From 44193907eb308930de05deed863fb4d157c5c866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sat, 5 Nov 2022 01:17:22 +0200 Subject: [PATCH] Fixed parsing of wheel file names with multiple platform tags Fixes #485. --- docs/news.rst | 5 +++++ src/wheel/__init__.py | 2 +- src/wheel/wheelfile.py | 4 ++-- tests/test_wheelfile.py | 14 +++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/news.rst b/docs/news.rst index 77a96610..8ef3bc5c 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,11 @@ Release Notes ============= +**0.38.2 (2022-11-05)** + +- Fixed regression introduced in v0.38.1 which broke parsing of wheel file names with + multiple platform tags + **0.38.1 (2022-11-04)** - Removed install dependency on setuptools diff --git a/src/wheel/__init__.py b/src/wheel/__init__.py index db16b91c..6184ced7 100644 --- a/src/wheel/__init__.py +++ b/src/wheel/__init__.py @@ -1,3 +1,3 @@ from __future__ import annotations -__version__ = "0.38.1" +__version__ = "0.38.2" diff --git a/src/wheel/wheelfile.py b/src/wheel/wheelfile.py index f55fc737..8ae97336 100644 --- a/src/wheel/wheelfile.py +++ b/src/wheel/wheelfile.py @@ -16,8 +16,8 @@ # Non-greedy matching of an optional build number may be too clever (more # invalid wheel filenames will match). Separate regex for .dist-info? WHEEL_INFO_RE = re.compile( - r"""^(?P(?P[^-]+?)-(?P[^-]+?))(-(?P\d[^-]*))? - -(?P[^-]+?)-(?P[^-]+?)-(?P[^.]+?)\.whl$""", + r"""^(?P(?P[^\s-]+?)-(?P[^\s-]+?))(-(?P\d[^\s-]*))? + -(?P[^\s-]+?)-(?P[^\s-]+?)-(?P\S+)\.whl$""", re.VERBOSE, ) MINIMUM_TIMESTAMP = 315532800 # 1980-01-01 00:00:00 UTC diff --git a/tests/test_wheelfile.py b/tests/test_wheelfile.py index 9ff5a328..ce134f9d 100644 --- a/tests/test_wheelfile.py +++ b/tests/test_wheelfile.py @@ -14,9 +14,16 @@ def wheel_path(tmpdir): return str(tmpdir.join("test-1.0-py2.py3-none-any.whl")) -def test_wheelfile_re(tmpdir): - # Regression test for #208 - path = tmpdir.join("foo-2-py3-none-any.whl") +@pytest.mark.parametrize( + "filename", + [ + "foo-2-py3-none-any.whl", + "foo-2-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + ], +) +def test_wheelfile_re(filename, tmpdir): + # Regression test for #208 and #485 + path = tmpdir.join(filename) with WheelFile(str(path), "w") as wf: assert wf.parsed_filename.group("namever") == "foo-2" @@ -29,6 +36,7 @@ def test_wheelfile_re(tmpdir): "test-1.0-py2.whl", "test-1.0-py2-none.whl", "test-1.0-py2-none-any", + "test-1.0-py 2-none-any.whl", ], ) def test_bad_wheel_filename(filename):