Skip to content

Commit

Permalink
Address joerick's review comments pypa#2
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed May 19, 2023
1 parent 8018030 commit bd61db0
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cibuildwheel/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _compute_platform_only(only: str) -> PlatformName:
return "macos"
if "win_" in only or "win32" in only:
return "windows"
if "emscripten_" in only:
if "pyodide_" in only:
return "pyodide"
print(
f"Invalid --only='{only}', must be a build selector with a known platform",
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"macosx_x86_64": "macOS x86_64",
"macosx_universal2": "macOS Universal 2 - x86_64 and arm64",
"macosx_arm64": "macOS arm64 - Apple Silicon",
"emscripten_3_1_32": "Pyodide v0.23.x",
"pyodide_wasm32": "Pyodide v0.23.x",
}


Expand Down
6 changes: 5 additions & 1 deletion cibuildwheel/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ def build(options: Options, tmp_path: Path) -> None:
# This environment variable tells it also to mount our temp
# directory.
oldmounts = ""
extra_mounts = [str(identifier_tmp_dir)]
if Path(".").resolve().is_relative_to("/tmp"):
extra_mounts.append(str(Path(".").resolve()))

if "_PYODIDE_EXTRA_MOUNTS" in env:
oldmounts = env["_PYODIDE_EXTRA_MOUNTS"] + ":"
env["_PYODIDE_EXTRA_MOUNTS"] = oldmounts + str(identifier_tmp_dir)
env["_PYODIDE_EXTRA_MOUNTS"] = oldmounts + ":".join(extra_mounts)

compatible_wheel = find_compatible_wheel(built_wheels, config.identifier)
if compatible_wheel:
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel/resources/build-platforms.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ python_configurations = [

[pyodide]
python_configurations = [
{ identifier = "cp311-emscripten_3_1_32", version = "3.11.2", pyodide_version = "0.23.2", emscripten_version = "3.1.32" },
{ identifier = "cp311-pyodide_wasm32", version = "3.11.2", pyodide_version = "0.23.2", emscripten_version = "3.1.32" },
]
6 changes: 3 additions & 3 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

import os

import pytest

from . import utils


def pytest_addoption(parser) -> None:
parser.addoption(
Expand All @@ -22,6 +22,6 @@ def pytest_addoption(parser) -> None:
params=[{"CIBW_BUILD_FRONTEND": "pip"}, {"CIBW_BUILD_FRONTEND": "build"}], ids=["pip", "build"]
)
def build_frontend_env(request) -> dict[str, str]:
if os.environ.get("CIBW_PLATFORM", None) == "pyodide":
if utils.platform == "pyodide":
pytest.skip("Can't use pip as build frontend for pyodide platform")
return request.param # type: ignore[no-any-return]
4 changes: 1 addition & 3 deletions test/test_abi_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ def test_abi_none(tmp_path, capfd):
project_dir,
add_env={
"CIBW_TEST_REQUIRES": "pytest",
"CIBW_TEST_COMMAND": "pytest {project}/test",
# limit the number of builds for test performance reasons
"CIBW_BUILD": "cp38-* cp311-* pp39-*",
"_PYODIDE_EXTRA_MOUNTS": str(tmp_path),
"CIBW_BUILD": "cp38-* cp310-* pp39-*",
},
)

Expand Down
14 changes: 10 additions & 4 deletions test/test_custom_repair_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import subprocess
from test import test_projects
from contextlib import nullcontext as does_not_raise
import pytest

from . import utils

Expand Down Expand Up @@ -33,15 +35,18 @@ def test(tmp_path, capfd):

num_builds = len(utils.cibuildwheel_get_build_identifiers(project_dir))
err = None
try:
utils.cibuildwheel_run(
if num_builds > 1:
expectation = pytest.raises(subprocess.CalledProcessError)
else:
expectation = does_not_raise()

with expectation:
result = utils.cibuildwheel_run(
project_dir,
add_env={
"CIBW_REPAIR_WHEEL_COMMAND": "python repair.py {wheel} {dest_dir}",
},
)
except subprocess.CalledProcessError as e:
err = e

captured = capfd.readouterr()

Expand All @@ -57,3 +62,4 @@ def test(tmp_path, capfd):
# error is raised
assert err is None
assert "spam-0.1.0-py2-none-emscripten" in captured.out
assert result[0].startswith("spam-0.1.0-py2-none-")
1 change: 0 additions & 1 deletion test/test_subdir_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test(capfd, tmp_path):
"CIBW_TEST_COMMAND": "python {package}/test/run_tests.py",
# this shouldn't depend on the version of python, so build only CPython 3.11
"CIBW_BUILD": "cp311-*",
"_PYODIDE_EXTRA_MOUNTS": str(tmp_path),
},
)

Expand Down
2 changes: 0 additions & 2 deletions test/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def test(tmp_path):
# mac/linux.
"CIBW_TEST_COMMAND": "false || pytest {project}/test",
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
"_PYODIDE_EXTRA_MOUNTS": str(tmp_path),
},
)

Expand All @@ -107,7 +106,6 @@ def test_extras_require(tmp_path):
# mac/linux.
"CIBW_TEST_COMMAND": "false || pytest {project}/test",
"CIBW_TEST_COMMAND_WINDOWS": "COLOR 00 || pytest {project}/test",
"_PYODIDE_EXTRA_MOUNTS": str(tmp_path),
},
)

Expand Down

0 comments on commit bd61db0

Please sign in to comment.