Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 34 additions & 18 deletions 52 Platforms/emscripten/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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,
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions 1 Platforms/emscripten/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.