@@ -317,21 +317,8 @@ def configure_wasi_python(context, working_dir):
317317
318318 wasi_build_dir = working_dir .relative_to (CHECKOUT )
319319
320- python_build_dir = BUILD_DIR / "build"
321- lib_dirs = list (python_build_dir .glob ("lib.*" ))
322- assert len (lib_dirs ) == 1 , (
323- f"Expected a single lib.* directory in { python_build_dir } "
324- )
325- lib_dir = os .fsdecode (lib_dirs [0 ])
326- python_version = lib_dir .rpartition ("-" )[- 1 ]
327- sysconfig_data_dir = (
328- f"{ wasi_build_dir } /build/lib.wasi-wasm32-{ python_version } "
329- )
330-
331- # Use PYTHONPATH to include sysconfig data which must be anchored to the
332- # WASI guest's `/` directory.
333320 args = {
334- "PYTHONPATH " : f"/{ sysconfig_data_dir } " ,
321+ "ARGV0 " : f"/{ wasi_build_dir } /python.wasm " ,
335322 "PYTHON_WASM" : working_dir / "python.wasm" ,
336323 }
337324 # Check dynamically for wasmtime in case it was specified manually via
@@ -421,8 +408,8 @@ def main():
421408 default_host_triple = config ["targets" ]["host-triple" ]
422409 default_host_runner = (
423410 f"{ WASMTIME_HOST_RUNNER_VAR } run "
424- # For setting PYTHONPATH to the sysconfig data directory.
425- "--env PYTHONPATH={PYTHONPATH } "
411+ # Set argv0 so that getpath.py can auto-discover the sysconfig data directory
412+ "--argv0 {ARGV0 } "
426413 # Map the checkout to / to load the stdlib from /Lib.
427414 f"--dir { os .fsdecode (CHECKOUT )} ::/ "
428415 # Flags involving --optimize, --codegen, --debug, --wasm, and --wasi can be kept
0 commit comments