Skip to content

Commit ddb1b6b

Browse files
committed
Update MACOSX_DEPLOYMENT_TARGET parsing
Now allows versions with other than "major.minor" i.e. "major" or "major.minor.patch"
1 parent 4d925a8 commit ddb1b6b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cibuildwheel/macos.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,16 @@ def setup_python(
267267
# retrieve the one supplied by the user, otherwise 10.9 is supported with every installer.
268268
# An exception can be made for wheel built explicitly for arm64, this will be fixed later on.
269269
# PyPy defaults to 10.7, causing inconsistencies if it's left unset.
270-
deployment_target = tuple(map(int, env.get("MACOSX_DEPLOYMENT_TARGET", "10.9").split(".")))
270+
# it's valid to set e.g. MACOSX_DEPLOYMENT_TARGET=10.12.1 or MACOSX_DEPLOYMENT_TARGET=11
271+
# always normalize as tuple(major, minor)
272+
deployment_target = tuple(map(int, env.get("MACOSX_DEPLOYMENT_TARGET", "10.9").split(".")[:2]))
273+
if deployment_target[0] >= 11:
274+
# starting with macOS 11, the minor version in fact represents patch version
275+
deployment_target = (deployment_target[0], 0)
276+
if len(deployment_target) < 2:
277+
# even though it didn't make much sense before macOS 11, it was valid to set
278+
# MACOSX_DEPLOYMENT_TARGET=10 which is 10.0
279+
deployment_target = (deployment_target[0], 0)
271280

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

0 commit comments

Comments
 (0)