!56 [sync] PR-49: Fixed parsing of wheel file names with multiple platform tags

From: @openeuler-sync-bot 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
This commit is contained in:
openeuler-ci-bot 2023-12-19 08:53:24 +00:00 committed by Gitee
commit 65277f5edd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,66 @@
From 44193907eb308930de05deed863fb4d157c5c866 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= <alex.gronholm@nextday.fi>
Date: Sat, 5 Nov 2022 01:17:22 +0200
Subject: [PATCH] Fixed parsing of wheel file names with multiple platform tags
Reference:https://github.com/pypa/wheel/commit/44193907eb308930de05deed863fb4d157c5c866
Conflict:src/wheel/install.py src/tests/test_install.py
---
tests/test_install.py | 16 ++++++++++++++--
wheel/install.py | 4 ++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/tests/test_install.py b/tests/test_install.py
index 42db4f0..847bb31 100644
--- a/tests/test_install.py
+++ b/tests/test_install.py
@@ -20,6 +20,8 @@ import wheel.pep425tags
import wheel.tool
from wheel.install import WheelFile
+import pytest
+
THISDIR = os.path.dirname(__file__)
TESTWHEEL = os.path.join(THISDIR, 'test-1.0-py2.py3-none-win32.whl')
@@ -101,8 +103,18 @@ def test_install_tool():
"""Slightly improve coverage of wheel.install"""
wheel.tool.install([TESTWHEEL], force=True, dry_run=True)
-
-def test_wheelfile_re():
+@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
wf = WheelFile('foo-2-py3-none-any.whl')
assert wf.distinfo_name == 'foo-2.dist-info'
+
+ path = tmpdir.join(filename)
+ wf = WheelFile(str(path), "w")
+ assert wf.parsed_filename.group("namever") == "foo-2"
diff --git a/wheel/install.py b/wheel/install.py
index 792b707..26359da 100644
--- a/wheel/install.py
+++ b/wheel/install.py
@@ -32,8 +32,8 @@ VERSION_TOO_HIGH = (1, 0)
# 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<namever>(?P<name>[^-]+?)-(?P<ver>\d[^-]*?))(-(?P<build>\d[^-]*?))?
- -(?P<pyver>[a-z][^-]+?)-(?P<abi>[^-]+?)-(?P<plat>[^.]+?)(\.whl|\.dist-info)$""",
+ r"""^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))(-(?P<build>\d[^\s-]*?))?
+ -(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>\S+?)(\.whl|\.dist-info)$""",
re.VERBOSE).match
--
2.27.0

View File

@ -1,7 +1,7 @@
%bcond_with bootstrap
Name: python-wheel
Version: 0.31.1
Release: 6
Release: 7
Epoch: 1
Summary: Built-package format for Python
License: MIT
@ -12,6 +12,7 @@ BuildArch: noarch
Patch0000: remove-keyrings.alt-dependency.patch
Patch0001: 0001-Enabled-Intersphinx-linking-to-Python-documentation.patch
Patch0002: CVE-2022-40898.patch
Patch0003: backport-Fixed-parsing-of-wheel-file-names-with-multiple-platform-tags.patch
%description
A built-package format for Python.
@ -118,6 +119,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-3 -v --ignore build
%endif
%changelog
* Tue Dec 19 2023 shixuantong <shixuantong1@huawei.com> - 1:0.31.1-7
- Fixed parsing of wheel file names with multiple platform tags
* Fri Dec 08 2023 wangkai <13474090681@163.com> - 1:0.31.1-6
- Fix CVE-2022-40898