Check some requirements when running setup.py for install

时光总嘲笑我的痴心妄想 提交于 2020-01-16 01:01:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!