Skip to content

Conversation

@di
Copy link
Member

@di di commented Dec 3, 2025

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:

Some todos:

  • Enforce compressed tag set ordering
  • General alignment w/ error messages vs. what PyPI uses
  • Documentation
  • Deprecation of parse_wheel_filename and parse_sdist_filename

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}"
)
Copy link
Member

@notatallshaw notatallshaw Dec 5, 2025

Choose a reason for hiding this comment

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

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

Copy link
Member

@notatallshaw notatallshaw left a comment

Choose a reason for hiding this comment

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

Big resolutions in pip involve scanning hundreds of thousands of distributions, can all the classes please use __slots__.

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.

2 participants