From 0d68ee0eb06d68a82feb42ff64c9b0307a7cb5c9 Mon Sep 17 00:00:00 2001 From: Savannah Ostrowski Date: Fri, 27 Feb 2026 10:04:56 -0800 Subject: [PATCH 1/2] Pass executable to argv0 --- Platforms/WASI/__main__.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Platforms/WASI/__main__.py b/Platforms/WASI/__main__.py index 8302432fd2f106..471ac3297b2702 100644 --- a/Platforms/WASI/__main__.py +++ b/Platforms/WASI/__main__.py @@ -317,21 +317,8 @@ def configure_wasi_python(context, working_dir): wasi_build_dir = working_dir.relative_to(CHECKOUT) - python_build_dir = BUILD_DIR / "build" - 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]) - 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 = { - "PYTHONPATH": f"/{sysconfig_data_dir}", + "ARGV0": f"/{wasi_build_dir}/python.wasm", "PYTHON_WASM": working_dir / "python.wasm", } # Check dynamically for wasmtime in case it was specified manually via @@ -421,8 +408,8 @@ def main(): default_host_triple = config["targets"]["host-triple"] default_host_runner = ( f"{WASMTIME_HOST_RUNNER_VAR} run " - # For setting PYTHONPATH to the sysconfig data directory. - "--env PYTHONPATH={PYTHONPATH} " + # Set argv0 so that getpath.py can auto-discover the sysconfig data directory + "--argv0 {ARGV0} " # Map the checkout to / to load the stdlib from /Lib. f"--dir {os.fsdecode(CHECKOUT)}::/ " # Flags involving --optimize, --codegen, --debug, --wasm, and --wasi can be kept From acc0955ec3e9b3bbe296a1fa89f21eebc18bda62 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 27 Feb 2026 18:10:08 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Build/2026-02-27-18-10-02.gh-issue-144533.21fk9L.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2026-02-27-18-10-02.gh-issue-144533.21fk9L.rst diff --git a/Misc/NEWS.d/next/Build/2026-02-27-18-10-02.gh-issue-144533.21fk9L.rst b/Misc/NEWS.d/next/Build/2026-02-27-18-10-02.gh-issue-144533.21fk9L.rst new file mode 100644 index 00000000000000..d6e0201b90c550 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-02-27-18-10-02.gh-issue-144533.21fk9L.rst @@ -0,0 +1 @@ +Use wasmtime's ``--argv0`` to auto-discover sysconfig in WASI builds