From 3e117d5e30400ec916f218159eb8c61d9c8b44ba Mon Sep 17 00:00:00 2001 From: Ee Durbin Date: Mon, 18 Nov 2024 18:47:29 -0500 Subject: [PATCH] relax wheel filename restriction from #17107 (#17112) * relax wheel filename restriction from #17107 the restrictions applied in #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 --- tests/unit/forklift/test_legacy.py | 2 +- warehouse/forklift/legacy.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py index ab6458f0f164..4956552428e4 100644 --- a/tests/unit/forklift/test_legacy.py +++ b/tests/unit/forklift/test_legacy.py @@ -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): diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py index e7915cef17c8..41beb6945bf7 100644 --- a/warehouse/forklift/legacy.py +++ b/warehouse/forklift/legacy.py @@ -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: