Draft
Conversation
notatallshaw
reviewed
Dec 5, 2025
Comment on lines
+64
to
+70
| self.name = canonicalize_name(name).replace("-", "_") | ||
|
|
||
| # Check that the name is normalized | ||
| if strict and self.original_name != self.name: | ||
| raise InvalidWheelFilename( | ||
| f"Invalid filename (non-normalized project name {name!r}): {filename!r}" | ||
| ) |
Member
There was a problem hiding this comment.
Pip will almost always use strict=False, which is spec complaint:
Tools consuming wheels must be prepared to accept . (FULL STOP) and uppercase letters, however, as these were allowed by an earlier version of this specification.
So we do not want to call canonicalize_name on every instantiation of WheelFilename, perhaps something like:
if not strict:
self._name = None
else:
# Check that the name is normalized
self._name = canonicalize_name(name).replace("-", "_")
if strict and self.original_name != self._name:
raise InvalidWheelFilename(
f"Invalid filename (non-normalized project name {name!r}): {filename!r}"
)
...
@property
def name(self) -> NormalizedName:
if self._name is None:
self._name = canonicalize_name(name).replace("-", "_")
return self._name
notatallshaw
reviewed
Dec 5, 2025
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.
Draft PR so @woodruffw can contribute here. I'm also fine w/ early reviews/comments and bikeshedding on the API names.
Eventually, this should resolve:
parse_sdist_filename#527parse_wheel_filenamepermits non-normalized versions. #873parse_wheel_filenamesaccepts wheel filenames with unsorted compressed tag sets #909Some todos:
parse_wheel_filenameandparse_sdist_filename