diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-24 15:24:50 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-24 15:24:50 -0700 |
commit | 9e7c7b3a139f919965a79558399167bcd165f2ea (patch) | |
tree | 2786fbf8cac2596693cf29cfbfd41b9ab63bcbd9 /tools/shared.py | |
parent | 7750e1c5017dba886cadcfb30b350d4414357a2a (diff) |
use env python instead of python in tools/shared if it is available
Diffstat (limited to 'tools/shared.py')
-rw-r--r-- | tools/shared.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/shared.py b/tools/shared.py index 5751ef60..3dfd2873 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -216,7 +216,17 @@ try: except NameError: pass -WINDOWS = sys.platform.startswith ('win') +WINDOWS = sys.platform.startswith('win') + +# If we have 'env', we should use that to find python, because |python| may fail while |env python| may work +# (For example, if system python is 3.x while we need 2.x, and env gives 2.x if told to do so.) +ENV_PREFIX = [] +if not WINDOWS: + try: + assert 'Python' in Popen(['env', 'python', '-V'], stdout=PIPE, stderr=STDOUT).communicate()[0] + ENV_PREFIX = ['env'] + except: + pass # Temp file utilities @@ -617,7 +627,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # Run Emscripten settings = Settings.serialize() - compiler_output = timeout_run(Popen(['python', EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') + compiler_output = timeout_run(Popen(ENV_PREFIX + ['python', EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') #print compiler_output # Detect compilation crashes and errors |