Search code examples
pythonpython-2.7setuptoolssetup.pypypi

Using python_requires to require Python 2.7 or 3.2+


How do I use python_requires classifier in setup.py to require Python 2.7.* or 3.2+?

I have tried many configurations, including this one: ~=2.7,==3,!=3.0,!=3.1,<4 but none have worked


Solution

  • This argument for setuptools uses the PEP440 version specifiers spec, so you can ask for:

    python_requires='>=2.7,!=3.0.*,!=3.1.*'
    

    The commas , are equivalent to logical and operator.

    Note that the metadata generated is only respected by pip>=9.0.0 (Nov 2016).