|
1 | 1 | import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess, hashlib, cPickle, re
|
2 | 2 | from subprocess import Popen, PIPE, STDOUT
|
3 | 3 | from tempfile import mkstemp
|
| 4 | +from distutils.spawn import find_executable |
4 | 5 | import jsrun, cache, tempfiles
|
5 | 6 | from response_file import create_response_file
|
6 | 7 | import logging, platform
|
@@ -204,25 +205,12 @@ def new(*args):
|
204 | 205 | config_file = '\n'.join(config_file)
|
205 | 206 | # autodetect some default paths
|
206 | 207 | config_file = config_file.replace('{{{ EMSCRIPTEN_ROOT }}}', __rootpath__)
|
207 |
| - llvm_root = '/usr/bin' |
208 |
| - try: |
209 |
| - llvm_root = os.path.dirname(Popen(['which', 'llvm-dis'], stdout=PIPE).communicate()[0].replace('\n', '')) |
210 |
| - except: |
211 |
| - pass |
| 208 | + llvm_root = find_executable('llvm-dis') or '/usr/bin' |
212 | 209 | config_file = config_file.replace('{{{ LLVM_ROOT }}}', llvm_root)
|
213 |
| - node = 'node' |
214 |
| - try: |
215 |
| - node = Popen(['which', 'node'], stdout=PIPE).communicate()[0].replace('\n', '') or \ |
216 |
| - Popen(['which', 'nodejs'], stdout=PIPE).communicate()[0].replace('\n', '') or node |
217 |
| - except: |
218 |
| - pass |
| 210 | + node = find_executable('node') or find_executable('nodejs') or 'node' |
219 | 211 | config_file = config_file.replace('{{{ NODE }}}', node)
|
220 |
| - python = sys.executable or 'python' |
221 |
| - try: |
222 |
| - python = Popen(['which', 'python2'], stdout=PIPE).communicate()[0].replace('\n', '') or \ |
223 |
| - Popen(['which', 'python'], stdout=PIPE).communicate()[0].replace('\n', '') or python |
224 |
| - except: |
225 |
| - pass |
| 212 | + python = find_executable('python2') or find_executable('python') or \ |
| 213 | + sys.executable or 'python' |
226 | 214 | config_file = config_file.replace('{{{ PYTHON }}}', python)
|
227 | 215 |
|
228 | 216 | # write
|
|
0 commit comments