Skip to content

Commit

Permalink
pythonGH-114013: fix setting HOSTRUNNER for Tools/wasm/wasi.py
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed Jan 16, 2024
1 parent 5094690 commit d25a07f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix ``Tools/wasm/wasi.py`` to not include the path to ``python.wasm`` as
part of ``HOSTRUNNER``. The environment variable is meant to specify how to
run the WASI host only, having ``python.wasm`` and relevant flags appended
to the ``HOSTRUNNER``.
11 changes: 5 additions & 6 deletions Tools/wasm/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ def configure_wasi_python(context, working_dir):
env=updated_env(env_additions | wasi_sdk_env(context)),
quiet=context.quiet)

python_wasm = working_dir / "python.wasm"
exec_script = working_dir / "python.sh"
with exec_script.open("w", encoding="utf-8") as file:
file.write(f'#!/bin/sh\nexec {host_runner} "$@"\n')
file.write(f'#!/bin/sh\nexec {host_runner} {python_wasm} "$@"\n')
exec_script.chmod(0o755)
print(f"🏃‍♀️ Created {exec_script} ... ")
sys.stdout.flush()
Expand Down Expand Up @@ -272,9 +273,7 @@ def main():
# Map the checkout to / to load the stdlib from /Lib.
"--dir {HOST_DIR}::{GUEST_DIR} "
# Set PYTHONPATH to the sysconfig data.
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE} "
# Path to the WASM binary.
"{PYTHON_WASM}")
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}")

parser = argparse.ArgumentParser()
subcommands = parser.add_subparsers(dest="subcommand")
Expand Down Expand Up @@ -310,8 +309,8 @@ def main():
"$WASI_SDK_PATH or /opt/wasi-sdk")
subcommand.add_argument("--host-runner", action="store",
default=default_host_runner, dest="host_runner",
help="Command template for running the WebAssembly "
"code (default meant for wasmtime 14 or newer: "
help="Command template for running the WASI host "
"(default designed for wasmtime 14 or newer: "
f"`{default_host_runner}`)")

context = parser.parse_args()
Expand Down

0 comments on commit d25a07f

Please sign in to comment.