Preserve compatible metadata versions in convert by itscloud0 · Pull Request #690 · pypa/wheel · GitHub
Skip to content

Preserve compatible metadata versions in convert - #690

Merged
agronholm merged 6 commits into
pypa:mainfrom
itscloud0:fix-643-preserve-convert-metadata-version
Jul 18, 2026
Merged

agronholm merged 6 commits into
pypa:mainfrom
itscloud0:fix-643-preserve-convert-metadata-version

Conversation

@itscloud0

Copy link
Copy Markdown
Contributor

Summary

Preserve the source metadata version during wheel convert when it is already compatible, instead of always rewriting converted metadata to 2.4.

Closes #643.

Problem

On current main, wheel convert rewrites converted PKG-INFO metadata to Metadata-Version: 2.4 unconditionally.

That means converting an egg with Metadata-Version: 2.1 produces a wheel whose METADATA advertises 2.4, even when the converted fields only require the older format. The issue report shows that this breaks downstream repositories such as Artifactory instances that still reject metadata newer than 2.3.

The packaging spec also says build tools may emit the lowest metadata version that supports the fields they write.

Solution

  • keep the source metadata version when it is already high enough for the converted fields
  • only bump older source metadata to 1.2, which is the minimum version needed for the generated Requires-Dist and Project-URL fields
  • update the convert expectations and add direct regression tests for both 1.1 -> 1.2 and 2.1 -> 2.1

Verification

  • .venv/bin/pytest -q
  • .venv/bin/pytest tests/commands/test_convert.py -q
  • .venv/bin/ruff check src/wheel/_commands/convert.py tests/commands/test_convert.py
  • PYTHONPATH=src .venv/bin/python - <<'PY' ... probe confirming 1.1 -> 1.2 and 2.1 -> 2.1

@codecov

codecov Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

@itscloud0
itscloud0 marked this pull request as ready for review July 4, 2026 17:25
@agronholm

Copy link
Copy Markdown
Contributor

So is it that Artifactory still doesn't support metadata 2.4?

@agronholm

Copy link
Copy Markdown
Contributor

All this touches is the metadata version number. Have you checked that the output metadata can still be compatible with all those previous metadata versions? Surely there have been significant changes over time.

@henryiii

Copy link
Copy Markdown
Contributor

I'm only familiar with the 2.1-2.6 range, but generally you do not ever want to auto-update the version if it was produced as an older version. For example, 2.2 make a change that you cannot auto-upgrade: it adds meaning to missing values that wasn't there before. I don't know about the pre-2 to 2 transition though (I think it's less defined, IIRC around 2.1 was the first strongly defined version? Maybe misremembering. I'm sure you could ask an LLM).

@agronholm

Copy link
Copy Markdown
Contributor

@agronholm agronholm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aside from the questions I asked, this also needs a changelog entry in docs/news.rst.

Comment thread src/wheel/_commands/convert.py Outdated
Comment thread tests/commands/test_convert.py Outdated

@agronholm agronholm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@agronholm
agronholm merged commit 4a63caf into pypa:main Jul 18, 2026
15 of 16 checks passed
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.

version 0.45: Metadata-Version change to 2.4 while converting breaks compatibility with Artifactory

3 participants