https://github.com/python/cpython/commit/2f1a9f2ed498b3cb2dd5f4616bf3a07fd1ad074c
commit: 2f1a9f2ed498b3cb2dd5f4616bf3a07fd1ad074c
branch: main
author: Brett Cannon <[email protected]>
committer: brettcannon <[email protected]>
date: 2025-07-30T11:46:24-07:00
summary:
GH-137243: Have `Tools/wasm/wasi` detect WASI SDK installs in `/opt` when the
release tarball is extracted (GH-137244)
files:
A Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst
M Tools/wasm/wasi/__main__.py
diff --git
a/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst
b/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst
new file mode 100644
index 00000000000000..c9c6c2ca287efd
--- /dev/null
+++
b/Misc/NEWS.d/next/Tools-Demos/2025-07-30-10-28-35.gh-issue-137243.NkdUqH.rst
@@ -0,0 +1,2 @@
+Have Tools/wasm/wasi detect a WASI SDK install in /opt when it was directly
+extracted from a release tarball.
diff --git a/Tools/wasm/wasi/__main__.py b/Tools/wasm/wasi/__main__.py
index f3c97ff3fd11a0..d2461c387fab54 100644
--- a/Tools/wasm/wasi/__main__.py
+++ b/Tools/wasm/wasi/__main__.py
@@ -26,6 +26,8 @@
LOCAL_SETUP_MARKER = ("# Generated by Tools/wasm/wasi .\n"
"# Required to statically build extension
modules.").encode("utf-8")
+WASI_SDK_VERSION = 24
+
WASMTIME_VAR_NAME = "WASMTIME"
WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}"
@@ -173,10 +175,22 @@ def make_build_python(context, working_dir):
def find_wasi_sdk():
- """Find the path to wasi-sdk."""
+ """Find the path to the WASI SDK."""
if wasi_sdk_path := os.environ.get("WASI_SDK_PATH"):
return pathlib.Path(wasi_sdk_path)
- elif (default_path := pathlib.Path("/opt/wasi-sdk")).exists():
+
+ opt_path = pathlib.Path("/opt")
+ # WASI SDK versions have a ``.0`` suffix, but it's a constant; the WASI
SDK team
+ # has said they don't plan to ever do a point release and all of their Git
tags
+ # lack the ``.0`` suffix.
+ # Starting with WASI SDK 23, the tarballs went from containing a directory
named
+ # ``wasi-sdk-{WASI_SDK_VERSION}.0`` to e.g.
+ # ``wasi-sdk-{WASI_SDK_VERSION}.0-x86_64-linux``.
+ potential_sdks = [path for path in
opt_path.glob(f"wasi-sdk-{WASI_SDK_VERSION}.0*")
+ if path.is_dir()]
+ if len(potential_sdks) == 1:
+ return potential_sdks[0]
+ elif (default_path := opt_path / "wasi-sdk").is_dir():
return default_path
@@ -306,6 +320,8 @@ def clean_contents(context):
def main():
+ default_host_triple = "wasm32-wasip1"
+ default_wasi_sdk = find_wasi_sdk()
default_host_runner = (f"{WASMTIME_HOST_RUNNER_VAR} run "
# Make sure the stack size will work for a pydebug
# build.
@@ -349,17 +365,17 @@ def main():
for subcommand in build, configure_host:
subcommand.add_argument("--wasi-sdk", type=pathlib.Path,
dest="wasi_sdk_path",
- default=find_wasi_sdk(),
- help="Path to wasi-sdk; defaults to "
- "$WASI_SDK_PATH or /opt/wasi-sdk")
+ default=default_wasi_sdk,
+ help=f"Path to the WASI SDK; defaults to
{default_wasi_sdk}")
subcommand.add_argument("--host-runner", action="store",
default=default_host_runner, dest="host_runner",
- help="Command template for running the WASI host "
- "(default designed for wasmtime 14 or newer: "
- f"`{default_host_runner}`)")
+ help="Command template for running the WASI host;
defaults to "
+ f"`{default_host_runner}`")
for subcommand in build, configure_host, make_host:
- subcommand.add_argument("--host-triple", action="store",
default="wasm32-wasip1",
- help="The target triple for the WASI host build")
+ subcommand.add_argument("--host-triple", action="store",
+ default=default_host_triple,
+ help="The target triple for the WASI host
build; "
+ f"defaults to {default_host_triple}")
context = parser.parse_args()
context.init_dir = pathlib.Path().absolute()
_______________________________________________
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]