https://github.com/python/cpython/commit/8f4bf1538d2d05d502417b0da6623727519ab945
commit: 8f4bf1538d2d05d502417b0da6623727519ab945
branch: 3.14
author: Brett Cannon <[email protected]>
committer: brettcannon <[email protected]>
date: 2025-05-22T22:07:21Z
summary:
[3.14] GH-131769: fix detecting a pydebug build of the build Python when
building for WASI (GH-133219)
files:
A Misc/NEWS.d/next/Build/2025-04-30-10-22-08.gh-issue-131769.H0oy5x.rst
M Tools/wasm/wasi.py
diff --git
a/Misc/NEWS.d/next/Build/2025-04-30-10-22-08.gh-issue-131769.H0oy5x.rst
b/Misc/NEWS.d/next/Build/2025-04-30-10-22-08.gh-issue-131769.H0oy5x.rst
new file mode 100644
index 00000000000000..834b0d9f7e145d
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2025-04-30-10-22-08.gh-issue-131769.H0oy5x.rst
@@ -0,0 +1 @@
+Fix detecting when the build Python in a cross-build is a pydebug build.
diff --git a/Tools/wasm/wasi.py b/Tools/wasm/wasi.py
index a742043e4be1d2..5f60f0ec469dd1 100644
--- a/Tools/wasm/wasi.py
+++ b/Tools/wasm/wasi.py
@@ -111,7 +111,7 @@ def call(command, *, quiet, **kwargs):
def build_platform():
"""The name of the build/host platform."""
- # Can also be found via `config.guess`.`
+ # Can also be found via `config.guess`.
return sysconfig.get_config_var("BUILD_GNU_TYPE")
@@ -127,6 +127,15 @@ def build_python_path():
return binary
+def build_python_is_pydebug():
+ """Find out if the build Python is a pydebug build."""
+ test = "import sys, test.support; sys.exit(test.support.Py_DEBUG)"
+ result = subprocess.run([build_python_path(), "-c", test],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ return bool(result.returncode)
+
+
@subdir(BUILD_DIR, clean_ok=True)
def configure_build_python(context, working_dir):
"""Configure the build/host Python."""
@@ -213,18 +222,15 @@ def configure_wasi_python(context, working_dir):
lib_dirs = list(python_build_dir.glob("lib.*"))
assert len(lib_dirs) == 1, f"Expected a single lib.* directory in
{python_build_dir}"
lib_dir = os.fsdecode(lib_dirs[0])
- pydebug = lib_dir.endswith("-pydebug")
- python_version = lib_dir.removesuffix("-pydebug").rpartition("-")[-1]
- sysconfig_data = f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
- if pydebug:
- sysconfig_data += "-pydebug"
+ python_version = lib_dir.rpartition("-")[-1]
+ sysconfig_data_dir =
f"{wasi_build_dir}/build/lib.wasi-wasm32-{python_version}"
# Use PYTHONPATH to include sysconfig data which must be anchored to the
# WASI guest's `/` directory.
args = {"GUEST_DIR": "/",
"HOST_DIR": CHECKOUT,
"ENV_VAR_NAME": "PYTHONPATH",
- "ENV_VAR_VALUE": f"/{sysconfig_data}",
+ "ENV_VAR_VALUE": f"/{sysconfig_data_dir}",
"PYTHON_WASM": working_dir / "python.wasm"}
# Check dynamically for wasmtime in case it was specified manually via
# `--host-runner`.
@@ -244,7 +250,7 @@ def configure_wasi_python(context, working_dir):
f"--host={context.host_triple}",
f"--build={build_platform()}",
f"--with-build-python={build_python}"]
- if pydebug:
+ if build_python_is_pydebug():
configure.append("--with-pydebug")
if context.args:
configure.extend(context.args)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]