Skip to content

Commit 991693a

Browse files
authored
[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)
1 parent 85b587a commit 991693a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Lib/distutils/spawn.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
5959
if _cfg_target:
6060
_cfg_target_split = [int(x) for x in _cfg_target.split('.')]
6161
if _cfg_target:
62-
# ensure that the deployment target of build process is not less
63-
# than that used when the interpreter was built. This ensures
64-
# extension modules are built with correct compatibility values
62+
# Ensure that the deployment target of the build process is not
63+
# less than 10.3 if the interpreter was built for 10.3 or later.
64+
# This ensures extension modules are built with correct
65+
# compatibility values, specifically LDSHARED which can use
66+
# '-undefined dynamic_lookup' which only works on >= 10.3.
6567
cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
66-
if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
68+
cur_target_split = [int(x) for x in cur_target.split('.')]
69+
if _cfg_target_split[:2] >= [10, 3] and cur_target_split[:2] < [10, 3]:
6770
my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
68-
'now "%s" but "%s" during configure'
71+
'now "%s" but "%s" during configure;'
72+
'must use 10.3 or later'
6973
% (cur_target, _cfg_target))
7074
raise DistutilsPlatformError(my_msg)
7175
env = dict(os.environ,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Relax unnecessarily restrictive MACOSX_DEPLOYMENT_TARGET check when building
2+
extension modules for macOS. Patch by Joshua Root.

0 commit comments

Comments
 (0)