Remove monkeypatch allowing Metadata 2.0#1317
Merged
Merged
Conversation
6119d23 to
4d15ab0
Compare
4d15ab0 to
4a98ab5
Compare
Closed
sigmavirus24
approved these changes
May 8, 2026
Member
Author
|
Thanks both! Could I ask you to do a release soon, since the monkeypatch prevents anyone uploading packages with metadata version 2.5. |
Open
1 task
gaborbernat
added a commit
to tox-dev/pipdeptree
that referenced
this pull request
Jun 1, 2026
#591) The `pkg_meta` CI environment started failing on every branch with: ``` twine check ... ERROR InvalidDistribution: Invalid distribution metadata: '2.5' is not a valid metadata version ``` hatchling 1.30.0 began emitting `Metadata-Version: 2.5` (PEP 794, adding `Import-Name`/`Import-Namespace`), and `[build-system].requires` pinned only `hatchling>=1.27`, so fresh CI resolved to 1.30. 🔧 The problem is not just the checker: metadata 2.5 cannot actually be published today. - The latest released twine (6.2.0) monkeypatches `packaging`'s validator to a hardcoded list ending at 2.4, so `twine check` rejects 2.5. The monkeypatch was removed in pypa/twine#1317, but that is unreleased — there is no twine release that accepts 2.5, so bumping the `twine>=` floor is not an option. - PyPI itself does not accept Metadata-Version 2.5 uploads yet — pypi/warehouse#19083 is still open; warehouse supports up to 2.4. So a 2.5 wheel is unpublishable regardless of the checker, and `pkg_meta`'s red is correct signal. The minimal fix that keeps the package genuinely publishable is to cap the build backend just below the version that introduced 2.5: ``` hatchling>=1.27,<1.30 ``` This produces Metadata-Version 2.4, which both released twine and PyPI accept. Verified `tox -e pkg_meta` goes green (uv build + twine check + check-wheel-contents). ⏳ A comment in `pyproject.toml` marks this as removable once twine ships pypa/twine#1317 and PyPI implements pypi/warehouse#19083 — at which point the cap should drop and the `twine>=` floor bump instead. Refs: - pypa/twine#1146 — twine fails on latest metadata-version (tracking) - pypa/twine#1317 — removes the validator monkeypatch (merged, unreleased) - pypi/warehouse#19083 — PyPI support for Metadata 2.5 (open)
gaborbernat
added a commit
to tox-dev/pipdeptree
that referenced
this pull request
Jun 1, 2026
Follow-up to #591. That PR capped `hatchling<1.30` because 1.30 emitted Metadata-Version 2.5 (PEP 794), which no released twine and PyPI accept yet. hatchling 1.30.0 has since been **yanked** from PyPI, with the yank reason: *"the default core metadata version was increased to 2.5 and some major projects like twine do not yet support it."* pip and uv skip yanked releases during resolution, so the build now lands on 1.29.0 (Metadata-Version 2.4) without any upper bound. ⏪ The explicit cap is therefore redundant. Dropping it back to `hatchling>=1.27` keeps us forward compatible: the full chain to publishing 2.5 needs a twine release (pypa/twine#1317), then a pypa/gh-action-pypi-publish release, then dependabot bumping the pinned publish action — once that lands, a future unyanked hatchling can emit 2.5 without another pyproject edit. Verified locally: with no cap the build resolves to hatchling 1.29.0, emits Metadata-Version 2.4, and `tox -e pkg_meta` passes (uv build + twine check + check-wheel-contents). Refs: - #591 — the cap this reverts - pypa/twine#1317 — removes the validator monkeypatch (merged, unreleased) - pypi/warehouse#19083 — PyPI support for Metadata 2.5 (open)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is a broken (#1315) monkeypatch to allow uploading packages with metadata version 2.0. However:
This removes the monkeypatch, as an alternative to fixing it and hoping packaging never changes in a way that breaks it.
I've done a fairly rough job on the tests for now; I don't know if the idea will be accepted, so I didn't want to spend too much time on it. The wheel for twine 4.0.2 has metadata version 2.1, and 6.2.0 has metadata 2.4.