Opened 3 years ago
Closed 2 years ago
#33778 closed Bug (fixed)
pyproject.toml uses the incorrect "legacy" setuptools backend and unnecessary wheel dep
Reported by: | Michał Górny | Owned by: | badziyoussef |
---|---|---|---|
Component: | Packaging | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Florian Apolloner, Nick Pope | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The pyproject.toml file lists the following:
[build-system] requires = ['setuptools>=40.8.0', 'wheel'] build-backend = 'setuptools.build_meta:__legacy__'
The wheel dependency is redundant and discouraged here. Setuptools adds this dependency via the backend automatically since day one. It was historically included in the documentation but it was a mistake. See: https://github.com/pypa/setuptools/commit/f7d30a9529378cf69054b5176249e5457aaf640a
The legacy backend was never supposed to be used in pyproject.toml. It is only an "internal" fallback that is used by tools like pip when pyproject.toml is not present at all. The regular backend must always be used in pyproject.toml. See: https://github.com/pypa/setuptools/issues/1689
Change History (12)
comment:1 by , 3 years ago
Cc: | added |
---|---|
Component: | Uncategorized → Packaging |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 3 years ago
The wheel dependency is redundant and discouraged here. Setuptools adds this dependency via the backend automatically since day one. It was historically included in the documentation but it was a mistake. See: https://github.com/pypa/setuptools/commit/f7d30a9529378cf69054b5176249e5457aaf640a
Mhm, I can remember that some frontends did need it, not 100% sure though nowadays
The legacy backend was never supposed to be used in pyproject.toml. It is only an "internal" fallback that is used by tools like pip when pyproject.toml is not present at all. The regular backend must always be used in pyproject.toml. See: https://github.com/pypa/setuptools/issues/1689
This is a little bit more tricky. The problem here is that the presence of pyproject.toml
changes behavior. Hence our fix was using the __legacy__
backend. Most importantly pip install -e
wouldn't work otherwise.
comment:3 by , 3 years ago
Not explicitly declaring this was raised and rejected on the original PR. Unless something has changed this would be wontfix
? 🤔
comment:4 by , 3 years ago
Well, unless I'm testing wrong, after changing pyproject.toml to:
[build-system] requires = ['setuptools>=40.8.0'] build-backend = 'setuptools.build_meta' [tool.black] target-version = ['py38'] extend-exclude = 'tests/test_runner_apps/tagged/tests_syntax_error.py'
editable install just works™:
$ pip install -e . Obtaining file:///tmp/django Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Collecting sqlparse>=0.2.2 Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB) Collecting asgiref<4,>=3.4.1 Using cached asgiref-3.5.2-py3-none-any.whl (22 kB) Installing collected packages: sqlparse, asgiref, Django Running setup.py develop for Django Successfully installed Django-4.0.6.dev20220613071132 asgiref-3.5.2 sqlparse-0.4.2
This is with pip-22.0.4 (as injected into venv by Python).
Note that PEP 660 explicitly provisions for editable installs.
comment:5 by , 3 years ago
Hi, it is great to hear that this works nowadays. What happens with an older pip like on ubuntu 18.04 or 20.04? Though I guess it would be okay to say that editable installs are not supported there.
follow-up: 8 comment:6 by , 3 years ago
I've tested a bunch of old pip version with these changes (and the hack from setup.py
removed) and FWICS:
- pip 10.0.1 (Apr 2018) complains about the missing
wheel
dependency because it "does not implement PEP 517 so it cannot build a wheel without 'setuptools' and 'wheel'" but I don't think that's very relevant - I was able to
pip install -e .
correctly with all versions down to 9.0 (Nov 2016); older versions seem to be broken with Python 3.9
Just in case, I've also tried downgrading setuptools and managed to get pip install -e .
working down to setuptools 41.1.0 (Aug 2019); older versions seem to be broken with Python 3.9.
comment:7 by , 2 years ago
Replying to Michał Górny:
hello,I'm new to package program, what means to used incorrect legacy backend?how to fix it? Besides,just need to remove duplicated 'wheel' requires?
The pyproject.toml file lists the following:
[build-system] requires = ['setuptools>=40.8.0', 'wheel'] build-backend = 'setuptools.build_meta:__legacy__'The wheel dependency is redundant and discouraged here. Setuptools adds this dependency via the backend automatically since day one. It was historically included in the documentation but it was a mistake. See: https://github.com/pypa/setuptools/commit/f7d30a9529378cf69054b5176249e5457aaf640a
The legacy backend was never supposed to be used in pyproject.toml. It is only an "internal" fallback that is used by tools like pip when pyproject.toml is not present at all. The regular backend must always be used in pyproject.toml. See: https://github.com/pypa/setuptools/issues/1689
comment:8 by , 2 years ago
Replying to Michał Górny:
I've tested a bunch of old pip version with these changes (and the hack from
setup.py
removed) and FWICS …
Ok, that sounds good, I guess we can really change that for the main branch then. After all we require rather new pythons nowadays :)
comment:10 by , 2 years ago
Thank you for reporting this, I've updated my maintained packages as a result.
comment:11 by , 2 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Thanks for the report.