1616import sysconfig
1717import tempfile
1818
19- CHECKOUT = pathlib .Path (__file__ ).parent .parent .parent .parent
19+ HERE = pathlib .Path (__file__ ).parent
20+
21+ CHECKOUT = HERE .parent .parent .parent
2022assert (CHECKOUT / "configure" ).is_file (), (
2123 "Please update the location of the file"
2224)
@@ -305,7 +307,7 @@ def configure_wasi_python(context, working_dir):
305307 )
306308
307309 config_site = os .fsdecode (
308- CHECKOUT / "Tools" / "wasm" / "wasi" / "config.site-wasm32-wasi"
310+ HERE / "config.site-wasm32-wasi"
309311 )
310312
311313 wasi_build_dir = working_dir .relative_to (CHECKOUT )
@@ -324,10 +326,7 @@ def configure_wasi_python(context, working_dir):
324326 # Use PYTHONPATH to include sysconfig data which must be anchored to the
325327 # WASI guest's `/` directory.
326328 args = {
327- "GUEST_DIR" : "/" ,
328- "HOST_DIR" : CHECKOUT ,
329- "ENV_VAR_NAME" : "PYTHONPATH" ,
330- "ENV_VAR_VALUE" : f"/{ sysconfig_data_dir } " ,
329+ "PYTHONPATH" : f"/{ sysconfig_data_dir } " ,
331330 "PYTHON_WASM" : working_dir / "python.wasm" ,
332331 }
333332 # Check dynamically for wasmtime in case it was specified manually via
@@ -417,16 +416,18 @@ def main():
417416 default_wasi_sdk = find_wasi_sdk ()
418417 default_host_runner = (
419418 f"{ WASMTIME_HOST_RUNNER_VAR } run "
420- # Make sure the stack size will work for a pydebug
421- # build.
422- # Use 32 MiB stack.
423- "--wasm max-wasm-stack=33554432 "
424- # Enable thread support; causes use of preview1.
425- # "--wasm threads=y --wasi threads=y "
419+ # For setting PYTHONPATH to the sysconfig data directory.
420+ "--env PYTHONPATH={PYTHONPATH} "
426421 # Map the checkout to / to load the stdlib from /Lib.
427- "--dir {HOST_DIR}::{GUEST_DIR} "
428- # Set PYTHONPATH to the sysconfig data.
429- "--env {ENV_VAR_NAME}={ENV_VAR_VALUE}"
422+ f"--dir { os .fsdecode (CHECKOUT )} ::/ "
423+ # Flags involving --optimize, --codegen, --debug, --wasm, and --wasi can be kept
424+ # in a config file.
425+ # We are using such a file to act as defaults in case a user wants to override
426+ # only some of the settings themselves, make it easy to modify settings
427+ # post-build so that they immediately apply to the Makefile instead of having to
428+ # regenerate it, and allow for easy copying of the settings for anyone else who
429+ # may want to use them.
430+ f"--config { os .fsdecode (HERE / 'wasmtime.toml' )} "
430431 )
431432 default_logdir = pathlib .Path (tempfile .gettempdir ())
432433
0 commit comments