From 0c82a4ac9fe539d40f5ab64fdcb297e61b448ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 26 May 2023 15:54:59 +0200 Subject: [PATCH 1/3] Use wheels from RPMs, at least on Fedora 39+ --- ...-get_config_var-wheel_pkg_dir-if-set.patch | 58 +++++++++++++++++++ python3.12.spec | 34 ++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 00401-tests-use-setuptools-wheel-from-sysconfig-get_config_var-wheel_pkg_dir-if-set.patch diff --git a/00401-tests-use-setuptools-wheel-from-sysconfig-get_config_var-wheel_pkg_dir-if-set.patch b/00401-tests-use-setuptools-wheel-from-sysconfig-get_config_var-wheel_pkg_dir-if-set.patch new file mode 100644 index 0000000..654b7e8 --- /dev/null +++ b/00401-tests-use-setuptools-wheel-from-sysconfig-get_config_var-wheel_pkg_dir-if-set.patch @@ -0,0 +1,58 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Mon, 29 May 2023 15:51:16 +0200 +Subject: [PATCH] 00401: Tests: Use setuptools+wheel from + sysconfig.get_config_var('WHEEL_PKG_DIR') if set + +Proposed upstream https://github.com/python/cpython/pull/105056 +--- + Lib/test/support/__init__.py | 21 +++++++++++++++++++++ + Lib/test/test_cppext.py | 4 ++-- + 2 files changed, 23 insertions(+), 2 deletions(-) + +diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py +index d555c53fee..adc3f5901d 100644 +--- a/Lib/test/support/__init__.py ++++ b/Lib/test/support/__init__.py +@@ -2398,5 +2398,26 @@ def adjust_int_max_str_digits(max_digits): + finally: + sys.set_int_max_str_digits(current) + ++ ++@functools.cache ++def _findwheel(pkgname): ++ """Try to find a wheel with the package specified as pkgname. ++ ++ If set, the wheels are searched for in WHEEL_PKG_DIR (see ensurepip). ++ Otherwise, they are searched for in the test directory. ++ """ ++ wheel_dir = sysconfig.get_config_var('WHEEL_PKG_DIR') or TEST_HOME_DIR ++ filenames = os.listdir(wheel_dir) ++ filenames = sorted(filenames) # sort this like ensurepip does it ++ for filename in filenames: ++ # filename is like 'pip-21.2.4-py3-none-any.whl' ++ if not filename.endswith(".whl"): ++ continue ++ prefix = pkgname + '-' ++ if filename.startswith(prefix): ++ return os.path.join(wheel_dir, filename) ++ raise FileNotFoundError(f"No wheel for {pkgname} found in {wheel_dir}") ++ ++ + #For recursion tests, easily exceeds default recursion limit + EXCEEDS_RECURSION_LIMIT = 5000 +diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext.py +index 4fb62d87e8..d124220dac 100644 +--- a/Lib/test/test_cppext.py ++++ b/Lib/test/test_cppext.py +@@ -83,8 +83,8 @@ def run_cmd(operation, cmd): + + cmd = [python, '-X', 'dev', + '-m', 'pip', 'install', +- support.findfile('setuptools-67.6.1-py3-none-any.whl'), +- support.findfile('wheel-0.40.0-py3-none-any.whl')] ++ support._findwheel('setuptools'), ++ support._findwheel('wheel')] + run_cmd('Install build dependencies', cmd) + + # Build and install the C++ extension diff --git a/python3.12.spec b/python3.12.spec index c202746..f94d213 100644 --- a/python3.12.spec +++ b/python3.12.spec @@ -17,7 +17,7 @@ URL: https://www.python.org/ %global prerel b1 %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 1%{?dist} +Release: 2%{?dist} License: Python-2.0.1 @@ -60,13 +60,20 @@ License: Python-2.0.1 # python-pip is built with a wheel to get around the issue. %bcond_with bootstrap -# Whether to use RPM build wheels from the python-pip-wheel package +# Whether to use RPM build wheels from the python-{pip,setuptools,wheel}-wheel packages # Uses upstream bundled prebuilt wheels otherwise +# Only F39+ has a pip new enough to work with Python 3.12 +%if 0%{?fedora} >= 39 || 0%{?rhel} >= 10 +%bcond_without rpmwheels +%else %bcond_with rpmwheels +%endif # If the rpmwheels condition is disabled, we use the bundled wheel packages # from Python with the versions below. # This needs to be manually updated when we update Python. %global pip_version 23.1.2 +%global setuptools_version 67.6.1 +%global wheel_version 0.40.0 # Expensive optimizations (mainly, profile-guided optimizations) %bcond_without optimizations @@ -238,6 +245,10 @@ BuildRequires: /usr/sbin/ifconfig # Python 3.12 removed the deprecated imp module, # the first compatible version of pip is 23.1.2. 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 +%endif %endif %if %{without bootstrap} @@ -304,6 +315,12 @@ Patch371: 00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-g # fix stack overwrite on 32-bit in perf map test harness (#104811) Patch398: 00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch +# 00401 # 48310af24b090719553bf0e9c965d80524e0b40e +# Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set +# +# Proposed upstream https://github.com/python/cpython/pull/105056 +Patch401: 00401-tests-use-setuptools-wheel-from-sysconfig-get_config_var-wheel_pkg_dir-if-set.patch + # (New patches go here ^^^) # # When adding new patches to "python" and "python3" in Fedora, EL, etc., @@ -546,6 +563,14 @@ Summary: The self-test suite for the main python3 package Requires: %{pkgname} = %{version}-%{release} Requires: %{pkgname}-libs%{?_isa} = %{version}-%{release} +%if %{with rpmwheels} +Requires: %{python_wheel_pkg_prefix}-setuptools-wheel +Requires: %{python_wheel_pkg_prefix}-wheel-wheel +%else +Provides: bundled(python3dist(setuptools)) = %{setuptools_version} +Provides: bundled(python3dist(wheel)) = %{wheel_version} +%endif + %unversioned_obsoletes_of_python3_X_if_main test %description -n %{pkgname}-test @@ -600,6 +625,8 @@ The debug runtime additionally supports debug builds of C-API extensions %if %{with rpmwheels} rm Lib/ensurepip/_bundled/pip-%{pip_version}-py3-none-any.whl +rm Lib/test/setuptools-%{setuptools_version}-py3-none-any.whl +rm Lib/test/wheel-%{wheel_version}-py3-none-any.whl %endif # Remove all exe files to ensure we are not shipping prebuilt binaries @@ -1568,6 +1595,9 @@ CheckPython optimized # ====================================================== %changelog +* Mon May 29 2023 Miro Hrončok - 3.12.0~b1-2 +- Use wheels from RPMs, at least on Fedora 39+ + * Tue May 23 2023 Tomáš Hrnčiar - 3.12.0~b1-1 - Update to 3.12.0b1 From 6073e4f0062e4076028a803e3427a942009c0714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 30 May 2023 18:19:42 +0200 Subject: [PATCH 2/3] --without rpmwheels: Declare bundled() provides and a complex License tag --- python3.12.spec | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/python3.12.spec b/python3.12.spec index f94d213..65af7b7 100644 --- a/python3.12.spec +++ b/python3.12.spec @@ -74,6 +74,57 @@ License: Python-2.0.1 %global pip_version 23.1.2 %global setuptools_version 67.6.1 %global wheel_version 0.40.0 +# All of those also include a list of indirect bundled libs: +# pip +# $ %%{_rpmconfigdir}/pythonbundles.py <(unzip -p Lib/ensurepip/_bundled/pip-*.whl pip/_vendor/vendor.txt) +%global pip_bundled_provides %{expand: +Provides: bundled(python3dist(cachecontrol)) = 0.12.11 +Provides: bundled(python3dist(certifi)) = 2022.12.7 +Provides: bundled(python3dist(chardet)) = 5.1 +Provides: bundled(python3dist(colorama)) = 0.4.6 +Provides: bundled(python3dist(distlib)) = 0.3.6 +Provides: bundled(python3dist(distro)) = 1.8 +Provides: bundled(python3dist(idna)) = 3.4 +Provides: bundled(python3dist(msgpack)) = 1.0.5 +Provides: bundled(python3dist(packaging)) = 21.3 +Provides: bundled(python3dist(platformdirs)) = 3.2 +Provides: bundled(python3dist(pygments)) = 2.14 +Provides: bundled(python3dist(pyparsing)) = 3.0.9 +Provides: bundled(python3dist(pyproject-hooks)) = 1 +Provides: bundled(python3dist(requests)) = 2.28.2 +Provides: bundled(python3dist(resolvelib)) = 1.0.1 +Provides: bundled(python3dist(rich)) = 13.3.3 +Provides: bundled(python3dist(setuptools)) = 67.7.2 +Provides: bundled(python3dist(six)) = 1.16 +Provides: bundled(python3dist(tenacity)) = 8.2.2 +Provides: bundled(python3dist(tomli)) = 2.0.1 +Provides: bundled(python3dist(typing-extensions)) = 4.5 +Provides: bundled(python3dist(urllib3)) = 1.26.15 +Provides: bundled(python3dist(webencodings)) = 0.5.1 +} +# setuptools +# vendor.txt files not in .whl +# $ %%{_rpmconfigdir}/pythonbundles.py \ +# <(curl -L https://github.com/pypa/setuptools/raw/v%%{setuptools_version}/setuptools/_vendor/vendored.txt) \ +# <(curl -L https://github.com/pypa/setuptools/raw/v%%{setuptools_version}/pkg_resources/_vendor/vendored.txt) +%global setuptools_bundled_provides %{expand: +Provides: bundled(python3dist(importlib-metadata)) = 6 +Provides: bundled(python3dist(importlib-resources)) = 5.10.2 +Provides: bundled(python3dist(jaraco-text)) = 3.7 +Provides: bundled(python3dist(more-itertools)) = 8.8 +Provides: bundled(python3dist(ordered-set)) = 3.1.1 +Provides: bundled(python3dist(packaging)) = 23 +Provides: bundled(python3dist(platformdirs)) = 2.6.2 +Provides: bundled(python3dist(tomli)) = 2.0.1 +Provides: bundled(python3dist(typing-extensions)) = 4.0.1 +Provides: bundled(python3dist(typing-extensions)) = 4.4 +Provides: bundled(python3dist(zipp)) = 3.7 +} +# wheel +# $ %%{_rpmconfigdir}/pythonbundles.py <(unzip -p Lib/test/wheel-*.whl wheel/vendored/vendor.txt) +%global wheel_bundled_provides %{expand: +Provides: bundled(python3dist(packaging)) = 23 +} # Expensive optimizations (mainly, profile-guided optimizations) %bcond_without optimizations @@ -445,6 +496,9 @@ Summary: Python runtime libraries Requires: %{python_wheel_pkg_prefix}-pip-wheel >= 23.1.2 %else Provides: bundled(python3dist(pip)) = %{pip_version} +%pip_bundled_provides +# License manually combined form Python + pip +License: Python-2.0.1 AND MIT AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND LGPL-2.1-only AND MPL-2.0 AND (Apache-2.0 OR BSD-2-Clause) %endif %unversioned_obsoletes_of_python3_X_if_main libs @@ -568,7 +622,11 @@ Requires: %{python_wheel_pkg_prefix}-setuptools-wheel Requires: %{python_wheel_pkg_prefix}-wheel-wheel %else Provides: bundled(python3dist(setuptools)) = %{setuptools_version} +%setuptools_bundled_provides Provides: bundled(python3dist(wheel)) = %{wheel_version} +%wheel_bundled_provides +# License manually combined from Python + setuptools + wheel +License: Python-2.0.1 AND MIT AND Apache-2.0 AND (Apache-2.0 OR BSD-2-Clause) %endif %unversioned_obsoletes_of_python3_X_if_main test @@ -623,6 +681,14 @@ The debug runtime additionally supports debug builds of C-API extensions %gpgverify -k2 -s1 -d0 %autosetup -S git_am -n Python-%{upstream_version} +# Verify the second level of bundled provides is up to date +# Arguably this should be done in %%check, but %%prep has a faster feedback loop +# setuptools.whl does not contain the vendored.txt files +if [ -f %{_rpmconfigdir}/pythonbundles.py ]; then + %{_rpmconfigdir}/pythonbundles.py <(unzip -p Lib/ensurepip/_bundled/pip-*.whl pip/_vendor/vendor.txt) --compare-with '%pip_bundled_provides' + %{_rpmconfigdir}/pythonbundles.py <(unzip -p Lib/test/wheel-*.whl wheel/vendored/vendor.txt) --compare-with '%wheel_bundled_provides' +fi + %if %{with rpmwheels} rm Lib/ensurepip/_bundled/pip-%{pip_version}-py3-none-any.whl rm Lib/test/setuptools-%{setuptools_version}-py3-none-any.whl @@ -1597,6 +1663,7 @@ CheckPython optimized %changelog * Mon May 29 2023 Miro Hrončok - 3.12.0~b1-2 - Use wheels from RPMs, at least on Fedora 39+ +- On older Fedora releases, declare bundled() provides and a complex License tag * Tue May 23 2023 Tomáš Hrnčiar - 3.12.0~b1-1 - Update to 3.12.0b1 From 036d63f211b141771562cc8312482d9fcb28bb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Wed, 7 Jun 2023 08:39:56 +0200 Subject: [PATCH 3/3] Update to 3.12.0b2 --- ...or-the-main-thread-gh-28549-gh-28589.patch | 10 ++--- ...rf-map-test-harness-gh-104811-104823.patch | 43 ------------------- python3.12.spec | 13 +++--- sources | 4 +- 4 files changed, 13 insertions(+), 57 deletions(-) delete mode 100644 00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch diff --git a/00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch b/00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch index 1120d00..b5b3461 100644 --- a/00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch +++ b/00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch @@ -16,10 +16,10 @@ https://github.com/GrahamDumpleton/mod_wsgi/issues/730 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py -index 97165264b3..7667ed37e8 100644 +index 9e4972ecb6..6f081d8f38 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py -@@ -1015,39 +1015,6 @@ def noop(): pass +@@ -987,39 +987,6 @@ def noop(): pass threading.Thread(target=noop).start() # Thread.join() is not called @@ -56,9 +56,9 @@ index 97165264b3..7667ed37e8 100644 - self.assertEqual(out, b'') - self.assertEqual(err, b'') - - - class ThreadJoinOnShutdown(BaseTestCase): - + def test_start_new_thread_at_exit(self): + code = """if 1: + import atexit diff --git a/Lib/threading.py b/Lib/threading.py index df273870fa..eba297776d 100644 --- a/Lib/threading.py diff --git a/00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch b/00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch deleted file mode 100644 index a86d646..0000000 --- a/00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Carl Meyer -Date: Tue, 23 May 2023 16:04:31 -0600 -Subject: [PATCH] 00398: fix stack overwrite on 32-bit in perf map test harness - (#104811) - ---- - Modules/_testinternalcapi.c | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c -index b91f7b620f..8267dbf677 100644 ---- a/Modules/_testinternalcapi.c -+++ b/Modules/_testinternalcapi.c -@@ -762,19 +762,24 @@ clear_extension(PyObject *self, PyObject *args) - static PyObject * - write_perf_map_entry(PyObject *self, PyObject *args) - { -+ PyObject *code_addr_v; - const void *code_addr; - unsigned int code_size; - const char *entry_name; - -- if (!PyArg_ParseTuple(args, "KIs", &code_addr, &code_size, &entry_name)) -+ if (!PyArg_ParseTuple(args, "OIs", &code_addr_v, &code_size, &entry_name)) - return NULL; -+ code_addr = PyLong_AsVoidPtr(code_addr_v); -+ if (code_addr == NULL) { -+ return NULL; -+ } - - int ret = PyUnstable_WritePerfMapEntry(code_addr, code_size, entry_name); -- if (ret == -1) { -- PyErr_SetString(PyExc_OSError, "Failed to write performance map entry"); -+ if (ret < 0) { -+ PyErr_SetFromErrno(PyExc_OSError); - return NULL; - } -- return Py_BuildValue("i", ret); -+ return PyLong_FromLong(ret); - } - - static PyObject * diff --git a/python3.12.spec b/python3.12.spec index 65af7b7..c78d8b5 100644 --- a/python3.12.spec +++ b/python3.12.spec @@ -14,10 +14,10 @@ URL: https://www.python.org/ # WARNING When rebasing to a new Python version, # remember to update the python3-docs package as well %global general_version %{pybasever}.0 -%global prerel b1 +%global prerel b2 %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 2%{?dist} +Release: 1%{?dist} License: Python-2.0.1 @@ -351,7 +351,7 @@ Source11: idle3.appdata.xml # pypa/distutils integration: https://github.com/pypa/distutils/pull/70 Patch251: 00251-change-user-install-location.patch -# 00371 # 1fc313929648e9b543542de09f59c55e175ac45a +# 00371 # d917a50238c94c652bc30ae9061d65f60cc8accd # Revert "bpo-1596321: Fix threading._shutdown() for the main thread (GH-28549) (GH-28589)" # # This reverts commit 38c67738c64304928c68d5c2bd78bbb01d979b94. It @@ -362,10 +362,6 @@ Patch251: 00251-change-user-install-location.patch # https://github.com/GrahamDumpleton/mod_wsgi/issues/730 Patch371: 00371-revert-bpo-1596321-fix-threading-_shutdown-for-the-main-thread-gh-28549-gh-28589.patch -# 00398 # 3a2e73c1542a7204628783cef2186e4b8a385f79 -# fix stack overwrite on 32-bit in perf map test harness (#104811) -Patch398: 00398-fix-stack-overwrite-on-32-bit-in-perf-map-test-harness-gh-104811-104823.patch - # 00401 # 48310af24b090719553bf0e9c965d80524e0b40e # Tests: Use setuptools+wheel from sysconfig.get_config_var('WHEEL_PKG_DIR') if set # @@ -1661,6 +1657,9 @@ CheckPython optimized # ====================================================== %changelog +* Wed Jun 07 2023 Tomáš Hrnčiar - 3.12.0~b2-1 +- Update to 3.12.0b2 + * Mon May 29 2023 Miro Hrončok - 3.12.0~b1-2 - Use wheels from RPMs, at least on Fedora 39+ - On older Fedora releases, declare bundled() provides and a complex License tag diff --git a/sources b/sources index df6fbfc..60ad9b4 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (Python-3.12.0b1.tar.xz) = 7d6d009f765ba48ef48e6b25cb1f043ba66979d66cb9141452862e84ae954611361d24178cce628d1892b75d306370a56fcb30a7c1715b0eedcfef5610f3e1ae -SHA512 (Python-3.12.0b1.tar.xz.asc) = cea449f05ae66c28aeb4ffd99b5748ba4c09bfb2a6889a771744ea81ca2afc2420648d4ca92592d32ddb26660804e73912e6fb8d906674e9e1895ba613904b26 +SHA512 (Python-3.12.0b2.tar.xz) = 9bfac70f2ccc1f6798bc63a55d92f0b162e3a9077624a2e37448002ea310cb7b1da64ad2aceda795b45de91f60eb4d95dde85984900e54906d814625b42143b5 +SHA512 (Python-3.12.0b2.tar.xz.asc) = 22a1f2c3335bc428cfee0ce2e081aeed24474d3cd877fac1cc4cf92b4a2bee70f85aed0068a71600cddef9c8b46bbde257a92c57bd494ad820c0686ab7c8c0f0