Skip to content

Commit

Permalink
Merge pull request #1750 from njzjz/macos-test-venv
Browse files Browse the repository at this point in the history
test macos-x86_64 and arm64 in different venv dir
  • Loading branch information
joerick committed Feb 3, 2024
2 parents c7a653d + d635c0e commit 88c1134
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def build(options: Options, tmp_path: Path) -> None:
# there are no dependencies that were pulled in at build time.
call("pip", "install", "virtualenv", *dependency_constraint_flags, env=env)

venv_dir = identifier_tmp_dir / "venv-test"
venv_dir = identifier_tmp_dir / f"venv-test-{testing_arch}"

arch_prefix = []
if testing_arch != machine_arch:
Expand Down
31 changes: 30 additions & 1 deletion test/test_macos_archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_deployment_target_warning_is_firing(tmp_path, capfd):


@pytest.mark.parametrize("skip_arm64_test", [False, True])
def test_universal2_testing(tmp_path, capfd, skip_arm64_test):
def test_universal2_testing_on_x86_64(tmp_path, capfd, skip_arm64_test):
if utils.platform != "macos":
pytest.skip("this test is only relevant to macos")
if get_xcode_version() < (12, 2):
Expand Down Expand Up @@ -173,6 +173,35 @@ def test_universal2_testing(tmp_path, capfd, skip_arm64_test):
assert set(actual_wheels) == set(expected_wheels)


def test_universal2_testing_on_arm64(tmp_path, capfd):
# cibuildwheel should test the universal2 wheel on both x86_64 and arm64, when run on arm64
if utils.platform != "macos":
pytest.skip("this test is only relevant to macos")
if platform.machine() != "arm64":
pytest.skip("this test only works on arm64")

project_dir = tmp_path / "project"
basic_project.generate(project_dir)

actual_wheels = utils.cibuildwheel_run(
project_dir,
add_env={
"CIBW_BUILD": "cp39-*",
"CIBW_ARCHS": "universal2",
# check that a native dependency is correctly installed, once per each testing arch
"CIBW_TEST_REQUIRES": "numpy",
"CIBW_TEST_COMMAND": '''python -c "import numpy, platform; print(f'running tests on {platform.machine()} with numpy {numpy.__version__}')"''',
},
)

captured = capfd.readouterr()
assert "running tests on arm64" in captured.out
assert "running tests on x86_64" in captured.out

expected_wheels = [w for w in ALL_MACOS_WHEELS if "cp39" in w and "universal2" in w]
assert set(actual_wheels) == set(expected_wheels)


def test_cp38_arm64_testing(tmp_path, capfd):
if utils.platform != "macos":
pytest.skip("this test is only relevant to macos")
Expand Down

0 comments on commit 88c1134

Please sign in to comment.