Skip to content
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.34.1] - 2026/04/03

### Added

- `pyodide config` exposes a variable `emscripten_dir` that points to the Emscripten installation
directory in the xbuildenv (this is only available after Emscripten gets installed into the
xbuildenv via the `pyodide xbuildenv install-emscripten` command).
[#321](https://github.com/pyodide/pyodide-build/pull/321)

### Changed

- Platform name for the Pyodide wheel is now `pyemscripten` instead of `pyodide`, following the PEP 783 standard.
Expand Down
13 changes: 13 additions & 0 deletions pyodide_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ def _load_cross_build_envs(self) -> Mapping[str, str]:
for k, v in DEFAULT_CONFIG_COMPUTED.items()
}

# Compute the Emscripten directory from pyodide_root. The emsdk directory
# is a sibling of the xbuildenv directory, both living under the versioned
# xbuildenv root (pyodide_root/../../emsdk/upstream/emscripten).
# We compute this here rather than via Makefile.envs or DEFAULT_CONFIG so
# that the path is always the resolved, versioned path – not the shared
# xbuildenv symlink, because there are some issues I have noticed with
# concurrent builds especially when being used in cibuildwheel etc.
Comment on lines +118 to +121
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the Emscripten version was being mis-found during concurrent builds. For example, in pypa/cibuildwheel#2800, we were previously relying on the symlinks. When running the test suite in parallel, it would find Emscripten 3.1.58 when we would need 4.0.9 and cause weird failures in the tests. I kept the comment a bit vague, though, indeed. Happy to add more details if you need me to?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Makes sense, thanks!

computed_vars["emscripten_dir"] = str(
self.pyodide_root.parent.parent / "emsdk" / "upstream" / "emscripten"
)

return {
BUILD_VAR_TO_KEY[k]: v
for k, v in makefile_vars.items()
Expand Down Expand Up @@ -250,6 +261,7 @@ def _parse_makefile_envs(
"build_dependency_index_url": "BUILD_DEPENDENCY_INDEX_URL",
"default_cross_build_env_url": "DEFAULT_CROSS_BUILD_ENV_URL",
"xbuildenv_path": "PYODIDE_XBUILDENV_PATH",
"emscripten_dir": "PYODIDE_EMSCRIPTEN_DIR",
"dist_dir": "PYODIDE_DIST_DIR",
"ignored_build_requirements": "IGNORED_BUILD_REQUIREMENTS",
"use_legacy_platform": "USE_LEGACY_PLATFORM",
Expand Down Expand Up @@ -340,6 +352,7 @@ def _parse_makefile_envs(
"ldflags": "SIDE_MODULE_LDFLAGS",
"meson_cross_file": "MESON_CROSS_FILE",
"xbuildenv_path": "PYODIDE_XBUILDENV_PATH",
"emscripten_dir": "PYODIDE_EMSCRIPTEN_DIR",
"pyodide_abi_version": "PYODIDE_ABI_VERSION",
"pyodide_root": "PYODIDE_ROOT",
"dist_dir": "PYODIDE_DIST_DIR",
Expand Down
17 changes: 17 additions & 0 deletions pyodide_build/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ def test_computed_vars(self, dummy_xbuildenv, reset_env_vars, reset_cache):
assert makefile_vars[k] != v # The template should have been substituted
assert "$(" not in makefile_vars[k]

def test_emscripten_dir(self, dummy_xbuildenv, reset_env_vars, reset_cache):
xbuildenv_manager = CrossBuildEnvManager(
dummy_xbuildenv / common.xbuildenv_dirname()
)
config_manager = CrossBuildEnvConfigManager(
pyodide_root=xbuildenv_manager.pyodide_root
)

expected = str(
xbuildenv_manager.pyodide_root.parent.parent
/ "emsdk"
/ "upstream"
/ "emscripten"
)
assert config_manager.config["emscripten_dir"] == expected
assert config_manager.to_env()["PYODIDE_EMSCRIPTEN_DIR"] == expected

def test_load_config_from_env(self, dummy_xbuildenv, reset_env_vars, reset_cache):
xbuildenv_manager = CrossBuildEnvManager(
dummy_xbuildenv / common.xbuildenv_dirname()
Expand Down