Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
29ae702
Add install-emscripten CLI command
bulenty584 Oct 15, 2025
d71ae08
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 15, 2025
ea08570
Emsdk installation comments fixed in xbuildenv.py and unneeded tests …
bulenty584 Oct 16, 2025
d86a11d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 16, 2025
8f20c44
TestInstallEmscripten class removed from test_install_emscripten.py a…
bulenty584 Oct 16, 2025
8041a1a
Following @ryanking's comments,
bulenty584 Oct 17, 2025
709ef84
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2025
7b4736b
Fixed integration test command to use xbuildenv and activate emsdk
bulenty584 Oct 19, 2025
83fddb9
1. emsdk activation directory changed in main.yml
bulenty584 Oct 20, 2025
41ffece
Merge branch 'main' into feat/add-install-emscripten-cli
ryanking13 Oct 21, 2025
abfe731
1. Fixed unittests to follow new code changes
bulenty584 Oct 21, 2025
1fd6457
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 21, 2025
8b52aa5
Updated Python version to 3.13 for xbuildenv and changed back lines 9…
bulenty584 Oct 22, 2025
8876921
new auto-activate emsdk, installation done in xbuildenv.py and cli pr…
bulenty584 Nov 3, 2025
f1fded0
Merge branch 'main' into feat/auto-activate-emsdk
bulenty584 Nov 3, 2025
dda1a80
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 3, 2025
a2e68ac
updated tests reflect new behavior, assuming activate emscripten is a…
bulenty584 Nov 3, 2025
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
1 change: 0 additions & 1 deletion pyodide_build/cli/xbuildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,3 @@ def _install_emscripten(
emsdk_dir = manager.install_emscripten(version)

print("Installing emsdk complete.")
print(f"Use `source {emsdk_dir}/emsdk_env.sh` to set up the environment.")
5 changes: 0 additions & 5 deletions pyodide_build/tests/test_cli_install_emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ def fake_install(self, version):
assert result.exit_code == 0, result.stdout
assert "Installing emsdk..." in result.stdout, result.stdout
assert "Installing emsdk complete." in result.stdout, result.stdout
assert "Use `source" in result.stdout, result.stdout
assert "emsdk_env.sh` to set up the environment." in result.stdout, result.stdout
assert called["version"] == "3.1.46"


Expand Down Expand Up @@ -134,7 +132,6 @@ def fake_install(self, version):
assert result.exit_code == 0, result.stdout
assert "Installing emsdk..." in result.stdout, result.stdout
assert "Installing emsdk complete." in result.stdout, result.stdout
assert str(existing_emsdk / "emsdk_env.sh") in result.stdout


def test_install_emscripten_git_failure(tmp_path, monkeypatch):
Expand Down Expand Up @@ -220,5 +217,3 @@ def test_install_emscripten_output_format(tmp_path, monkeypatch):
# Verify output format - check for key messages (logger adds extra lines)
assert "Installing emsdk..." in result.stdout
assert "Installing emsdk complete." in result.stdout
assert "Use `source" in result.stdout
assert "emsdk_env.sh` to set up the environment." in result.stdout
32 changes: 28 additions & 4 deletions pyodide_build/tests/test_install_emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def mock_run_side_effect(cmd, **kwargs):

# Verify
assert result == emsdk_dir
assert mock_run.call_count == 4 # clone + install + patch + activate
assert mock_run.call_count == 5 # clone + install + patch + activate + source env

# Check the four subprocess calls
# Check the subprocess calls in the expected order
calls = mock_run.call_args_list

# 1. Clone emsdk
Expand Down Expand Up @@ -153,6 +153,14 @@ def mock_run_side_effect(cmd, **kwargs):
check=True,
)

# 5. Source the environment script to validate activation
assert calls[4] == call(
"source ./emsdk_env.sh",
check=True,
shell=True,
cwd=emsdk_dir,
)


def test_install_emscripten_specific_version(tmp_path, monkeypatch):
"""Test installing a specific Emscripten SDK version"""
Expand Down Expand Up @@ -182,7 +190,7 @@ def mock_run_side_effect(cmd, **kwargs):

# Verify
assert result == emsdk_dir
assert mock_run.call_count == 4 # clone + install + patch + activate
assert mock_run.call_count == 5 # clone + install + patch + activate + source env

calls = mock_run.call_args_list

Expand All @@ -208,6 +216,14 @@ def mock_run_side_effect(cmd, **kwargs):
check=True,
)

# Verify sourcing of the environment script (call 4)
assert calls[4] == call(
"source ./emsdk_env.sh",
check=True,
shell=True,
cwd=emsdk_dir,
)


def test_install_emscripten_with_existing_emsdk(tmp_path, monkeypatch):
"""Test installing Emscripten when emsdk directory already exists"""
Expand All @@ -234,7 +250,7 @@ def test_install_emscripten_with_existing_emsdk(tmp_path, monkeypatch):

# Verify - should pull, then install, patch, and activate
assert result == emsdk_dir
assert mock_run.call_count == 4
assert mock_run.call_count == 5

calls = mock_run.call_args_list

Expand All @@ -261,6 +277,14 @@ def test_install_emscripten_with_existing_emsdk(tmp_path, monkeypatch):
check=True,
)

# 5. Source the environment script
assert calls[4] == call(
"source ./emsdk_env.sh",
check=True,
shell=True,
cwd=emsdk_dir,
)


def test_install_emscripten_patch_fails(tmp_path, monkeypatch):
"""Test handling of patch application failure due to version mismatch"""
Expand Down
13 changes: 13 additions & 0 deletions pyodide_build/xbuildenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,19 @@ def install_emscripten(self, emscripten_version: str = "latest") -> Path:
)

logger.info("Emscripten SDK installed successfully at %s", emsdk_dir)

try:
subprocess.run(
"source ./emsdk_env.sh",
check=True,
shell=True,
cwd=emsdk_dir,
)
except subprocess.CalledProcessError as e:
raise RuntimeError(
f"Failed to activate emsdk environment. Please check the emsdk installation at {emsdk_dir}"
) from e

return emsdk_dir

def _add_version_marker(self) -> None:
Expand Down