Skip to content

Add PEP 794 import name metadata support to uv build backend#16598

Closed
terror wants to merge 7 commits into
astral-sh:mainfrom
terror:pep-794
Closed

Add PEP 794 import name metadata support to uv build backend#16598
terror wants to merge 7 commits into
astral-sh:mainfrom
terror:pep-794

Conversation

@terror

@terror terror commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Resolves #16435

This first pass extends the build backend to parse, validate, and emit project.import-names / project.import-namespaces, including the new error cases and prefix checks (outlined in the PEP 794 document), and bumps metadata output to 2.5 when either field is present. It also expands the shared metadata types so we can round-trip Import-Name headers and keeps the publish path tolerant of them.

There are a few follow-up PRs to consider here, namely:

  • Threading the new fields through the resolver/database/lock layers so we can surface them in front-end commands.
  • Exposing the metadata in user-facing tooling (uv pip show, diagnostics, etc.).
  • Considering a linter or helper for computing import names automatically.

I would be willing to get these in here as well, but it may balloon the diff making it harder to review.

@terror terror marked this pull request as ready for review November 5, 2025 05:53
let uses_pep794 = import_names_provided || import_namespaces_provided;
let metadata_version = if uses_pep794 {
debug!("Found import name metadata declarations, using METADATA 2.5");
"2.5"

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.

Note that shipping this is blocked on adding support in warehouse (pypi/warehouse#19083)

@agriyakhetarpal

Copy link
Copy Markdown

PyPI and packaging now both support PEP 794, so I think this PR can be revisited – thanks! Twine also has an open PR, which is being worked on: pypa/twine#1315.

@edgarrmondragon

Copy link
Copy Markdown
Contributor

I think that twine PR would be superseded by pypa/twine#1317. We're only waiting for a release now.

@zanieb zanieb requested a review from zsol May 12, 2026 17:43
@terror

terror commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

This is a tad old so I'm reviewing it as well 😅

@konstin

konstin commented May 12, 2026

Copy link
Copy Markdown
Member

I've rebased and added some fixes and rewrites in #19380

@terror

terror commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

I've rebased and added some fixes and rewrites in #19380

Ah, okay. I'll close this one out!

@terror terror closed this May 12, 2026
@konstin

konstin commented May 12, 2026

Copy link
Copy Markdown
Member

Sorry for the bad timing, I saw this earlier today and created a new branch (to avoid messing with the history here), not realizing that you were also reviving this at the same time.

@terror terror deleted the pep-794 branch May 12, 2026 22:51
konstin added a commit that referenced this pull request May 28, 2026
…#19380)

Support PEP 794 in the uv build backend, when publishing and when
parsing metadata, while checking for the banned conditions from the PEP.

This is rebase of #16598 with additional fixes.

---------

Co-authored-by: Liam <liam@scalzulli.com>
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.

Implement PEP 794 "Import Name Metadata" in uv_build

4 participants