问题
I want to check some requirements (but existence of other python packages, I already know how to do that) of the system before running setup()
, like check output of some system commands, to stop installation process and warn user if requirements doesn't met. But I need to do it only when running setup.py install
, not setup.py check
or setup.py sdist
.
How can I do that?
UPD: Example of check that I need:
packs = subprocess.check_output(['packagemanager', '--list'])
if NAME in packs:
print ('You have to remove previous version of %s '
'before installing this.' % NAME
)
sys.exit(1)
回答1:
setup(
...
install_requires=[PACKAGE1, PACKAGE2]
)
回答2:
I know what i'll do. I'll just look into sys.argv
to see if install
param was passed into setup.py
, before calling setup()
.
来源:https://stackoverflow.com/questions/20045802/check-some-requirements-when-running-setup-py-for-install