0

setup.py の「install_requires」セクションで複雑な条件を指定する方法を知っている人はいますか?

このようなもの:

install_requires = ['project1 >= 0.0.1 or project2 >=0.0.2', 'project3==0.9.0']

4

1 に答える 1

2

次のように書くことができます。

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' ]
       ....
      ) 
于 2013-01-10T06:49:45.833 に答える