Provide A Complex Condition In Install_requires ( Python Setuptools's Setup.py )
Does anybody know how I can provide a complex condition in the 'install_requires' section of setup.py? Something like this: install_requires = ['project1 >= 0.0.1 or project2 &
Solution 1:
You can write something like this:
def choose_proper_prject( requires ):
import pkg_resources
for req in requires:
try:
pkg_resources.require( req )
return [ req ]
except pkg_resources.DistributionNotFound :
pass
pass
print “There are no proper project installation available”
print “To use this app one of the following project versions have to be installed - %s” % requires
import os; os._exit( os.EX_OK )
pass
setup( ....
install_requires = choose_proper_prject( [ 'project1 >= 0.0.1', 'project2>=0.0.2' ]) + [ 'project3==0.9.0' ]
....
)
Post a Comment for "Provide A Complex Condition In Install_requires ( Python Setuptools's Setup.py )"