setuptools could respect python_requires
See original GitHub issueExample: setup.py
from setuptools import setup
setup(
name="my package",
py_modules=["mypackage"],
python_requires=">=3.4",
)
Example steps to reproduce:
$ python2 setup.py install
...
Installed .../lib/python2.7/site-packages/my_package-0.0.0-py2.7.egg
Processing dependencies for my-package==0.0.0
Finished processing dependencies for my-package==0.0.0
Expected: Command fails with an error explaining that the Python version isn’t supported.
Some packages workaround this by adding the following to the top of their setup.py
:
if sys.version_info < (3, 4):
raise Exception(...)
Rather than relying on each package to implement this, it could be handled once by setuptools.
An important use case, after porting a package to Python-3-only, one may mistakenly do:
$ python setup.py bdist_wheel
On a system where python
is Python 2 (most Linux systems), this produces a Python 2 wheel instead of a Python 3 wheel. This is clearly a mistake by the user, but if setuptools were to bail early, the mistake wouldn’t make it to PyPI.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Prevent package from being installed on old Python versions
In your setup.py file, pass setup() a python_requires argument that ... python_requires argument to be processed; earlier versions will just ...
Read more >Why you shouldn't invoke setup.py directly - Paul Ganssle
When you ran setup.py, setuptools would globally install whatever was in setup_requires before actually attempting to build your package.
Read more >Dependencies Management in Setuptools
There are three types of dependency styles offered by setuptools: 1) build system requirement, 2) required dependency and 3) optional dependency.
Read more >setup.py vs setup.cfg in Python - Towards Data Science
Discussing about setuptools and the difference between setup.py, setup.cfg ... respect to the purpose of requirements.txt and setuptools you can read one of ......
Read more >Packaging and Python 2 - Discussions on Python.org
Concerning setuptools, I think a deprecation notice of a few months would have ... I guess pip could potentially be taught to respect...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fair enough, thanks @pganssle! I think deprecating it would be a good start so people can move to more friendly and stable setups with
tox
. 👍This has some problems, which are essentially the same problems that invoking
setup.py
directly has, namely that in order to respectpython_requires
,setup()
needs to run successfully, at least to the point where it parses the python version requirement. This means that anyone counting onsetup.py
only being run in Python 3 may have arbitrary failures.Another issue is that
python_requires
is really intended to apply to the installed version of the package. It’s entirely plausible to build a Python 3-only package with Python 2 and vice versa, it’s just kinda rarely done. It’s not a big deal, but given the other problems with this approach, I’m not sure it makes sense to conflate the two pieces of metadata.It would make sense if this information were stored in
pyproject.toml
, since it is meta-information about the build system itself. We can either lobby to add that to thepyproject.toml
build-system
spec or possibly just add a setuptools-specific configuration option topyproject.toml
when we resolve #1515.