44import contextlib
55import functools
66import os
7+ import tomllib
78
89try :
910 from os import process_cpu_count as cpu_count
1819
1920HERE = pathlib .Path (__file__ ).parent
2021
22+ # Path is: wasi wasm Tools cpython
2123CHECKOUT = HERE .parent .parent .parent
2224assert (CHECKOUT / "configure" ).is_file (), (
2325 "Please update the location of the file"
@@ -213,9 +215,10 @@ def make_build_python(context, working_dir):
213215 log ("🎉" , f"{ binary } { version } " )
214216
215217
216- def find_wasi_sdk ():
218+ def find_wasi_sdk (config ):
217219 """Find the path to the WASI SDK."""
218220 wasi_sdk_path = None
221+ wasi_sdk_version = config ["targets" ]["wasi-sdk" ]
219222
220223 if wasi_sdk_path_env_var := os .environ .get ("WASI_SDK_PATH" ):
221224 wasi_sdk_path = pathlib .Path (wasi_sdk_path_env_var )
@@ -229,7 +232,7 @@ def find_wasi_sdk():
229232 # ``wasi-sdk-{WASI_SDK_VERSION}.0-x86_64-linux``.
230233 potential_sdks = [
231234 path
232- for path in opt_path .glob (f"wasi-sdk-{ WASI_SDK_VERSION } .0*" )
235+ for path in opt_path .glob (f"wasi-sdk-{ wasi_sdk_version } .0*" )
233236 if path .is_dir ()
234237 ]
235238 if len (potential_sdks ) == 1 :
@@ -245,12 +248,12 @@ def find_wasi_sdk():
245248 found_version = version_details .splitlines ()[0 ]
246249 # Make sure there's a trailing dot to avoid false positives if somehow the
247250 # supported version is a prefix of the found version (e.g. `25` and `2567`).
248- if not found_version .startswith (f"{ WASI_SDK_VERSION } ." ):
251+ if not found_version .startswith (f"{ wasi_sdk_version } ." ):
249252 major_version = found_version .partition ("." )[0 ]
250253 log (
251254 "⚠️" ,
252255 f" Found WASI SDK { major_version } , "
253- f"but WASI SDK { WASI_SDK_VERSION } is the supported version" ,
256+ f"but WASI SDK { wasi_sdk_version } is the supported version" ,
254257 )
255258
256259 return wasi_sdk_path
@@ -410,8 +413,10 @@ def clean_contents(context):
410413
411414
412415def main ():
413- default_host_triple = "wasm32-wasip1"
414- default_wasi_sdk = find_wasi_sdk ()
416+ with (HERE / "config.toml" ).open ("rb" ) as file :
417+ config = tomllib .load (file )
418+ default_wasi_sdk = find_wasi_sdk (config )
419+ default_host_triple = config ["targets" ]["host-triple" ]
415420 default_host_runner = (
416421 f"{ WASMTIME_HOST_RUNNER_VAR } run "
417422 # For setting PYTHONPATH to the sysconfig data directory.
0 commit comments