2018-08-22 01:28:53 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-12-30 15:09:52 +01:00
|
|
|
# Locate an acceptable Python interpreter and then re-execute the script.
|
2019-02-01 14:51:37 +01:00
|
|
|
# Note that the mix of single and double quotes is intentional,
|
|
|
|
# as is the fact that the ] goes on a new line.
|
2018-08-22 01:28:53 +02:00
|
|
|
_=[ 'exec' '/bin/sh' '-c' '''
|
2020-10-06 17:51:24 +02:00
|
|
|
command -v python3.9 >/dev/null && exec python3.9 "$0" "$@"
|
build: fix inability to detect correct python command in configure
The "which" utility is not guaranteed to be installed, and if it is, its
behavior is not portable.
Conversely, the "command -v" shell builtin is required to exist in all
POSIX 2008 compliant shells, and is thus guaranteed to work everywhere.
Examples of open-source shells likely to be installed as /bin/sh on
Linux, which implement the 12-year-old standard: ash, bash, busybox,
dash, ksh, mksh and zsh.
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
PR-URL: https://github.com/nodejs/node/pull/32925
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-04-19 09:23:58 +02:00
|
|
|
command -v python3.8 >/dev/null && exec python3.8 "$0" "$@"
|
|
|
|
command -v python3.7 >/dev/null && exec python3.7 "$0" "$@"
|
|
|
|
command -v python3.6 >/dev/null && exec python3.6 "$0" "$@"
|
2020-11-05 21:57:50 +01:00
|
|
|
command -v python3 >/dev/null && exec python3 "$0" "$@"
|
2018-08-22 01:28:53 +02:00
|
|
|
exec python "$0" "$@"
|
|
|
|
''' "$0" "$@"
|
|
|
|
]
|
|
|
|
del _
|
|
|
|
|
|
|
|
import sys
|
2021-05-06 00:48:14 +02:00
|
|
|
try:
|
|
|
|
from shutil import which
|
|
|
|
except ImportError:
|
|
|
|
from distutils.spawn import find_executable as which
|
2018-08-22 01:28:53 +02:00
|
|
|
|
2020-12-30 15:09:52 +01:00
|
|
|
print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info))
|
|
|
|
acceptable_pythons = ((3, 9), (3, 8), (3, 7), (3, 6))
|
2019-02-01 14:51:37 +01:00
|
|
|
if sys.version_info[:2] in acceptable_pythons:
|
|
|
|
import configure
|
|
|
|
else:
|
2020-12-30 15:09:52 +01:00
|
|
|
python_cmds = ['python{}.{}'.format(*vers) for vers in acceptable_pythons]
|
|
|
|
sys.stderr.write('Please use {}.\n'.format(' or '.join(python_cmds)))
|
2019-02-01 14:51:37 +01:00
|
|
|
for python_cmd in python_cmds:
|
2021-05-06 00:48:14 +02:00
|
|
|
python_cmd_path = which(python_cmd)
|
2019-02-01 14:51:37 +01:00
|
|
|
if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
|
2020-12-30 15:09:52 +01:00
|
|
|
sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1])))
|
2018-08-22 01:28:53 +02:00
|
|
|
sys.exit(1)
|