@@ -12,10 +12,10 @@ exec python "$0" "$@"
1212del _
1313
1414import sys
15+ from distutils.spawn import find_executable as which
1516if sys.version_info[0] ! = 2 or sys.version_info[1] not in (6, 7):
1617 sys.stderr.write(' Please use either Python 2.6 or 2.7' )
1718
18- from distutils.spawn import find_executable as which
1919 python2 = which(' python2' ) or which(' python2.6' ) or which(' python2.7' )
2020
2121 if python2:
@@ -1350,36 +1350,36 @@ def configure_inspector(o):
13501350 options.without_ssl)
13511351 o[' variables' ][' v8_enable_inspector' ] = 0 if disable_inspector else 1
13521352
1353- bin_override = None
13541353
1355- def setup_bin_overrides ():
1356- global bin_override
1354+ def get_bin_override ():
13571355 # If the system python is not the python we are running (which should be
13581356 # python 2), then create a directory with a symlink called `python` to our
13591357 # sys.executable. This directory will be prefixed to the PATH, so that
13601358 # other tools that shell out to `python` will use the appropriate python
13611359
1362- from distutils.spawn import find_executable as which
13631360 if os.path.realpath(which(' python' )) == os.path.realpath(sys.executable):
13641361 return
13651362
13661363 bin_override = os.path.abspath(' out/tools/bin' )
13671364 try:
13681365 os.makedirs(bin_override)
1369- except os.error as e:
1370- if e.errno ! = errno.EEXIST:
1371- raise e
1366+ except OSError as e:
1367+ if e.errno ! = errno.EEXIST: raise e
13721368
13731369 python_link = os.path.join(bin_override, ' python' )
13741370 try:
13751371 os.unlink(python_link)
1376- except os.error as e:
1377- if e.errno ! = errno.ENOENT:
1378- raise e
1372+ except OSError as e:
1373+ if e.errno ! = errno.ENOENT: raise e
13791374 os.symlink(sys.executable, python_link)
13801375
1376+ # We need to set the environment right now so that when gyp (in run_gyp)
1377+ # shells out, it finds the right python (specifically at
1378+ # https://github.com/nodejs/node/blob/d82e107/deps/v8/gypfiles/toolchain.gypi#L43)
13811379 os.environ[' PATH' ] = bin_override + ' :' + os.environ[' PATH' ]
13821380
1381+ return bin_override
1382+
13831383output = {
13841384 ' variables' : {},
13851385 ' include_dirs' : [],
@@ -1458,9 +1458,9 @@ if options.prefix:
14581458
14591459config = ' \n' .join(map(' =' .join, config.iteritems ())) + ' \n'
14601460
1461- setup_bin_overrides ()
1461+ bin_override = get_bin_override ()
14621462if bin_override:
1463- config = ' export PATH:=' + bin_override + ' :${ PATH} \n' + config
1463+ config = ' export PATH:=' + bin_override + ' :$( PATH) \n' + config
14641464
14651465write(' config.mk' , do_not_edit + config)
14661466
0 commit comments