Using python_requires to require Python 2.7 or 3.2+

wolfy1339 picture wolfy1339 · Jun 20, 2017 · Viewed 9.3k times · Source

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

Answer

wim picture wim · Jun 20, 2017

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

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

Note that the metadata generated is only respected by pip>=9.0.0.