Skip to content

Commit

Permalink
fix: warning when building macOS arm64 wheels
Browse files Browse the repository at this point in the history
When `MACOSX_DEPLOYMENT_TARGET` is not set by the user, cibuildwheel always defaults to `10.9`.
This leads to warning when building arm64 wheels.
This commit removes the warning by setting the default to `11.0` for arm64 builds.
  • Loading branch information
mayeut committed Oct 14, 2022
1 parent 1904551 commit fed1314
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,15 @@ def setup_python(
)
sys.exit(1)

# Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it.
# PyPy defaults to 10.7, causing inconsistencies if it's left unset.
env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9")

config_is_arm64 = python_configuration.identifier.endswith("arm64")
config_is_universal2 = python_configuration.identifier.endswith("universal2")

# Set MACOSX_DEPLOYMENT_TARGET, if the user didn't set it.
# For arm64, the minimal deployment target is 11.0.
# On x86_64 (or universal2), use 10.9 as a default.
# PyPy defaults to 10.7, causing inconsistencies if it's left unset.
env.setdefault("MACOSX_DEPLOYMENT_TARGET", "11.0" if config_is_arm64 else "10.9")

if python_configuration.version not in {"3.6", "3.7"}:
if config_is_arm64:
# macOS 11 is the first OS with arm64 support, so the wheels
Expand Down
4 changes: 4 additions & 0 deletions test/test_macos_archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ def test_cross_compiled_test(tmp_path, capfd, build_universal2):
"CIBW_BUILD": "cp39-*",
"CIBW_TEST_COMMAND": '''python -c "import platform; print('running tests on ' + platform.machine())"''',
"CIBW_ARCHS": "universal2" if build_universal2 else "x86_64 arm64",
"CIBW_BUILD_VERBOSITY": "3",
},
)

captured = capfd.readouterr()

assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value" not in captured.out
assert "[WARNING] MACOSX_DEPLOYMENT_TARGET is set to a lower value" not in captured.err

if platform.machine() == "x86_64":
# ensure that tests were run on only x86_64
assert "running tests on x86_64" in captured.out
Expand Down

0 comments on commit fed1314

Please sign in to comment.