From b0635fe748c37296d28b7ff74376140af3c9d4f2 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 1 Sep 2013 00:33:49 +0000 Subject: [PATCH] [SCons] Fix compilation of Python 3 module when PYTHONHOME is set --- SConstruct | 2 ++ site_scons/buildutils.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index e602e2e61..f26548d2e 100644 --- a/SConstruct +++ b/SConstruct @@ -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: diff --git a/site_scons/buildutils.py b/site_scons/buildutils.py index 1f7d7ae16..1676e47f6 100644 --- a/site_scons/buildutils.py +++ b/site_scons/buildutils.py @@ -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)