From f7b41821ae08e607510cc63fa07c0c226a2542f8 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Mar 2026 09:24:58 +0100 Subject: [PATCH 1/4] gh-145177: Put node version into emscripten/config.toml as well. This is the last bit of config that is in the buildbot config that we should move to the cpython repo. --- Platforms/emscripten/__main__.py | 48 ++++++++++++++++++++++---------- Platforms/emscripten/config.toml | 1 + 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 78825a52fed29b..d96fa6b2a24b8c 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -413,6 +413,35 @@ def make_mpdec(context, working_dir): write_library_config(prefix, "mpdec", mpdec_config, context.quiet) +def calculate_node_path(): + node_version := os.environ.get("PYTHON_NODE_VERSION", None) + if node_version is None: + node_version = load_config_toml()["node-version"] + + res = subprocess.run( + [ + "bash", + "-c", + f"source ~/.nvm/nvm.sh && nvm install {node_version}", + ], + text=True, + capture_output=True, + check=True, + ) + + res = subprocess.run( + [ + "bash", + "-c", + f"source ~/.nvm/nvm.sh && nvm which {node_version}", + ], + text=True, + capture_output=True, + check=True, + ) + return res.stdout.strip() + + @subdir("host_dir", clean_ok=True) def configure_emscripten_python(context, working_dir): """Configure the emscripten/host build.""" @@ -437,17 +466,8 @@ def configure_emscripten_python(context, working_dir): sysconfig_data += "-pydebug" host_runner = context.host_runner - if node_version := os.environ.get("PYTHON_NODE_VERSION", None): - res = subprocess.run( - [ - "bash", - "-c", - f"source ~/.nvm/nvm.sh && nvm which {node_version}", - ], - text=True, - capture_output=True, - ) - host_runner = res.stdout.strip() + if host_runner is None: + host_runner = calculate_node_path() pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve() env_additions = { "CONFIG_SITE": config_site, @@ -744,10 +764,10 @@ def main(): subcommand.add_argument( "--host-runner", action="store", - default=default_host_runner, + default=None, dest="host_runner", - help="Command template for running the emscripten host" - f"`{default_host_runner}`)", + help="Command template for running the emscripten host " + "(default: use nvm to install the node version specified in config.toml)", ) context = parser.parse_args() diff --git a/Platforms/emscripten/config.toml b/Platforms/emscripten/config.toml index 98edaebe992685..4e76b5bf9f7d2b 100644 --- a/Platforms/emscripten/config.toml +++ b/Platforms/emscripten/config.toml @@ -2,6 +2,7 @@ # This allows for blanket copying of the Emscripten build code between supported # Python versions. emscripten-version = "4.0.12" +node-version = "24" [libffi] url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz" From 718431096bac19784d52238003f5484e3c264851 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Mar 2026 09:35:34 +0100 Subject: [PATCH 2/4] Remove unused default_host_runner variable --- Platforms/emscripten/__main__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index d96fa6b2a24b8c..cf3324ba1612c4 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -633,8 +633,6 @@ def add_cross_build_dir_option(subcommand): def main(): - default_host_runner = "node" - parser = argparse.ArgumentParser() subcommands = parser.add_subparsers(dest="subcommand") From 4f391654a51f43a968289774cb835f4a8ac36fd6 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Mar 2026 09:41:28 +0100 Subject: [PATCH 3/4] Fix --- Platforms/emscripten/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index cf3324ba1612c4..0c9f76a68c0be3 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -414,7 +414,7 @@ def make_mpdec(context, working_dir): def calculate_node_path(): - node_version := os.environ.get("PYTHON_NODE_VERSION", None) + node_version = os.environ.get("PYTHON_NODE_VERSION", None) if node_version is None: node_version = load_config_toml()["node-version"] From d22facc9eb5b2b032eba31fef1fa24b088a9cb92 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 19 Mar 2026 10:11:10 +0100 Subject: [PATCH 4/4] Don't hide output from nvm install --- Platforms/emscripten/__main__.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Platforms/emscripten/__main__.py b/Platforms/emscripten/__main__.py index 0c9f76a68c0be3..a7c52c2d59f10d 100644 --- a/Platforms/emscripten/__main__.py +++ b/Platforms/emscripten/__main__.py @@ -418,14 +418,12 @@ def calculate_node_path(): if node_version is None: node_version = load_config_toml()["node-version"] - res = subprocess.run( + subprocess.run( [ "bash", "-c", f"source ~/.nvm/nvm.sh && nvm install {node_version}", ], - text=True, - capture_output=True, check=True, ) @@ -446,6 +444,10 @@ def calculate_node_path(): def configure_emscripten_python(context, working_dir): """Configure the emscripten/host build.""" validate_emsdk_version(context.emsdk_cache) + host_runner = context.host_runner + if host_runner is None: + host_runner = calculate_node_path() + paths = context.build_paths config_site = os.fsdecode(EMSCRIPTEN_DIR / "config.site-wasm32-emscripten") @@ -464,10 +466,6 @@ def configure_emscripten_python(context, working_dir): ) if pydebug: sysconfig_data += "-pydebug" - - host_runner = context.host_runner - if host_runner is None: - host_runner = calculate_node_path() pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve() env_additions = { "CONFIG_SITE": config_site,