From 5adad22d4dfd6ced89d588da6da3ff46d880fae4 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 4 Sep 2024 15:43:19 -0500 Subject: [PATCH 01/10] Attempt to download and build `mpdecimal` on Windows --- cpython-windows/build.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 9195e071..d5ec5eea 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -1409,6 +1409,12 @@ def build_cpython( setuptools_wheel = download_entry("setuptools", BUILD) pip_wheel = download_entry("pip", BUILD) + # CPython 3.13+ no longer uses a bundled version by default + if meets_python_minimum_version(python_version, "3.13"): + mpdecimal_archive = download_entry("mpdecimal", BUILD) + else: + mpdecimal_archive = None + if arch == "amd64": build_platform = "x64" build_directory = "amd64" @@ -1426,12 +1432,16 @@ def build_cpython( for a in ( python_archive, bzip2_archive, + mpdecimal_archive, openssl_archive, sqlite_archive, tk_bin_archive, xz_archive, zlib_archive, ): + if a is None: + continue + log("extracting %s to %s" % (a, td)) fs.append(e.submit(extract_tar_to_directory, a, td)) @@ -1599,11 +1609,6 @@ def build_cpython( if not meets_python_minimum_version(python_version, "3.12"): args.append("--include-distutils") - # CPython 3.13+ no longer uses a bundled libmpdec by default - # TODO(zanieb): We should use the system libmpdec as we do for Unix builds - if meets_python_minimum_version(python_version, "3.13"): - args.append("--with-system-libmpdec=no") - args.extend(["--include-idle", "--include-stable", "--include-tcltk"]) exec_and_log( From 44bfcbda416bd4ef75b9fd8d55002f021c756989 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 4 Sep 2024 18:17:44 -0500 Subject: [PATCH 02/10] Patch `mpdecimal` in `python.props` --- cpython-windows/build.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index d5ec5eea..1e62c943 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -352,6 +352,7 @@ def hack_props( xz_version = DOWNLOADS["xz"]["version"] zlib_version = DOWNLOADS["zlib"]["version"] tcltk_commit = DOWNLOADS["tk-windows-bin"]["git_commit"] + mpdecimal_version = DOWNLOADS["mpdecimal"]["version"] sqlite_path = td / ("sqlite-autoconf-%s" % sqlite_version) bzip2_path = td / ("bzip2-%s" % bzip2_version) @@ -359,6 +360,7 @@ def hack_props( tcltk_path = td / ("cpython-bin-deps-%s" % tcltk_commit) xz_path = td / ("xz-%s" % xz_version) zlib_path = td / ("zlib-%s" % zlib_version) + mpdecimal_path = td / ("mpdecimal-%s" % mpdecimal_version) openssl_root = td / "openssl" / arch openssl_libs_path = openssl_root / "lib" @@ -398,6 +400,9 @@ def hack_props( elif b"%s\\" % zlib_path + elif b"%s\\" % mpdecimal_path + lines.append(line) with python_props_path.open("wb") as fh: From c6a84e9346c9cdc144dd7794d32498f34ff3c06a Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 4 Sep 2024 19:41:03 -0500 Subject: [PATCH 03/10] Remove `_msi` from expected global extensions --- src/validation.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/validation.rs b/src/validation.rs index af94f7c6..cd0f93d6 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -759,7 +759,6 @@ const GLOBAL_EXTENSIONS_POSIX: &[&str] = &[ const GLOBAL_EXTENSIONS_LINUX_PRE_3_13: &[&str] = &["spwd"]; const GLOBAL_EXTENSIONS_WINDOWS: &[&str] = &[ - "_msi", "_overlapped", "_winapi", "_xxsubinterpreters", @@ -769,6 +768,8 @@ const GLOBAL_EXTENSIONS_WINDOWS: &[&str] = &[ "winsound", ]; +const GLOBAL_EXTENSIONS_WINDOWS_PRE_3_13 : &[&str] = &["_msi"]; + /// Extension modules not present in Windows static builds. const GLOBAL_EXTENSIONS_WINDOWS_NO_STATIC: &[&str] = &["_testinternalcapi", "_tkinter"]; @@ -1494,6 +1495,10 @@ fn validate_extension_modules( if is_windows { wanted.extend(GLOBAL_EXTENSIONS_WINDOWS); + if matches!(python_major_minor, "3.8" | "3.9" | "3.10" | "3.11" | "3.12") { + wanted.extend(GLOBAL_EXTENSIONS_WINDOWS_PRE_3_13); + } + if static_crt { for x in GLOBAL_EXTENSIONS_WINDOWS_NO_STATIC { wanted.remove(*x); From 1f13e0905565f765db4ad60590861e7f552e71dd Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 07:34:59 -0500 Subject: [PATCH 04/10] Allow `_msi` to be missing during `collect_python_build_artifacts` --- cpython-windows/build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 1e62c943..d6baaef2 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -65,7 +65,10 @@ "_lzma": { "ignore_additional_depends": {"$(OutDir)liblzma$(PyDebugExt).lib"}, }, - "_msi": {}, + "_msi": { + # Removed in 3.13. + "ignore_missing": True, + }, "_overlapped": {}, "_multiprocessing": {}, "_socket": {}, From daae3db3da3d1ec2c6249491954c3a55097dbc33 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 08:16:25 -0500 Subject: [PATCH 05/10] Add `_testclinic_limited` and `_testlimitedcapi` to ignored extensions --- cpython-windows/build.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index d6baaef2..74fc2422 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -1163,15 +1163,17 @@ def collect_python_build_artifacts( "_ctypes_test", "_testbuffer", "_testcapi", + "_testclinic_limited", "_testclinic", "_testconsole", "_testembed", "_testimportmultiple", "_testinternalcapi", - "_testsinglephase", + "_testlimitedcapi", "_testmultiphase", - "xxlimited", + "_testsinglephase", "xxlimited_35", + "xxlimited", } other_projects = {"pythoncore"} From 92c285387c78ab6c81c24e8ef8e89388199c3782 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 08:48:30 -0500 Subject: [PATCH 06/10] Add `python313.dll` to allowed libraries --- src/validation.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/validation.rs b/src/validation.rs index cd0f93d6..70c66ef2 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -125,6 +125,7 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[ "python310.dll", "python311.dll", "python312.dll", + "python313.dll", "sqlite3.dll", "tcl86t.dll", "tk86t.dll", From 057d5ced4e4c981dd4cafd7baa3a12a8bed264e6 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 08:52:30 -0500 Subject: [PATCH 07/10] Fix expected global extensions for 3.13 --- src/validation.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/validation.rs b/src/validation.rs index 70c66ef2..f3148a8e 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -728,9 +728,7 @@ const GLOBAL_EXTENSIONS_PYTHON_3_13: &[&str] = &[ "_interpqueues", "_interpreters", "_sha2", - "_suggestions", "_sysconfig", - "_testexternalinspection", "_tokenize", "_typing", "_zoneinfo", @@ -762,14 +760,13 @@ const GLOBAL_EXTENSIONS_LINUX_PRE_3_13: &[&str] = &["spwd"]; const GLOBAL_EXTENSIONS_WINDOWS: &[&str] = &[ "_overlapped", "_winapi", - "_xxsubinterpreters", "msvcrt", "nt", "winreg", "winsound", ]; -const GLOBAL_EXTENSIONS_WINDOWS_PRE_3_13 : &[&str] = &["_msi"]; +const GLOBAL_EXTENSIONS_WINDOWS_PRE_3_13: &[&str] = &["_msi"]; /// Extension modules not present in Windows static builds. const GLOBAL_EXTENSIONS_WINDOWS_NO_STATIC: &[&str] = &["_testinternalcapi", "_tkinter"]; From 8aac36b61b4f518dfae0807d50b887108242e861 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 08:52:55 -0500 Subject: [PATCH 08/10] Allow `_PyWarnings_Init` to be missing on 3.13 --- src/validation.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/validation.rs b/src/validation.rs index f3148a8e..c59b8070 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -1952,9 +1952,10 @@ fn validate_distribution( // Static distributions never export symbols. let wanted = if is_static { false - // For some strange reason _PyWarnings_Init is exported as part of the ABI. + // For some strange reason _PyWarnings_Init is exported as part of the ABI before + // Python 3.13. } else if name == "_warnings" { - true + matches!(python_major_minor, "3.9" | "3.10" | "3.11" | "3.12") // Windows dynamic doesn't export extension module init functions. } else if triple.contains("-windows-") { false From a1ee6c71b12df15dcf635ed510ecea58aa41e870 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 09:23:21 -0500 Subject: [PATCH 09/10] Include 3.8 in `_PyWarnings_Init` case --- src/validation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.rs b/src/validation.rs index c59b8070..665d9b72 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -1955,7 +1955,7 @@ fn validate_distribution( // For some strange reason _PyWarnings_Init is exported as part of the ABI before // Python 3.13. } else if name == "_warnings" { - matches!(python_major_minor, "3.9" | "3.10" | "3.11" | "3.12") + matches!(python_major_minor, "3.8" | "3.9" | "3.10" | "3.11" | "3.12") // Windows dynamic doesn't export extension module init functions. } else if triple.contains("-windows-") { false From 938f9ce738a29fb5c926be49da8da61a22b9ffd1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 5 Sep 2024 09:24:02 -0500 Subject: [PATCH 10/10] Include `_xxsubinterpreters` in 3.8 extensions --- src/validation.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/validation.rs b/src/validation.rs index 665d9b72..434c1a32 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -680,7 +680,13 @@ const GLOBAL_EXTENSIONS: &[&str] = &[ // We didn't build ctypes_test until 3.9. // We didn't build some test extensions until 3.9. -const GLOBAL_EXTENSIONS_PYTHON_3_8: &[&str] = &["audioop", "_sha256", "_sha512", "parser"]; +const GLOBAL_EXTENSIONS_PYTHON_3_8: &[&str] = &[ + "audioop", + "_sha256", + "_sha512", + "parser", + "_xxsubinterpreters", +]; const GLOBAL_EXTENSIONS_PYTHON_3_9: &[&str] = &[ "audioop", @@ -1952,7 +1958,7 @@ fn validate_distribution( // Static distributions never export symbols. let wanted = if is_static { false - // For some strange reason _PyWarnings_Init is exported as part of the ABI before + // For some strange reason _PyWarnings_Init is exported as part of the ABI before // Python 3.13. } else if name == "_warnings" { matches!(python_major_minor, "3.8" | "3.9" | "3.10" | "3.11" | "3.12")