Skip to content

Commit

Permalink
Normalize wheel distribution filenames parsed from wheels
Browse files Browse the repository at this point in the history
Allowing us to unpack wheels with non-normalized filenames.

Part of pypa#97, but doesn't retrieve the names from distribution metadata,
yet.

Fixes: pypa#134
  • Loading branch information
stefanor committed Aug 15, 2022
1 parent c7711ac commit 3e2e542
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/installer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ def parse_wheel_filename(filename: str) -> WheelFilename:
wheel_info = _WHEEL_FILENAME_REGEX.match(filename)
if not wheel_info:
raise ValueError(f"Not a valid wheel filename: {filename}")
return WheelFilename(*wheel_info.groups())
parsed = wheel_info.groups()
normalized_name = normalize_distribution_name(parsed[0])
return WheelFilename(normalized_name, *parsed[1:])


def copyfileobj_with_hashing(
Expand Down
5 changes: 5 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ class TestParseWheelFilename:
"tensorflow-2.3.0-cp38-cp38-win_amd64.whl",
WheelFilename("tensorflow", "2.3.0", None, "cp38-cp38-win_amd64"),
),
# Non-canonicalized real wheel names
(
"Quart-0.18.0-py3-none-any.whl",
WheelFilename("quart", "0.18.0", None, "py3-none-any"),
),
],
)
def test_valid_cases(self, string, expected):
Expand Down

0 comments on commit 3e2e542

Please sign in to comment.