mirror of
https://github.com/python/cpython.git
synced 2026-04-16 00:31:03 +00:00
[3.14] gh-145177: Put node version into emscripten/config.toml. (GH-146156) (#146159)
Configure node version as part of the emscripten build script, and install
that node version if it isn't available.
(cherry picked from commit 91e1312b95)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
This commit is contained in:
parent
fa3143a1d2
commit
0a9f397239
2 changed files with 35 additions and 18 deletions
|
|
@ -413,10 +413,41 @@ 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"]
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
"bash",
|
||||
"-c",
|
||||
f"source ~/.nvm/nvm.sh && nvm install {node_version}",
|
||||
],
|
||||
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."""
|
||||
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")
|
||||
|
||||
|
|
@ -435,19 +466,6 @@ def configure_emscripten_python(context, working_dir):
|
|||
)
|
||||
if pydebug:
|
||||
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()
|
||||
pkg_config_path_dir = (paths["prefix_dir"] / "lib/pkgconfig/").resolve()
|
||||
env_additions = {
|
||||
"CONFIG_SITE": config_site,
|
||||
|
|
@ -613,8 +631,6 @@ def add_cross_build_dir_option(subcommand):
|
|||
|
||||
|
||||
def main():
|
||||
default_host_runner = "node"
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
subcommands = parser.add_subparsers(dest="subcommand")
|
||||
|
||||
|
|
@ -744,10 +760,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()
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue