Skip to content

Commit 64d45da

Browse files
miss-islingtonfxcoudert
authored andcommitted
bpo-42504: fix for MACOSX_DEPLOYMENT_TARGET=11 (pythonGH-23556)
macOS releases numbering has changed as of macOS 11 Big Sur. Previously, major releases were of the form 10.x, 10.x+1, 10.x+2, etc; as of Big Sur, they are now x, x+1, etc, so, for example, 10.15, 10.15.1, ..., 10.15.7, 11, 11.0.1, 11.1, ..., 12, 12.1, etc. Allow Python to build with single-digit deployment target values. Patch provided by FX Coudert. (cherry picked from commit 5291639) Co-authored-by: FX Coudert <fxcoudert@gmail.com>
1 parent 250937f commit 64d45da

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

Lib/distutils/spawn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
9595
global _cfg_target, _cfg_target_split
9696
if _cfg_target is None:
9797
from distutils import sysconfig
98-
_cfg_target = sysconfig.get_config_var(
99-
'MACOSX_DEPLOYMENT_TARGET') or ''
98+
_cfg_target = str(sysconfig.get_config_var(
99+
'MACOSX_DEPLOYMENT_TARGET') or '')
100100
if _cfg_target:
101101
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
102102
if _cfg_target:

Lib/distutils/tests/test_build_ext.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def test_deployment_target_higher_ok(self):
455455
deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
456456
if deptarget:
457457
# increment the minor version number (i.e. 10.6 -> 10.7)
458-
deptarget = [int(x) for x in deptarget.split('.')]
458+
deptarget = [int(x) for x in str(deptarget).split('.')]
459459
deptarget[-1] += 1
460460
deptarget = '.'.join(str(i) for i in deptarget)
461461
self._try_compile_deployment_target('<', deptarget)
@@ -488,7 +488,7 @@ def _try_compile_deployment_target(self, operator, target):
488488

489489
# get the deployment target that the interpreter was built with
490490
target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
491-
target = tuple(map(int, target.split('.')[0:2]))
491+
target = tuple(map(int, str(target).split('.')[0:2]))
492492
# format the target value as defined in the Apple
493493
# Availability Macros. We can't use the macro names since
494494
# at least one value we test with will not exist yet.
@@ -497,7 +497,11 @@ def _try_compile_deployment_target(self, operator, target):
497497
target = '%02d%01d0' % target
498498
else:
499499
# for 10.10 and beyond -> "10nn00"
500-
target = '%02d%02d00' % target
500+
if len(target) >= 2:
501+
target = '%02d%02d00' % target
502+
else:
503+
# 11 and later can have no minor version (11 instead of 11.0)
504+
target = '%02d0000' % target
501505
deptarget_ext = Extension(
502506
'deptarget',
503507
[deptarget_c],

Lib/test/test_posix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def test_getgroups(self):
10461046
if sys.platform == 'darwin':
10471047
import sysconfig
10481048
dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
1049-
if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
1049+
if tuple(int(n) for n in str(dt).split('.')[0:2]) < (10, 6):
10501050
raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
10511051

10521052
# 'id -G' and 'os.getgroups()' should return the same
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix build on macOS Big Sur when MACOSX_DEPLOYMENT_TARGET=11

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def detect_readline_curses(self):
912912
os_release = int(os.uname()[2].split('.')[0])
913913
dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
914914
if (dep_target and
915-
(tuple(int(n) for n in dep_target.split('.')[0:2])
915+
(tuple(int(n) for n in str(dep_target).split('.')[0:2])
916916
< (10, 5) ) ):
917917
os_release = 8
918918
if os_release < 9:

0 commit comments

Comments
 (0)