packaging.python.org
packaging.python.org copied to clipboard
Is the section about `setuptools` and `wheel` required to build from source still relevant?
I just came across this section which states:
While
pip
alone is sufficient to install from pre-built binary archives, up to date copies of thesetuptools
andwheel
projects are useful to ensure you can also install from source archives
With PEP 517 now supported, is this still relevant? If not, I can push a PR removing it.
If I am not mistaken, when the project does not contain pyproject.toml
, pip
uses some internal heuristics (that depend on the state of the virtual/global environment) to determine whether to use build isolation.
My interpretation is that if the project does not have a pyproject.toml
file, and/or is not tested against build isolation, it is still useful to install setuptools
and wheel
.
In fact we received a couple of related issues later in setuptools
because some users still want to use "non-isolated" builds, but the latest versions of virtualenv
, venv
, etc no longer pre-install wheel
by default[^1].
Maybe the text could be improved, but I think that the information is somehow relevant for people that did not complete the transition yet.
[^1]: So we have to clarify that they are missing this step.
If I am not mistaken, when the project does not contain
pyproject.toml
,pip
uses some internal heuristics (that depend on the state of the virtual/global environment) to determine whether to use build isolation.
Looks like it just assumes setuptools
is the build backend (see https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#fallback-behaviour)? But probably that behaviour is limited to projects containing a pyproject.toml
file.
Maybe the text could be improved, but I think that the information is somehow relevant for people that did not complete the transition yet.
I agree with that.
Looks like it just assumes
setuptools
is the build backend (see https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#fallback-behaviour)? But probably that behaviour is limited to projects containing apyproject.toml
file.
Not really, it is more complex than that...
That is the planned fallback behaviour for the future, but right now pip
has 2 fallback modes.
- Assume as if the following is defined:
And use the APIs defined in PEP 517/660. This is probably what you are mentioning.[build-system] requires = ["setuptools>=40.8.0"] build-backend = "setuptools.build_meta:__legacy__"
- Don't use any PEP 517/660 APIs, instead just run
python setup.py sdist
andpython setup.oy bdist_wheel
in the current environment (global/virtual).
The choice between (1) and (2) varies depending on the state of the global/virtual environment and it is governed by pip
's internal heuristics. But note that the behaviour in 1 and 2 are fundamentally different.
I suppose that pip
's plan is to eventually retire (2), but last time I checked it was still being used.
I suppose that
pip
's plan is to eventually retire (2), but last time I checked it was still being used.
Indeed, the relevant code seems to be defined here
When no pyproject is available: if the user hasn't specified whether he'd like to use PEP517 and setuptools
or wheel
is available, PEP517 will not be used, and I don't have the bigger picture but I guess it will use the installed version of setuptools
/wheel
to install the library.
My interpretation is that if the project does not have a
pyproject.toml
file, and/or is not tested against build isolation, it is still useful to installsetuptools
andwheel
.
So with what was said above, I guess it makes sense to indicate you should have up to date versions of setuptools
and wheel
if you already have them installed in your environment (which is going to be less common with Python 3.12 not shipping setuptools
anymore), but it is probably not necessary if you don't have them installed, as pip
will fallback to build isolation? Not sure how to phrase this if we want to edit this section of the docs.