From 0bea6ee6f313c82ea42d54db2ef09ecfb57a98e5 Mon Sep 17 00:00:00 2001 From: Naveen M K Date: Wed, 8 Nov 2023 23:40:56 +0530 Subject: [PATCH] python: update --- ...g-make-_sysconfigdata.py-relocatable.patch | 26 +++++++++++ ...-add-a-test-to-check-if-sysconfig-re.patch | 46 +++++++++++++++++++ mingw-w64-python/PKGBUILD | 14 ++++-- 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 mingw-w64-python/0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch create mode 100644 mingw-w64-python/0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch diff --git a/mingw-w64-python/0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch b/mingw-w64-python/0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch new file mode 100644 index 0000000000..3f899f91e3 --- /dev/null +++ b/mingw-w64-python/0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch @@ -0,0 +1,26 @@ +From 9d633349ce916c151a8f077ea4ea8c0a1bcc7e75 Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Tue, 7 Nov 2023 22:44:38 +0530 +Subject: [PATCH 147/N] fixup! sysconfig: make _sysconfigdata.py relocatable + +Use `sys.base_prefix` for sysconfig relocation +Previously, we were using `sys.prefix` for relocation, which is +not right as it may change for virtualenvs. `sys.base_prefix` is +the right variable to use. +--- + Lib/sysconfig.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 8035d2e..f359835 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -542,7 +542,7 @@ def _generate_posix_vars(): + + for key in keys_to_replace: + value = build_time_vars[key] +- build_time_vars[key] = value.replace(prefix, sys.prefix) ++ build_time_vars[key] = value.replace(prefix, sys.base_prefix) + """ + + with open(destfile, 'w', encoding='utf8') as f: diff --git a/mingw-w64-python/0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch b/mingw-w64-python/0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch new file mode 100644 index 0000000000..47f60fa111 --- /dev/null +++ b/mingw-w64-python/0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch @@ -0,0 +1,46 @@ +From 9599c1cbffc8b1889f661b4da6463252e0722bed Mon Sep 17 00:00:00 2001 +From: Naveen M K +Date: Wed, 8 Nov 2023 19:44:22 +0530 +Subject: [PATCH 148/N] mingw_smoketests: add a test to check if sysconfig + returns correct values for `LIBDIR` + +--- + mingw_smoketests.py | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/mingw_smoketests.py b/mingw_smoketests.py +index ca1f652..4f81c68 100644 +--- a/mingw_smoketests.py ++++ b/mingw_smoketests.py +@@ -218,6 +218,9 @@ class Tests(unittest.TestCase): + import sysconfig + import platform + import importlib.machinery ++ import tempfile ++ import venv ++ import subprocess + self.assertEqual(sys.implementation.name, "cpython") + self.assertEqual(sys.platform, "win32") + self.assertTrue(sysconfig.get_platform().startswith("mingw")) +@@ -241,6 +244,21 @@ class Tests(unittest.TestCase): + self.assertEqual(platform.system(), "Windows") + self.assertTrue(isinstance(sys.api_version, int) and sys.api_version > 0) + ++ with tempfile.TemporaryDirectory() as tmp: ++ builder = venv.EnvBuilder() ++ builder.create(tmp) ++ # This will not work in in-tree build ++ if not sysconfig.is_python_build(): ++ op = subprocess.check_output( ++ [ ++ os.path.join(tmp, "bin", "python.exe"), ++ "-c", ++ "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))" ++ ], ++ cwd=tmp, ++ ) ++ self.assertTrue(op.decode().strip().startswith(sys.base_prefix)) ++ + def test_sys_getpath(self): + # everything sourced from getpath.py + import sys diff --git a/mingw-w64-python/PKGBUILD b/mingw-w64-python/PKGBUILD index beb39cdfec..59bd8f3e0d 100644 --- a/mingw-w64-python/PKGBUILD +++ b/mingw-w64-python/PKGBUILD @@ -22,7 +22,7 @@ else pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}${_pybasever}") fi pkgver=${_pybasever}.6 -pkgrel=1 +pkgrel=2 pkgdesc="A high-level scripting language (mingw-w64)" arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') @@ -193,7 +193,9 @@ source=("https://www.python.org/ftp/python/${pkgver%rc?}/Python-${pkgver}.tar.xz 0143-setup.py-don-t-prepend-the-system-library-directorie.patch 0144-Port-GetPythonImport-to-mingw.patch 0145-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch - 0146-Use-shared-instead-of-mdll.patch) + 0146-Use-shared-instead-of-mdll.patch + 0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch + 0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch) # Helper macros to help make tasks easier # apply_patch_with_msg() { @@ -352,7 +354,9 @@ prepare() { 0143-setup.py-don-t-prepend-the-system-library-directorie.patch \ 0144-Port-GetPythonImport-to-mingw.patch \ 0145-LoadLibraryExW-make-sure-to-only-use-backslashes-for.patch \ - 0146-Use-shared-instead-of-mdll.patch + 0146-Use-shared-instead-of-mdll.patch \ + 0147-fixup-sysconfig-make-_sysconfigdata.py-relocatable.patch \ + 0148-mingw_smoketests-add-a-test-to-check-if-sysconfig-re.patch autoreconf -vfi } @@ -599,4 +603,6 @@ sha256sums=('0fab78fa7f133f4f38210c6260d90d7c0d5c7198446419ce057ec7ac2e6f5f38' 'c42adc1061b81f77f7a3dfabf455cc1894e82f6b65b35468621ba27d471ae21e' '06704b6f161aa2607b1d3f7183fbc9f57e7b3f1b3a1ad97abcf7ef007c952029' 'ab6d51169505a411c5a08d8f836b2bc96952f1bcc0ba72da121f1f174775138d' - '4ef06fe46863bf8d5b82ea936bb1819e80cc00b22fcd4bdc5e933071399c148c') + '4ef06fe46863bf8d5b82ea936bb1819e80cc00b22fcd4bdc5e933071399c148c' + '21852e0a64c8867f709de718cf56a6a5b780b4c802c0684ddfcdacff366c1088' + '3a30bac3621d37284abd9b4af37030be30457a44cf4e80b7e2c97ce91e1b2003')