]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-42504: fix for MACOSX_DEPLOYMENT_TARGET=11 (GH-23556)
authorFX Coudert <fxcoudert@gmail.com>
Thu, 3 Dec 2020 03:20:18 +0000 (04:20 +0100)
committerGitHub <noreply@github.com>
Thu, 3 Dec 2020 03:20:18 +0000 (22:20 -0500)
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.

Lib/distutils/spawn.py
Lib/distutils/tests/test_build_ext.py
Lib/test/test_posix.py
Misc/NEWS.d/next/macOS/2020-12-02-15-48-40.bpo-42504.RQmMOR.rst [new file with mode: 0644]
setup.py

index 0d1bd0391e6f1134e4472d7e133d8302d564a7dc..f50edd2da9710068324ff48d4ec275347370716b 100644 (file)
@@ -54,8 +54,8 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
         global _cfg_target, _cfg_target_split
         if _cfg_target is None:
             from distutils import sysconfig
-            _cfg_target = sysconfig.get_config_var(
-                                  'MACOSX_DEPLOYMENT_TARGET') or ''
+            _cfg_target = str(sysconfig.get_config_var(
+                                  'MACOSX_DEPLOYMENT_TARGET') or '')
             if _cfg_target:
                 _cfg_target_split = [int(x) for x in _cfg_target.split('.')]
         if _cfg_target:
index 6bb009a86f41eb8d95b94dde03c64249f8c6bce8..a3055c198403264bf1210806868514efd9de73c9 100644 (file)
@@ -456,7 +456,7 @@ class BuildExtTestCase(TempdirManager,
         deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
         if deptarget:
             # increment the minor version number (i.e. 10.6 -> 10.7)
-            deptarget = [int(x) for x in deptarget.split('.')]
+            deptarget = [int(x) for x in str(deptarget).split('.')]
             deptarget[-1] += 1
             deptarget = '.'.join(str(i) for i in deptarget)
             self._try_compile_deployment_target('<', deptarget)
@@ -489,7 +489,7 @@ class BuildExtTestCase(TempdirManager,
 
         # get the deployment target that the interpreter was built with
         target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
-        target = tuple(map(int, target.split('.')[0:2]))
+        target = tuple(map(int, str(target).split('.')[0:2]))
         # format the target value as defined in the Apple
         # Availability Macros.  We can't use the macro names since
         # at least one value we test with will not exist yet.
@@ -498,7 +498,11 @@ class BuildExtTestCase(TempdirManager,
             target = '%02d%01d0' % target
         else:
             # for 10.10 and beyond -> "10nn00"
-            target = '%02d%02d00' % target
+            if len(target) >= 2:
+                target = '%02d%02d00' % target
+            else:
+                # 11 and later can have no minor version (11 instead of 11.0)
+                target = '%02d0000' % target
         deptarget_ext = Extension(
             'deptarget',
             [deptarget_c],
index 18afbef082bffc3c3e4055d8ea4c8f778ffeae55..d4d348cdc02d095bdf49a9a01191b9549c1fdbcc 100644 (file)
@@ -1061,7 +1061,7 @@ class PosixTester(unittest.TestCase):
         if sys.platform == 'darwin':
             import sysconfig
             dt = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') or '10.0'
-            if tuple(int(n) for n in dt.split('.')[0:2]) < (10, 6):
+            if tuple(int(n) for n in str(dt).split('.')[0:2]) < (10, 6):
                 raise unittest.SkipTest("getgroups(2) is broken prior to 10.6")
 
         # 'id -G' and 'os.getgroups()' should return the same
diff --git a/Misc/NEWS.d/next/macOS/2020-12-02-15-48-40.bpo-42504.RQmMOR.rst b/Misc/NEWS.d/next/macOS/2020-12-02-15-48-40.bpo-42504.RQmMOR.rst
new file mode 100644 (file)
index 0000000..c83bc2b
--- /dev/null
@@ -0,0 +1 @@
+Fix build on macOS Big Sur when MACOSX_DEPLOYMENT_TARGET=11
\ No newline at end of file
index b7a7d26c5325bc53fc429b90b20ac18c3ad382da..0c9a42501686926eb7b8a186c89d8619a41827e9 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1014,7 +1014,7 @@ class PyBuildExt(build_ext):
             os_release = int(os.uname()[2].split('.')[0])
             dep_target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
             if (dep_target and
-                    (tuple(int(n) for n in dep_target.split('.')[0:2])
+                    (tuple(int(n) for n in str(dep_target).split('.')[0:2])
                         < (10, 5) ) ):
                 os_release = 8
             if os_release < 9: