Drop requirement on python-wheel-wheel with setuptools >= 71

This commit is contained in:
Miro Hrončok 2025-05-05 09:54:32 +02:00
commit e3f12dbc36
3 changed files with 174 additions and 4 deletions

View file

@ -0,0 +1,120 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Date: Fri, 25 Apr 2025 00:46:20 +0100
Subject: 00460: gh-132415: Update vendored setuptools in
``Lib/test/wheeldata``
(cherry picked from commit c9f3f5b4ed52d7bed6073ffa39717ece47202558)
(actual changes in .whl files removed to make this patch smaller)
gh-127906: Add missing sys import to test_cppext
(cherry picked from commit 9cba14881b371b1e95d57877896169c4605f9b75)
Co-Authored-By: Victor Stinner <vstinner@python.org>
---
Lib/test/support/__init__.py | 14 +++++++-------
Lib/test/test_cext/__init__.py | 2 +-
Lib/test/test_cppext/__init__.py | 2 +-
Lib/test/test_cppext/setup.py | 1 +
Lib/test/test_peg_generator/test_c_parser.py | 2 +-
5 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 6d670a575b..7f72c689e8 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2415,7 +2415,7 @@ def _findwheel(pkgname):
filenames = os.listdir(wheel_dir)
filenames = sorted(filenames, reverse=True) # approximate "newest" first
for filename in filenames:
- # filename is like 'setuptools-67.6.1-py3-none-any.whl'
+ # filename is like 'setuptools-{version}-py3-none-any.whl'
if not filename.endswith(".whl"):
continue
prefix = pkgname + '-'
@@ -2424,16 +2424,16 @@ def _findwheel(pkgname):
raise FileNotFoundError(f"No wheel for {pkgname} found in {wheel_dir}")
-# Context manager that creates a virtual environment, install setuptools and wheel in it
-# and returns the path to the venv directory and the path to the python executable
+# Context manager that creates a virtual environment, install setuptools in it,
+# and returns the paths to the venv directory and the python executable
@contextlib.contextmanager
-def setup_venv_with_pip_setuptools_wheel(venv_dir):
- import shlex
+def setup_venv_with_pip_setuptools(venv_dir):
import subprocess
from .os_helper import temp_cwd
def run_command(cmd):
if verbose:
+ import shlex
print()
print('Run:', ' '.join(map(shlex.quote, cmd)))
subprocess.run(cmd, check=True)
@@ -2457,10 +2457,10 @@ def run_command(cmd):
else:
python = os.path.join(venv, 'bin', python_exe)
- cmd = [python, '-X', 'dev',
+ cmd = (python, '-X', 'dev',
'-m', 'pip', 'install',
_findwheel('setuptools'),
- _findwheel('wheel')]
+ )
run_command(cmd)
yield python
diff --git a/Lib/test/test_cext/__init__.py b/Lib/test/test_cext/__init__.py
index 402a2d04fa..46fde54149 100644
--- a/Lib/test/test_cext/__init__.py
+++ b/Lib/test/test_cext/__init__.py
@@ -53,7 +53,7 @@ def test_build_limited_c11(self):
def check_build(self, extension_name, std=None, limited=False):
venv_dir = 'env'
- with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:
+ with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
self._check_build(extension_name, python_exe,
std=std, limited=limited)
diff --git a/Lib/test/test_cppext/__init__.py b/Lib/test/test_cppext/__init__.py
index 13f9ea1c56..2b7adac4bc 100644
--- a/Lib/test/test_cppext/__init__.py
+++ b/Lib/test/test_cppext/__init__.py
@@ -54,7 +54,7 @@ def test_build_limited(self):
def check_build(self, extension_name, std=None, limited=False):
venv_dir = 'env'
- with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:
+ with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
self._check_build(extension_name, python_exe,
std=std, limited=limited)
diff --git a/Lib/test/test_cppext/setup.py b/Lib/test/test_cppext/setup.py
index b30c9e2746..ea1ed64bf7 100644
--- a/Lib/test/test_cppext/setup.py
+++ b/Lib/test/test_cppext/setup.py
@@ -3,6 +3,7 @@
import os
import platform
import shlex
+import sys
import sysconfig
from test import support
diff --git a/Lib/test/test_peg_generator/test_c_parser.py b/Lib/test/test_peg_generator/test_c_parser.py
index 1411e55dd0..1095e7303c 100644
--- a/Lib/test/test_peg_generator/test_c_parser.py
+++ b/Lib/test/test_peg_generator/test_c_parser.py
@@ -99,7 +99,7 @@ def setUpClass(cls):
cls.addClassCleanup(shutil.rmtree, cls.library_dir)
with contextlib.ExitStack() as stack:
- python_exe = stack.enter_context(support.setup_venv_with_pip_setuptools_wheel("venv"))
+ python_exe = stack.enter_context(support.setup_venv_with_pip_setuptools("venv"))
sitepackages = subprocess.check_output(
[python_exe, "-c", "import sysconfig; print(sysconfig.get_path('platlib'))"],
text=True,

View file

@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Fri, 25 Apr 2025 09:33:37 +0200
Subject: 00461: Downstream only: Install wheel in test venvs when setuptools <
71
This can be removed when Fedora 41 goes EOL (or updates setuptools).
---
Lib/test/support/__init__.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 7f72c689e8..e15f18c47e 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -2457,9 +2457,16 @@ def run_command(cmd):
else:
python = os.path.join(venv, 'bin', python_exe)
+ setuptools_whl = _findwheel('setuptools')
+ whl_filename = os.path.basename(setuptools_whl)
+ setuptools_major = int(whl_filename.split('-')[1].split('.')[0])
+ if setuptools_major >= 71: # we need 70.1+, but that's OK
+ wheels = (setuptools_whl,)
+ else:
+ wheels = (setuptools_whl, _findwheel('wheel'))
cmd = (python, '-X', 'dev',
'-m', 'pip', 'install',
- _findwheel('setuptools'),
+ *wheels,
)
run_command(cmd)

View file

@ -17,7 +17,7 @@ URL: https://www.python.org/
%global prerel a7
%global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}}
Release: 2%{?dist}
Release: 3%{?dist}
License: Python-2.0.1
@ -302,7 +302,7 @@ BuildRequires: libappstream-glib
BuildRequires: %{python_wheel_pkg_prefix}-pip-wheel >= 23.1.2
%if %{with tests}
BuildRequires: %{python_wheel_pkg_prefix}-setuptools-wheel
BuildRequires: %{python_wheel_pkg_prefix}-wheel-wheel
BuildRequires: (%{python_wheel_pkg_prefix}-wheel-wheel if %{python_wheel_pkg_prefix}-setuptools-wheel < 71)
%endif
%endif
@ -378,6 +378,20 @@ Patch456: 00456-find-the-correct-group-name-in-test_group_no_follow_symlinks.pat
# See also: https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
Patch459: 00459-apply-intel-control-flow-technology-for-x86-64.patch
# 00460 # f876c748b89770cfee4148c3dd3acbc3dd527eb6
# gh-132415: Update vendored setuptools in ``Lib/test/wheeldata``
#
# (actual changes in .whl files removed to make this patch smaller)
#
# gh-127906: Add missing sys import to test_cppext
Patch460: 00460-gh-132415-update-vendored-setuptools-in-lib-test-wheeldata.patch
# 00461 # 920175020b21c0aff5edcc4c28d688b5061f591c
# Downstream only: Install wheel in test venvs when setuptools < 71
#
# This can be removed when Fedora 41 goes EOL (or updates setuptools).
Patch461: 00461-downstream-only-install-wheel-in-test-venvs-when-setuptools-71.patch
# (New patches go here ^^^)
#
# When adding new patches to "python" and "python3" in Fedora, EL, etc.,
@ -635,7 +649,7 @@ Requires: %{pkgname}-libs%{?_isa} = %{version}-%{release}
%if %{with rpmwheels}
Requires: %{python_wheel_pkg_prefix}-setuptools-wheel
Requires: %{python_wheel_pkg_prefix}-wheel-wheel
Requires: (%{python_wheel_pkg_prefix}-wheel-wheel if %{python_wheel_pkg_prefix}-setuptools-wheel < 71)
%else
Provides: bundled(python3dist(setuptools)) = %{setuptools_version}
%setuptools_bundled_provides
@ -700,7 +714,7 @@ Summary: Free Threading (PEP 703) version of the Python runtime
%if %{with rpmwheels}
Requires: %{python_wheel_pkg_prefix}-pip-wheel >= 23.1.2
Requires: %{python_wheel_pkg_prefix}-setuptools-wheel
Requires: %{python_wheel_pkg_prefix}-wheel-wheel
Requires: (%{python_wheel_pkg_prefix}-wheel-wheel if %{python_wheel_pkg_prefix}-setuptools-wheel < 71)
License: %{libs_license}
%else
Provides: bundled(python3dist(pip)) = %{pip_version}
@ -1726,6 +1740,9 @@ CheckPython freethreading
# ======================================================
%changelog
* Mon May 05 2025 Miro Hrončok <mhroncok@redhat.com> - 3.14.0~a7-3
- Drop requirement on python-wheel-wheel with setuptools >= 71
* Tue Apr 22 2025 Charalampos Stratakis <cstratak@redhat.com> - 3.14.0~a7-2
- Apply Intel's CET for mitigation against control-flow hijacking attacks