本文介绍了在 install_requires ( Python setuptools's setup.py ) 中提供一个复杂的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道我如何在 setup.py 的install_requires"部分提供复杂的条件?
Does anybody know how I can provide a complex condition in the "install_requires" section of setup.py?
像这样:
install_requires = ['project1 >= 0.0.1 or project2 >=0.0.2', 'project3==0.9.0']
推荐答案
你可以这样写:
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' ]
....
)
这篇关于在 install_requires ( Python setuptools's setup.py ) 中提供一个复杂的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!