Skip to content

Commit f7b4182

Browse files
committed
pythongh-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.
1 parent 0f2246b commit f7b4182

2 files changed

Lines changed: 35 additions & 14 deletions

File tree

‎Platforms/emscripten/__main__.py‎

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,35 @@ def make_mpdec(context, working_dir):
413413
write_library_config(prefix, "mpdec", mpdec_config, context.quiet)
414414

415415

416+
def calculate_node_path():
417+
node_version := os.environ.get("PYTHON_NODE_VERSION", None)
418+
if node_version is None:
419+
node_version = load_config_toml()["node-version"]
420+
421+
res = subprocess.run(
422+
[
423+
"bash",
424+
"-c",
425+
f"source ~/.nvm/nvm.sh && nvm install {node_version}",
426+
],
427+
text=True,
428+
capture_output=True,
429+
check=True,
430+
)
431+
432+
res = subprocess.run(
433+
[
434+
"bash",
435+
"-c",
436+
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
437+
],
438+
text=True,
439+
capture_output=True,
440+
check=True,
441+
)
442+
return res.stdout.strip()
443+
444+
416445
@subdir("host_dir", clean_ok=True)
417446
def configure_emscripten_python(context, working_dir):
418447
"""Configure the emscripten/host build."""
@@ -437,17 +466,8 @@ def configure_emscripten_python(context, working_dir):
437466
sysconfig_data += "-pydebug"
438467

439468
host_runner = context.host_runner
440-
if node_version := os.environ.get("PYTHON_NODE_VERSION", None):
441-
res = subprocess.run(
442-
[
443-
"bash",
444-
"-c",
445-
f"source ~/.nvm/nvm.sh && nvm which {node_version}",
446-
],
447-
text=True,
448-
capture_output=True,
449-
)
450-
host_runner = res.stdout.strip()
469+
if host_runner is None:
470+
host_runner = calculate_node_path()
451471
pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve()
452472
env_additions = {
453473
"CONFIG_SITE": config_site,
@@ -744,10 +764,10 @@ def main():
744764
subcommand.add_argument(
745765
"--host-runner",
746766
action="store",
747-
default=default_host_runner,
767+
default=None,
748768
dest="host_runner",
749-
help="Command template for running the emscripten host"
750-
f"`{default_host_runner}`)",
769+
help="Command template for running the emscripten host "
770+
"(default: use nvm to install the node version specified in config.toml)",
751771
)
752772

753773
context = parser.parse_args()

‎Platforms/emscripten/config.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This allows for blanket copying of the Emscripten build code between supported
33
# Python versions.
44
emscripten-version = "4.0.12"
5+
node-version = "24"
56

67
[libffi]
78
url = "https://github.com/libffi/libffi/releases/download/v{version}/libffi-{version}.tar.gz"

0 commit comments

Comments
 (0)