Backport upstream fixes for Python 3.12
These are test-only (and thus build-only) except for a different fallback value for `setuptools.__version__`. Fixes: RHBZ#2222249
This commit is contained in:
parent
cae1565586
commit
adb9b68bd6
133
adjust-for-py3.12.patch
Normal file
133
adjust-for-py3.12.patch
Normal file
@ -0,0 +1,133 @@
|
||||
# This patch combines two upstream fixes (mainly for tests), adapting to
|
||||
# changes in Python 3.12:
|
||||
# - Python 3.12 raises a warning if tarfile filter is not set for extractall.
|
||||
# Tests do this, and fail on this warning.
|
||||
# Set a "fully trusted" filter. (The tests create the archive, so it is
|
||||
# trusted.)
|
||||
# - https://github.com/pypa/setuptools/pull/3917
|
||||
# - Python 3.12 venv no longer installs setuptools and wheel into new virtual
|
||||
# environments. Adjust tests that assumed the old behaviour.
|
||||
# Also, setting setuptools.__version__ assumed setuptools is installed.
|
||||
# Set a valid dummy value if that's not the case.
|
||||
# - https://github.com/pypa/setuptools/pull/3915
|
||||
|
||||
From 13887c8defa8f2042a5824da4fa049461e3718ac Mon Sep 17 00:00:00 2001
|
||||
From: Steve Kowalik <steven@wedontsleep.org>
|
||||
Date: Wed, 3 May 2023 12:02:19 +1000
|
||||
Subject: [PATCH] tests: Add extraction_filter for tarfile
|
||||
|
||||
Python 3.12, and earlier via security backports now issue an
|
||||
DeprecationWarning when calling tarfile.extractall without an extraction
|
||||
filter set. Since the only place we've called extractall is literally
|
||||
right after we've created the archive, use a fully trusted filter. This
|
||||
can be replaced with a filter argument to extractall in future.
|
||||
---
|
||||
setuptools/tests/test_easy_install.py | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
|
||||
index 0ee9bea909..709964b3ac 100644
|
||||
--- a/setuptools/tests/test_easy_install.py
|
||||
+++ b/setuptools/tests/test_easy_install.py
|
||||
@@ -697,6 +697,7 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg):
|
||||
foobar_1_dir = os.path.join(temp_dir, 'foo.bar-0.1')
|
||||
os.mkdir(foobar_1_dir)
|
||||
with tarfile.open(foobar_1_archive) as tf:
|
||||
+ tf.extraction_filter = (lambda member, path: member)
|
||||
tf.extractall(foobar_1_dir)
|
||||
sys.path.insert(1, foobar_1_dir)
|
||||
|
||||
|
||||
From 1bef1e2e793ca59828d7911f702ce05c098c0a74 Mon Sep 17 00:00:00 2001
|
||||
From: Anderson Bravalheri <andersonbravalheri@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 12:20:33 +0100
|
||||
Subject: [PATCH 1/3] Adequate venv fixtures to the latest change in virtualenv
|
||||
|
||||
Since version v20.23.0, `virtualenv` will no longer include `wheel` and
|
||||
`setuptools` in the created folders.
|
||||
|
||||
Some tests in the setuptools test suite assume that these packages are
|
||||
always present. So we need to adequate these tests.
|
||||
---
|
||||
setuptools/tests/fixtures.py | 4 +++-
|
||||
setuptools/tests/test_virtualenv.py | 4 ++--
|
||||
2 files changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py
|
||||
index 25ab49fd22..f1cfc66c81 100644
|
||||
--- a/setuptools/tests/fixtures.py
|
||||
+++ b/setuptools/tests/fixtures.py
|
||||
@@ -105,6 +105,8 @@ def venv(tmp_path, setuptools_wheel):
|
||||
"""Virtual env with the version of setuptools under test installed"""
|
||||
env = environment.VirtualEnv()
|
||||
env.root = path.Path(tmp_path / 'venv')
|
||||
+ env.create_opts = ['--no-setuptools', '--wheel=bundle']
|
||||
+ # TODO: Use `--no-wheel` when setuptools implements its own bdist_wheel
|
||||
env.req = str(setuptools_wheel)
|
||||
# In some environments (eg. downstream distro packaging),
|
||||
# where tox isn't used to run tests and PYTHONPATH is set to point to
|
||||
@@ -125,7 +127,7 @@ def venv_without_setuptools(tmp_path):
|
||||
"""Virtual env without any version of setuptools installed"""
|
||||
env = environment.VirtualEnv()
|
||||
env.root = path.Path(tmp_path / 'venv_without_setuptools')
|
||||
- env.create_opts = ['--no-setuptools']
|
||||
+ env.create_opts = ['--no-setuptools', '--no-wheel']
|
||||
env.ensure_env()
|
||||
return env
|
||||
|
||||
diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py
|
||||
index acfe04e9dd..b17be9ef2b 100644
|
||||
--- a/setuptools/tests/test_virtualenv.py
|
||||
+++ b/setuptools/tests/test_virtualenv.py
|
||||
@@ -174,8 +174,8 @@ def sdist(distname, version):
|
||||
|
||||
|
||||
def test_test_command_install_requirements(venv, tmpdir, tmpdir_cwd):
|
||||
- # Ensure pip/wheel packages are installed.
|
||||
- venv.run(["python", "-c", "__import__('pkg_resources').require(['pip', 'wheel'])"])
|
||||
+ # Ensure pip is installed.
|
||||
+ venv.run(["python", "-c", "import pip"])
|
||||
# disable index URL so bits and bobs aren't requested from PyPI
|
||||
with contexts.environment(PYTHONPATH=None, PIP_NO_INDEX="1"):
|
||||
_check_test_command_install_requirements(venv, tmpdir)
|
||||
|
||||
From 70ed7894801a308d93b1d155b30ac58d8ef0accd Mon Sep 17 00:00:00 2001
|
||||
From: Anderson Bravalheri <andersonbravalheri@gmail.com>
|
||||
Date: Tue, 2 May 2023 17:16:33 +0100
|
||||
Subject: [PATCH 2/3] Add news fragment
|
||||
|
||||
---
|
||||
changelog.d/3915.misc.rst | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
create mode 100644 changelog.d/3915.misc.rst
|
||||
|
||||
diff --git a/changelog.d/3915.misc.rst b/changelog.d/3915.misc.rst
|
||||
new file mode 100644
|
||||
index 0000000000..cd962b2c6e
|
||||
--- /dev/null
|
||||
+++ b/changelog.d/3915.misc.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Adequate tests to the latest changes in ``virtualenv`` for Python 3.12.
|
||||
|
||||
From 3f172826492e99470db75a74cdaa5494ec3e932c Mon Sep 17 00:00:00 2001
|
||||
From: Anderson Bravalheri <andersonbravalheri@gmail.com>
|
||||
Date: Thu, 27 Apr 2023 16:30:41 +0100
|
||||
Subject: [PATCH 3/3] Attempt to use a valid PEP 440 version fallback
|
||||
|
||||
---
|
||||
setuptools/version.py | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/setuptools/version.py b/setuptools/version.py
|
||||
index 75b2a14959..ec253c4144 100644
|
||||
--- a/setuptools/version.py
|
||||
+++ b/setuptools/version.py
|
||||
@@ -1,6 +1,6 @@
|
||||
from ._importlib import metadata
|
||||
|
||||
try:
|
||||
- __version__ = metadata.version('setuptools')
|
||||
+ __version__ = metadata.version('setuptools') or '0.dev0+unknown'
|
||||
except Exception:
|
||||
- __version__ = 'unknown'
|
||||
+ __version__ = '0.dev0+unknown'
|
@ -45,6 +45,20 @@ Patch: Remove-optional-or-unpackaged-test-deps.patch
|
||||
# adjust it, but only when $RPM_BUILD_ROOT is set
|
||||
Patch: Adjust-the-setup.py-install-deprecation-message.patch
|
||||
|
||||
# This patch combines two upstream fixes (mainly for tests), adapting to
|
||||
# changes in Python 3.12:
|
||||
# - Python 3.12 raises a warning if tarfile filter is not set for extractall.
|
||||
# Tests do this, and fail on this warning.
|
||||
# Set a "fully trusted" filter. (The tests create the archive, so it is
|
||||
# trusted.)
|
||||
# - https://github.com/pypa/setuptools/pull/3917
|
||||
# - Python 3.12 venv no longer installs setuptools and wheel into new virtual
|
||||
# environments. Adjust tests that assumed the old behaviour.
|
||||
# Also, setting setuptools.__version__ assumed setuptools is installed.
|
||||
# Set a valid dummy value if that's not the case.
|
||||
# - https://github.com/pypa/setuptools/pull/3915
|
||||
Patch: adjust-for-py3.12.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: python%{python3_pkgversion}-devel
|
||||
|
Loading…
Reference in New Issue
Block a user