[Python-checkins] [3.9] bpo-43568: Relax distutils MACOSX_DEPLOYMENT_TARGET check (GH-25827) (GH-26001)

ned-deily webhook-mailer at python.org
Wed Jun 2 20:25:23 EDT 2021


https://github.com/python/cpython/commit/991693a217363243b0bd33887852d6b3959b99a1
commit: 991693a217363243b0bd33887852d6b3959b99a1
branch: 3.9
author: Joshua Root <jmr at macports.org>
committer: ned-deily <nad at python.org>
date: 2021-06-02T20:25:15-04:00
summary:

[3.9] bpo-43568: Relax distutils MACOSX_DEPLOYMENT_TARGET check (GH-25827) (GH-26001)

Only complain if the config target is >= 10.3 and the current target is
< 10.3. The check was originally added to ensure that incompatible
LDSHARED flags are not used, because '-undefined dynamic_lookup' is
used when building for 10.3 and later, and is not supported on older OS
versions. Apart from that, there should be no problem in general
with using an older target. In particular, this allows targeting macOS
11.0 when Python was built for a newer minor version like 11.3.

(manually cherry picked from part of commit 8703178)

files:
A Misc/NEWS.d/next/macOS/2021-06-02-19-21-13.bpo-43568.viomLm.rst
M Lib/distutils/spawn.py

diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 0d1bd0391e6f11..31df3f7faca552 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -59,13 +59,17 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
             if _cfg_target:
                 _cfg_target_split = [int(x) for x in _cfg_target.split('.')]
         if _cfg_target:
-            # ensure that the deployment target of build process is not less
-            # than that used when the interpreter was built. This ensures
-            # extension modules are built with correct compatibility values
+            # Ensure that the deployment target of the build process is not
+            # less than 10.3 if the interpreter was built for 10.3 or later.
+            # This ensures extension modules are built with correct
+            # compatibility values, specifically LDSHARED which can use
+            # '-undefined dynamic_lookup' which only works on >= 10.3.
             cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
-            if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
+            cur_target_split = [int(x) for x in cur_target.split('.')]
+            if _cfg_target_split[:2] >= [10, 3] and cur_target_split[:2] < [10, 3]:
                 my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
-                          'now "%s" but "%s" during configure'
+                          'now "%s" but "%s" during configure;'
+                          'must use 10.3 or later'
                                 % (cur_target, _cfg_target))
                 raise DistutilsPlatformError(my_msg)
             env = dict(os.environ,
diff --git a/Misc/NEWS.d/next/macOS/2021-06-02-19-21-13.bpo-43568.viomLm.rst b/Misc/NEWS.d/next/macOS/2021-06-02-19-21-13.bpo-43568.viomLm.rst
new file mode 100644
index 00000000000000..57757ba1ed0509
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2021-06-02-19-21-13.bpo-43568.viomLm.rst
@@ -0,0 +1,2 @@
+Relax unnecessarily restrictive MACOSX_DEPLOYMENT_TARGET check when building
+extension modules for macOS. Patch by Joshua Root.



More information about the Python-checkins mailing list