[SCons] Fix compilation of Python 3 module when PYTHONHOME is set

This commit is contained in:
Ray Speth 2013-09-01 00:33:49 +00:00
parent 9f90edc313
commit b0635fe748
2 changed files with 8 additions and 1 deletions

View file

@ -672,6 +672,8 @@ print
# Copy in external environment variables
if env['env_vars'] == 'all':
env['ENV'].update(os.environ)
if 'PYTHONHOME' in env['ENV']:
del env['ENV']['PYTHONHOME']
elif env['env_vars']:
for name in env['env_vars'].split(','):
if name in os.environ:

View file

@ -591,9 +591,14 @@ def getCommandOutput(cmd, *args):
Substitute for subprocess.check_output which is only available
in Python >= 2.7
"""
environ = dict(os.environ)
if 'PYTHONHOME' in environ:
# Can cause problems when trying to run a different Python interpreter
del environ['PYTHONHOME']
proc = subprocess.Popen([cmd] + list(args),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
env=environ)
data, err = proc.communicate()
if proc.returncode:
raise OSError(err)