Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the section about setuptools and wheel required to build from source still relevant? #1517

Open
Viicos opened this issue Mar 5, 2024 · 4 comments

Comments

@Viicos
Copy link

Viicos commented Mar 5, 2024

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 the setuptools and wheel 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.

@abravalheri
Copy link
Contributor

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

Maybe the text could be improved, but I think that the information is somehow relevant for people that did not complete the transition yet.

Footnotes

  1. So we have to clarify that they are missing this step.

@chrysle
Copy link
Contributor

chrysle commented Mar 8, 2024

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.

@abravalheri
Copy link
Contributor

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.

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.

  1. Assume as if the following is defined:
    [build-system]
    requires = ["setuptools>=40.8.0"]
    build-backend = "setuptools.build_meta:__legacy__"
    And use the APIs defined in PEP 517/660. This is probably what you are mentioning.
  2. Don't use any PEP 517/660 APIs, instead just run python setup.py sdist and python 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.

@Viicos
Copy link
Author

Viicos commented Mar 14, 2024

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 install setuptools and wheel.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@abravalheri @Viicos @chrysle and others