Skip to content

Commit fc4b0cb

Browse files
committed
Merge pull request #1332 from int3/use-distutils
Use distutils.
2 parents f4114f4 + 691454a commit fc4b0cb

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

tools/shared.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess, hashlib, cPickle, re
22
from subprocess import Popen, PIPE, STDOUT
33
from tempfile import mkstemp
4+
from distutils.spawn import find_executable
45
import jsrun, cache, tempfiles
56
from response_file import create_response_file
67
import logging, platform
@@ -204,25 +205,12 @@ def new(*args):
204205
config_file = '\n'.join(config_file)
205206
# autodetect some default paths
206207
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'
212209
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'
219211
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'
226214
config_file = config_file.replace('{{{ PYTHON }}}', python)
227215

228216
# write

0 commit comments

Comments
 (0)