Validate pyodide-version option against Pyodide build identifier (#2925)
* Validate pyodide-version against identifier * Add tests * Allow Pyodide nightly xbuildenvs too (for later)
This commit is contained in:
@@ -25,12 +25,19 @@ from cibuildwheel.options import (
|
||||
_get_pinned_container_images,
|
||||
)
|
||||
from cibuildwheel.platforms import ALL_PLATFORM_MODULES, get_build_identifiers
|
||||
from cibuildwheel.platforms.pyodide import (
|
||||
PyodideXBuildEnvInfo,
|
||||
validate_pyodide_target_python,
|
||||
)
|
||||
from cibuildwheel.platforms.pyodide import (
|
||||
PythonConfiguration as PyodidePythonConfiguration,
|
||||
)
|
||||
from cibuildwheel.util import resources
|
||||
from cibuildwheel.util.packaging import DependencyConstraints
|
||||
|
||||
TYPE_CHECKING = False
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Callable, Sequence
|
||||
|
||||
PYPROJECT_1 = """
|
||||
[tool.cibuildwheel]
|
||||
@@ -106,6 +113,62 @@ def test_options_1(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
assert local.pyodide_version == "0.29.4"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def make_pyodide_xbuildenv_info() -> Callable[[str, str], PyodideXBuildEnvInfo]:
|
||||
def _make(version: str, python: str) -> PyodideXBuildEnvInfo:
|
||||
return {
|
||||
"version": version,
|
||||
"python": python,
|
||||
"emscripten": "5.0.3",
|
||||
"pyodide_build": {"min": None, "max": None},
|
||||
"compatible": True,
|
||||
}
|
||||
|
||||
return _make
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def make_pyodide_python_configuration() -> Callable[[str, str], PyodidePythonConfiguration]:
|
||||
def _make(identifier: str, version: str) -> PyodidePythonConfiguration:
|
||||
return PyodidePythonConfiguration(
|
||||
version=version,
|
||||
identifier=identifier,
|
||||
default_pyodide_version="0.0.0",
|
||||
node_version="v22",
|
||||
)
|
||||
|
||||
return _make
|
||||
|
||||
|
||||
def test_validate_pyodide_target_python_matching(
|
||||
make_pyodide_xbuildenv_info: Callable[[str, str], PyodideXBuildEnvInfo],
|
||||
make_pyodide_python_configuration: Callable[[str, str], PyodidePythonConfiguration],
|
||||
) -> None:
|
||||
xbuildenv_info = make_pyodide_xbuildenv_info("314.0.0", "3.14.2")
|
||||
config = make_pyodide_python_configuration("cp314-pyodide_wasm32", "3.14")
|
||||
# should not raise
|
||||
validate_pyodide_target_python(xbuildenv_info, config)
|
||||
|
||||
|
||||
def test_validate_pyodide_target_python_mismatch(
|
||||
make_pyodide_xbuildenv_info: Callable[[str, str], PyodideXBuildEnvInfo],
|
||||
make_pyodide_python_configuration: Callable[[str, str], PyodidePythonConfiguration],
|
||||
) -> None:
|
||||
# a Python 3.14 xbuildenv applied to a cp313-pyodide_wasm32 build, when a global
|
||||
# pyodide-version is set across mismatched targets
|
||||
xbuildenv_info = make_pyodide_xbuildenv_info("314.0.0", "3.14.2")
|
||||
config = make_pyodide_python_configuration("cp313-pyodide_wasm32", "3.13")
|
||||
|
||||
with pytest.raises(errors.ConfigurationError) as exc_info:
|
||||
validate_pyodide_target_python(xbuildenv_info, config)
|
||||
|
||||
message = str(exc_info.value)
|
||||
assert "cp313-pyodide_wasm32" in message
|
||||
assert "314.0.0" in message
|
||||
assert "3.13" in message
|
||||
assert "3.14" in message
|
||||
|
||||
|
||||
def test_test_and_audit_requires_with_dependency_specifiers(tmp_path: Path) -> None:
|
||||
"""Regression test for https://github.com/pypa/cibuildwheel/issues/2912"""
|
||||
pyproject_toml = tmp_path / "pyproject.toml"
|
||||
|
||||
Reference in New Issue
Block a user