Skip to content

Remove monkeypatch allowing Metadata 2.0#1317

Merged
woodruffw merged 1 commit into
pypa:mainfrom
takluyver:rm-metadata-2.0-monkeypatch
May 9, 2026
Merged

Remove monkeypatch allowing Metadata 2.0#1317
woodruffw merged 1 commit into
pypa:mainfrom
takluyver:rm-metadata-2.0-monkeypatch

Conversation

@takluyver

Copy link
Copy Markdown
Member

There is a broken (#1315) monkeypatch to allow uploading packages with metadata version 2.0. However:

  • Metadata 2.0 was never officially a standard
  • Metadata 2.1 was accepted in 2018
  • PyPI stopped allowing uploads with metadata version 2.0 in 2024
    • although third party indices may still allow it, especially ones that do little or no validation of uploaded packages
  • It doesn't sound like anyone has any definite evidence that metadata 2.0 support is valuable, it's just retained as a precaution.
  • Anyone who does need it can pin an existing version of twine (it's unlikely they will also be using the latest features)

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.

@takluyver takluyver force-pushed the rm-metadata-2.0-monkeypatch branch from 6119d23 to 4d15ab0 Compare May 8, 2026 08:42
@takluyver takluyver force-pushed the rm-metadata-2.0-monkeypatch branch from 4d15ab0 to 4a98ab5 Compare May 8, 2026 08:44
@takluyver takluyver mentioned this pull request May 8, 2026

@woodruffw woodruffw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @takluyver!

@woodruffw woodruffw merged commit 4f20c0d into pypa:main May 9, 2026
23 checks passed
@takluyver

Copy link
Copy Markdown
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.

@takluyver takluyver deleted the rm-metadata-2.0-monkeypatch branch May 10, 2026 09:23
@gyscos gyscos mentioned this pull request May 27, 2026
4 tasks
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)
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

Successfully merging this pull request may close these issues.

3 participants