Gate Python package artifacts on wheel METADATA vs setup.cfg dependency parity#4528
Closed
Copilot wants to merge 3 commits into
Closed
Gate Python package artifacts on wheel METADATA vs setup.cfg dependency parity#4528Copilot wants to merge 3 commits into
METADATA vs setup.cfg dependency parity#4528Copilot wants to merge 3 commits into
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/cc7e1047-d695-4594-a891-382bde1beefc Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Agent-Logs-Url: https://github.com/envoyproxy/toolshed/sessions/cc7e1047-d695-4594-a891-382bde1beefc Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix wheel-METADATA leak in aio.core package
Gate Python package artifacts on wheel May 14, 2026
METADATA vs setup.cfg dependency parity
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.
The existing wheel-metadata coverage only validated a single fixture target, so leaked
Requires-Distentries in real published wheels were not caught in CI. This change adds a post-package gate over actual built wheels and removes the fixture-only check path that missed regressions.Post-build wheel metadata verifier (new script)
py/tools/publish_check/check_wheel_metadata.pyto scandist/*.whlafterpants package ::.*.dist-info/METADATARequires-Dist(excludingextra == ...markers)py/*/setup.cfgvia canonicalized package names[options] install_requiresusing the same minimal parser pattern used in tooling macroscanonicalize_name+Requirement(...).specifierunexpected/missingdiffs.1on any mismatch2whendist/has no wheels.CI package job gating
.github/workflows/py.yml(packagejob) to run metadata verification between:Run pants packageArchive wheels/Archive sdists).Removed obsolete fixture-only coverage
py/tools/publish_check/test_publish_wheel_metadata.py.publish_wheel_metadata_checktarget frompy/tools/publish_check/BUILD.publish_checkintact (setup.cfg vs lockfile consistency remains unchanged).Documentation
py/tools/publish_check/README.mdnote clarifying why the check runs outside the Pants test graph (it validates builtdist/*artifacts).Example of the new CI gate step:
Original prompt
Context
PR #4527 fixed a wheel-METADATA leak in
py/aio.corewhere pinned//py/deps:reqs#*targets attached to the innerpython_sources(viatoolshed_library(dependencies=[...])) were being baked intoRequires-Dist. The publishedaio.corewheel ended up with entries likeabstracts==0.2.0,pyyaml==6.0.3,trycast==1.3.0, plus stub-only packagestypes-orjson==3.6.2andtypes-pyyaml==6.0.12.20260508— none of which are inpy/aio.core/setup.cfginstall_requires.The existing test at
py/tools/publish_check/test_publish_wheel_metadata.py(target//py/tools/publish_check:publish_wheel_metadata_check) only exercises a single fixture package//py/_test_publish_pkg:packageviaruntime_package_dependencies, and asserts against hardcoded_EXPECTED_*constants. The fixture happens to already be in the "correct" shape so the test stays green even while every realpy/*package was leaking. This is what allowed PR #4527's bug to ship to PyPI.Goal
Catch wheel-METADATA leaks in CI on the actual wheels that get published, without rebuilding them. The
packagejob in.github/workflows/py.ymlalready runspants --colors package ::, which produces every wheel indist/*.whl. Add a verification step in that same job, betweenRun pants packageandArchive wheels, that:dist/*.whl.*.dist-info/METADATAand collects allRequires-Dist:entries excluding those gated by; extra == "..."markers (i.e. only the runtime/required dist deps, not extras).py/<pkg>/setup.cfgby matching the wheel's normalized dist name to[metadata] name = ...in each setup.cfg underpy/*/setup.cfg.[options] install_requiresfrom that setup.cfg using the same minimal parser style already used inpy/pants-toolshed/macros.py::_setup_cfg_install_requiresandpy/pants-toolshed/toolshed_setup_cfg.packaging.utils.canonicalize_namefor the name andpackaging.requirements.Requirement(...).specifierfor the version specifier, then asserts the two sets are equal — not subset. Mismatches (either direction: leaked extras OR missing requirements) must fail the job with a clear per-wheel diff showing the unexpected and missing entries.dist/contains no wheels.This step MUST run before
Archive wheels/Archive sdistsso that a leak gates the publish artefact upload.Concrete changes
1. New script:
py/tools/publish_check/check_wheel_metadata.pyStandalone python script (no pants test framework needed — it's a post-build verification). Implementation outline already drafted in the chat discussion that led to this issue; reproduce it faithfully: