Search code examples
pythondistutils

Check some requirements when running setup.py for install


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)

Solution

  • 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().