Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 956
wolfy1339 Avatar asked Jun 20 '17 18:06

wolfy1339


People also ask

How do I set python version in setup py?

setup(name="my_package_name", python_requires='>3.5. 2', [...] Save this answer.

What does python setup py bdist_wheel do?

What is python setup py bdist_wheel? python setup.py bdist_wheel. This will build any C extensions in the project and then package those and the pure Python code into a . whl file in the dist directory.

What is setup CFG python?

The setup. cfg is an ini file, containing option defaults for setup.py commands. You can pretty much specify every keyword we used in the setup.py file in the new setup. cfg file and simply use the setup.py file as the command line interface.

What is python M build?

python -m build uses the build module (which may in-turn read a setup.py file, if it exists) – OneCricketeer. Jul 28, 2021 at 1:18. 2. @OneCricketeer The doc of build module says build is roughly the equivalent of setup.py sdist bdist_wheel but with PEP 517 support, allowing use with projects that don't use setuptools.


1 Answers

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).

like image 193
wim Avatar answered Oct 10 '22 12:10

wim