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

## [Unreleased]

### Changed

- Platform name for the Pyodide wheel is now `pyemscripten` instead of `pyodide`, following the PEP 783 standard.
If you want to use the old platform name, you can set the `USE_LEGACY_PLATFORM` environment variable to `1`.
[#319](https://github.com/pyodide/pyodide-build/pull/319)

Comment on lines +10 to +15

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.

Would something like this work?

Suggested change
### Changed
- Platform name for the Pyodide wheel is now `pyemscripten` instead of `pyodide`, following the PEP 783 standard.
If you want to use the old platform name, you can set the `USE_LEGACY_PLATFORM` environment variable to `1`.
[#319](https://github.com/pyodide/pyodide-build/pull/319)
### Changed
- Platform name for the Pyodide wheel is now `pyemscripten` instead of `pyodide`, following the PEP 783 standard.
If you want to use the old platform name, you can set the `USE_LEGACY_PLATFORM` environment variable to `1`. This environment variable will be available until Pyodide v0.31, and will be removed in v0.32.
[#319](https://github.com/pyodide/pyodide-build/pull/319)

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.

Actually, the pyemscripten platform has almost nothing to do with pyodide runtime itself. It only affects how packages are installed, and Pyodide does not check the platform name at all. It is only the pyodide venv (pyodide-build) or micropip that checks the platform. So I think it is weird to say that it will be removed in future Pyodide versions.

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.

Ah, interesting. Thanks for the clarification!

## [0.34.0] - 2026/03/31

### Added
Expand Down
5 changes: 4 additions & 1 deletion pyodide_build/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ def platform() -> str:

def wheel_platform() -> str:
abi_version = get_build_flag("PYODIDE_ABI_VERSION")
return f"pyodide_{abi_version}_wasm32"
legacy_platform = to_bool(get_host_build_flag("USE_LEGACY_PLATFORM"))
if legacy_platform:
return f"pyodide_{abi_version}_wasm32"
return f"pyemscripten_{abi_version}_wasm32"


def pyodide_tags_() -> Iterator[Tag]:
Expand Down
3 changes: 3 additions & 0 deletions pyodide_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def _parse_makefile_envs(
"xbuildenv_path": "PYODIDE_XBUILDENV_PATH",
"dist_dir": "PYODIDE_DIST_DIR",
"ignored_build_requirements": "IGNORED_BUILD_REQUIREMENTS",
"use_legacy_platform": "USE_LEGACY_PLATFORM",
# maintainer only
"_f2c_fixes_wrapper": "_F2C_FIXES_WRAPPER",
}
Expand All @@ -273,6 +274,7 @@ def _parse_makefile_envs(
"default_cross_build_env_url",
"xbuildenv_path",
"ignored_build_requirements",
"use_legacy_platform",
# maintainer only
"_f2c_fixes_wrapper",
}
Expand All @@ -297,6 +299,7 @@ def _parse_makefile_envs(
"xbuildenv_path": "",
# A list of PEP508 build-time requirements to be ignored when building a wheel
"ignored_build_requirements": " ".join(BASE_IGNORED_REQUIREMENTS),
"use_legacy_platform": "0",
# maintainer only
"_f2c_fixes_wrapper": "",
}
Expand Down
10 changes: 8 additions & 2 deletions pyodide_build/out_of_tree/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import virtualenv

from pyodide_build.build_env import get_build_flag, get_pyodide_root, in_xbuildenv
from pyodide_build.build_env import (
get_build_flag,
get_pyodide_root,
in_xbuildenv,
wheel_platform,
)
from pyodide_build.common import IS_WIN, run_command
from pyodide_build.logger import logger

Expand Down Expand Up @@ -311,7 +316,7 @@ def _get_pip_monkeypatch(self) -> str:
sysconfigdata_dir = Path(get_build_flag("TARGETINSTALLDIR")) / "sysconfigdata"
pip_patched_name = self.pip_patched_path.name
exe_suffix = self.exe_suffix
pyodide_platform = f"pyodide_{get_build_flag('PYODIDE_ABI_VERSION')}_wasm32"
pyodide_platform = wheel_platform()
return dedent(
"""\
import os
Expand Down Expand Up @@ -343,6 +348,7 @@ def get_executable():
def _emscripten_platforms():
pyodide_abi_version = sysconfig.get_config_var("PYODIDE_ABI_VERSION")
if pyodide_abi_version:
yield f"pyemscripten_{pyodide_abi_version}_wasm32"
yield f"pyodide_{pyodide_abi_version}_wasm32"
yield from tags._generic_platforms()

Expand Down
1 change: 1 addition & 0 deletions pyodide_build/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _reset():
build_env.get_host_build_environment_vars.cache_clear()
build_env.get_build_environment_vars.cache_clear()
build_env.get_unisolated_packages.cache_clear()
build_env.pyodide_tags.cache_clear()
common.default_xbuildenv_path.cache_clear()

_reset()
Expand Down
6 changes: 3 additions & 3 deletions pyodide_build/tests/recipe/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ def test_needs_rebuild(tmpdir, is_wheel):
dist_dir = pkg_root / "dist"
dist_dir.mkdir()
# Build of current version with wrong abi
(dist_dir / "regex-12-cp311-cp311-pyodide_2024_0_wasm32.whl").touch()
(dist_dir / "regex-12-cp311-cp311-pyemscripten_2024_0_wasm32.whl").touch()
# Build of old version with current abi
(dist_dir / "regex-11-cp312-cp312-pyodide_2024_0_wasm32.whl").touch()
(dist_dir / "regex-11-cp312-cp312-pyemscripten_2024_0_wasm32.whl").touch()
# the version we're trying to build
packaged = dist_dir / "regex-12-cp312-cp312-pyodide_2024_0_wasm32.whl"
packaged = dist_dir / "regex-12-cp312-cp312-pyemscripten_2024_0_wasm32.whl"
else:
packaged = buildpath / ".packaged"

Expand Down
45 changes: 45 additions & 0 deletions pyodide_build/tests/test_build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,51 @@ def test_get_build_environment_vars_host_env(
assert "RANDOM_ENV" not in e


class TestWheelPlatform:
def test_default_pyemscripten(self, dummy_xbuildenv, reset_env_vars, reset_cache):
abi_version = build_env.get_build_flag("PYODIDE_ABI_VERSION")
assert build_env.wheel_platform() == f"pyemscripten_{abi_version}_wasm32"

def test_legacy_pyodide(
self, dummy_xbuildenv, monkeypatch, reset_env_vars, reset_cache
):
monkeypatch.setenv("USE_LEGACY_PLATFORM", "1")
build_env.get_host_build_environment_vars.cache_clear()
build_env.get_build_environment_vars.cache_clear()

abi_version = build_env.get_build_flag("PYODIDE_ABI_VERSION")
assert build_env.wheel_platform() == f"pyodide_{abi_version}_wasm32"

def test_pyodide_tags_include_both_platforms(
self, dummy_xbuildenv, reset_env_vars, reset_cache
):
build_env.pyodide_tags.cache_clear()
tags = build_env.pyodide_tags()
platforms = {t.platform for t in tags}

emscripten_plat = build_env.platform()
wheel_plat = build_env.wheel_platform()

assert emscripten_plat in platforms
assert wheel_plat in platforms
assert wheel_plat.startswith("pyemscripten_")

def test_pyodide_tags_legacy_platform(
self, dummy_xbuildenv, monkeypatch, reset_env_vars, reset_cache
):
monkeypatch.setenv("USE_LEGACY_PLATFORM", "1")
build_env.get_host_build_environment_vars.cache_clear()
build_env.get_build_environment_vars.cache_clear()
build_env.pyodide_tags.cache_clear()

tags = build_env.pyodide_tags()
platforms = {t.platform for t in tags}

wheel_plat = build_env.wheel_platform()
assert wheel_plat.startswith("pyodide_")
assert wheel_plat in platforms


def test_wheel_paths(dummy_xbuildenv):
from pathlib import Path

Expand Down
2 changes: 1 addition & 1 deletion pyodide_build/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def test_build_cpython_module(tmp_path, dummy_xbuildenv, mock_emscripten):
results = list(dist_dir.glob("*.whl"))
assert len(results) == 1
result = results[0]
assert result.name == "pydecimal-1.0.0-cp312-cp312-pyodide_2024_0_wasm32.whl"
assert result.name == "pydecimal-1.0.0-cp312-cp312-pyemscripten_2024_0_wasm32.whl"


def test_wheel_download_version_mismatch(tmp_path, dummy_xbuildenv, mock_emscripten):
Expand Down