feat: add strict wheel filename validation - #1309
Open
itscloud0 wants to merge 3 commits into
Open
Conversation
notatallshaw
requested changes
Jul 1, 2026
notatallshaw
left a comment
Member
There was a problem hiding this comment.
As discussed in the issue, the specification changed and there are now two ways the specification says a wheel should be parsed, strictly for tools that don't have to deal with old wheels, and leniently for tools that do. Packaging doesn't know what the context of the caller is.
itscloud0
marked this pull request as ready for review
July 2, 2026 05:12
brettcannon
requested changes
Jul 10, 2026
|
|
||
| If **validate_order** is true, compressed tag set components are | ||
| checked to be in sorted order as required by PEP 425. | ||
| If **strict** is true, the version component must already be |
Member
There was a problem hiding this comment.
Why only the version component? The spec says to normalize the name.
Contributor
There was a problem hiding this comment.
That reminds me, what about ensuring the tags are sorted, too?
Member
There was a problem hiding this comment.
tags are sorted
Alphanumerically?
itscloud0
force-pushed
the
fix-873-normalized-wheel-version
branch
from
July 20, 2026 05:12
3e6503b to
895647d
Compare
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.
Summary
Fixes #873.
parse_wheel_filename()remains lenient for legacy wheel consumers. Withstrict=True, it now validates all three normalized wheel-filename components: the project name in wheel form, the PEP 440 version token, and sorted compressed tag sets.User outcome
Strict consumers can reject malformed wheel filenames without changing the existing lenient parser behavior for installed legacy artifacts.
Verification
uv run --group test pytest tests/test_utils.py -quvx ruff check src/packaging/utils.py tests/test_utils.pyuvx ruff format --check src/packaging/utils.py tests/test_utils.pyLimitations
This opt-in change is scoped to wheel filenames; sdist parsing and the default lenient API remain unchanged.