[Django] #33778: pyproject.toml uses the incorrect "legacy" setuptools backend and unnecessary wheel dep

1 view
Skip to first unread message

Django

unread,
Jun 13, 2022, 2:35:22 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
-----------------------------------------+------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 4.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
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

--
Ticket URL: <https://code.djangoproject.com/ticket/33778>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 13, 2022, 3:14:43 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------

Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* cc: Florian Apolloner, Nick Pope (added)
* component: Uncategorized => Packaging
* stage: Unreviewed => Accepted


Comment:

Thanks for the report.

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:1>

Django

unread,
Jun 13, 2022, 3:22:57 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Florian Apolloner):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:2>

Django

unread,
Jun 13, 2022, 4:18:10 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Carlton Gibson):

[https://github.com/django/django/pull/13994#issuecomment-776727097 Not
explicitly declaring this was raised and rejected on the original PR].
Unless something has changed this would be `wontfix`? 🤔

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:3>

Django

unread,
Jun 13, 2022, 4:38:21 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Michał Górny):

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 [https://peps.python.org/pep-0660/ PEP 660] explicitly
provisions for editable installs.

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:4>

Django

unread,
Jun 13, 2022, 4:42:19 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Florian Apolloner):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:5>

Django

unread,
Jun 13, 2022, 7:22:17 AM6/13/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Michał Górny):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:6>

Django

unread,
Jun 27, 2022, 2:04:00 PM6/27/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Rui):

Replying to [ticket:33778 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

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:7>

Django

unread,
Jul 1, 2022, 2:41:53 AM7/1/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+------------------------------------
Reporter: Michał Górny | Owner: nobody
Type: Bug | Status: new
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Florian Apolloner):

Replying to [comment:6 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 :)

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:8>

Django

unread,
Jul 4, 2022, 3:05:46 PM7/4/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+-----------------------------------------
Reporter: Michał Górny | Owner: Adit Krishnan
Type: Bug | Status: assigned

Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+-----------------------------------------
Changes (by Adit Krishnan):

* owner: nobody => Adit Krishnan
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:9>

Django

unread,
Jul 8, 2022, 4:16:27 AM7/8/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+-----------------------------------------
Reporter: Michał Górny | Owner: Adit Krishnan
Type: Bug | Status: assigned
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+-----------------------------------------

Comment (by Adam Johnson):

Thank you for reporting this, I've updated [https://adamj.eu/projects/ my
maintained packages] as a result.

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:10>

Django

unread,
Aug 12, 2022, 10:09:55 AM8/12/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
------------------------------+----------------------------------------
Reporter: Michał Górny | Owner: badziyoussef

Type: Bug | Status: assigned
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by badziyoussef):

* owner: nobody => badziyoussef


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:11>

Django

unread,
Aug 15, 2022, 5:40:03 AM8/15/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
-------------------------------------+-------------------------------------

Reporter: Michał Górny | Owner:
| badziyoussef
Type: Bug | Status: assigned
Component: Packaging | Version: 4.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/15954 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:12>

Django

unread,
Aug 15, 2022, 6:57:46 AM8/15/22
to django-...@googlegroups.com
#33778: pyproject.toml uses the incorrect "legacy" setuptools backend and
unnecessary wheel dep
-------------------------------------+-------------------------------------
Reporter: Michał Górny | Owner:
| badziyoussef
Type: Bug | Status: closed
Component: Packaging | Version: 4.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"247e25897b1682a1c15f240d780eb81ca01e0a5a" 247e2589]:
{{{
#!CommitTicketReference repository=""
revision="247e25897b1682a1c15f240d780eb81ca01e0a5a"
Fixed #33778 -- Updated build-system configuration.

This removes unnecessary wheel dependency and __legacy__ fallback.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33778#comment:13>

Reply all
Reply to author
Forward
0 new messages