Skip to content

Commit

Permalink
relax wheel filename restriction from pypi#17107 (pypi#17112)
Browse files Browse the repository at this point in the history
* relax wheel filename restriction from pypi#17107

the restrictions applied in pypi#17107 introduced a bit _too_ strict handling of wheels than we're ready for. using the parse_wheel_filename normalized name/version, which is a new and more strict constraint than intended

* lint
  • Loading branch information
ewdurbin authored Nov 18, 2024
1 parent f40fa5e commit 3e117d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def test_invalid_wheel_filename(self, tmpdir):

assert legacy._is_valid_dist_file(f, "bdist_wheel") == (
False,
"Invalid wheel filename (wrong number of parts): 'cheese'",
"Unable to parse name and version from wheel filename",
)

def test_incorrect_number_of_top_level_directories_sdist_tar(self, tmpdir):
Expand Down
8 changes: 3 additions & 5 deletions warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,11 @@ def _is_valid_dist_file(filename, filetype):
return False, f"PKG-INFO not found at {target_file}"
if filename.endswith(".whl"):
try:
name, version, _, _ = packaging.utils.parse_wheel_filename(
os.path.basename(filename)
)
except packaging.utils.InvalidWheelFilename as e:
name, version, _ = os.path.basename(filename).split("-", 2)
except ValueError:
return (
False,
str(e),
"Unable to parse name and version from wheel filename",
)
target_file = os.path.join(f"{name}-{version}.dist-info", "WHEEL")
try:
Expand Down

0 comments on commit 3e117d5

Please sign in to comment.