summaryrefslogtreecommitdiff
path: root/Lib/distutils/spawn.py
diff options
context:
space:
mode:
authorNed Deily <nad@acm.org>2011-06-28 20:01:52 -0700
committerNed Deily <nad@acm.org>2011-06-28 20:01:52 -0700
commit8c86d308a155e86f2ef630777cd5ac08c926f139 (patch)
tree36b0d34bb6217437b195e9b9ffe88c4e7383fe30 /Lib/distutils/spawn.py
parent274271d1ae71dbd1177b54a5def45fed3ecb501f (diff)
parent657b2de893a206dbcc3d34baa65f6cfda11726e5 (diff)
downloadcpython-git-8c86d308a155e86f2ef630777cd5ac08c926f139.tar.gz
Issue #9516: Merge Distutils changes from 3.2
Diffstat (limited to 'Lib/distutils/spawn.py')
-rw-r--r--Lib/distutils/spawn.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 8c476dc23f..2b62c968a4 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -96,15 +96,42 @@ def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
raise DistutilsExecError(
"command '%s' failed with exit status %d" % (cmd[0], rc))
+if sys.platform == 'darwin':
+ from distutils import sysconfig
+ _cfg_target = None
+ _cfg_target_split = None
+
def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
log.info(' '.join(cmd))
if dry_run:
return
exec_fn = search_path and os.execvp or os.execv
+ exec_args = [cmd[0], cmd]
+ if sys.platform == 'darwin':
+ global _cfg_target, _cfg_target_split
+ if _cfg_target is None:
+ _cfg_target = 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:
+ # 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
+ cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
+ if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
+ my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
+ 'now "%s" but "%s" during configure'
+ % (cur_target, _cfg_target))
+ raise DistutilsPlatformError(my_msg)
+ env = dict(os.environ,
+ MACOSX_DEPLOYMENT_TARGET=cur_target)
+ exec_fn = search_path and os.execvpe or os.execve
+ exec_args.append(env)
pid = os.fork()
if pid == 0: # in the child
try:
- exec_fn(cmd[0], cmd)
+ exec_fn(*exec_args)
except OSError as e:
sys.stderr.write("unable to execute %s: %s\n"
% (cmd[0], e.strerror))