@@ -12,10 +12,10 @@ exec python "$0" "$@"
12
12
del _
13
13
14
14
import sys
15
+ from distutils.spawn import find_executable as which
15
16
if sys.version_info[0] ! = 2 or sys.version_info[1] not in (6, 7):
16
17
sys.stderr.write(' Please use either Python 2.6 or 2.7' )
17
18
18
- from distutils.spawn import find_executable as which
19
19
python2 = which(' python2' ) or which(' python2.6' ) or which(' python2.7' )
20
20
21
21
if python2:
@@ -1350,36 +1350,36 @@ def configure_inspector(o):
1350
1350
options.without_ssl)
1351
1351
o[' variables' ][' v8_enable_inspector' ] = 0 if disable_inspector else 1
1352
1352
1353
- bin_override = None
1354
1353
1355
- def setup_bin_overrides ():
1356
- global bin_override
1354
+ def get_bin_override ():
1357
1355
# If the system python is not the python we are running (which should be
1358
1356
# python 2), then create a directory with a symlink called `python` to our
1359
1357
# sys.executable. This directory will be prefixed to the PATH, so that
1360
1358
# other tools that shell out to `python` will use the appropriate python
1361
1359
1362
- from distutils.spawn import find_executable as which
1363
1360
if os.path.realpath(which(' python' )) == os.path.realpath(sys.executable):
1364
1361
return
1365
1362
1366
1363
bin_override = os.path.abspath(' out/tools/bin' )
1367
1364
try:
1368
1365
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
1372
1368
1373
1369
python_link = os.path.join(bin_override, ' python' )
1374
1370
try:
1375
1371
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
1379
1374
os.symlink(sys.executable, python_link)
1380
1375
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)
1381
1379
os.environ[' PATH' ] = bin_override + ' :' + os.environ[' PATH' ]
1382
1380
1381
+ return bin_override
1382
+
1383
1383
output = {
1384
1384
' variables' : {},
1385
1385
' include_dirs' : [],
@@ -1458,9 +1458,9 @@ if options.prefix:
1458
1458
1459
1459
config = ' \n' .join(map(' =' .join, config.iteritems ())) + ' \n'
1460
1460
1461
- setup_bin_overrides ()
1461
+ bin_override = get_bin_override ()
1462
1462
if bin_override:
1463
- config = ' export PATH:=' + bin_override + ' :${ PATH} \n' + config
1463
+ config = ' export PATH:=' + bin_override + ' :$( PATH) \n' + config
1464
1464
1465
1465
write(' config.mk' , do_not_edit + config)
1466
1466
0 commit comments