Exclude certain dependency version ranges in setuptools/pip

后端 未结 2 1485

Currently the Django Project supports 1.4, 1.7 and 1.8. In my setup.py I want to reflect these versions as being supported.

install_requires=[\'Djan         


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-20 09:08

    You can use Django>=1.4.2,<1.9,!=1.5.*,!=1.6.*

    This is defined inside PEP440.

    You can test this behavior with the packaging module that is vendored inside the last versions of setuptools and pip.

    In [1]: from packaging import specifiers
    
    In [2]: sp=specifiers.SpecifierSet(">=1.4.2,<1.9,!=1.5.*,!=1.6.*")
    
    In [3]: sp.contains("1.4.2")
    Out[3]: True
    
    In [4]: sp.contains("1.6.4")
    Out[4]: False
    
    In [5]: sp.contains("1.8.2")
    Out[5]: True
    

提交回复
热议问题