2018-08-21 23:28:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-12-30 14:09:52 +00:00
|
|
|
# Locate an acceptable Python interpreter and then re-execute the script.
|
2019-02-01 13:51:37 +00: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-21 23:28:53 +00:00
|
|
|
_=[ 'exec' '/bin/sh' '-c' '''
|
2023-11-06 14:11:01 +00:00
|
|
|
command -v python3.12 >/dev/null && exec python3.12 "$0" "$@"
|
2022-10-26 13:01:59 +00:00
|
|
|
command -v python3.11 >/dev/null && exec python3.11 "$0" "$@"
|
2021-10-04 07:01:04 +00:00
|
|
|
command -v python3.10 >/dev/null && exec python3.10 "$0" "$@"
|
2020-10-06 15:51:24 +00: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 07:23:58 +00: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 20:57:50 +00:00
|
|
|
command -v python3 >/dev/null && exec python3 "$0" "$@"
|
2018-08-21 23:28:53 +00:00
|
|
|
exec python "$0" "$@"
|
|
|
|
''' "$0" "$@"
|
|
|
|
]
|
|
|
|
del _
|
|
|
|
|
|
|
|
import sys
|
2021-05-05 22:48:14 +00:00
|
|
|
try:
|
|
|
|
from shutil import which
|
|
|
|
except ImportError:
|
|
|
|
from distutils.spawn import find_executable as which
|
2018-08-21 23:28:53 +00:00
|
|
|
|
2020-12-30 14:09:52 +00:00
|
|
|
print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info))
|
2023-11-06 14:11:01 +00:00
|
|
|
acceptable_pythons = ((3, 12), (3, 11), (3, 10), (3, 9), (3, 8), (3, 7), (3, 6))
|
2019-02-01 13:51:37 +00:00
|
|
|
if sys.version_info[:2] in acceptable_pythons:
|
|
|
|
import configure
|
|
|
|
else:
|
2020-12-30 14:09:52 +00: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 13:51:37 +00:00
|
|
|
for python_cmd in python_cmds:
|
2021-05-05 22:48:14 +00:00
|
|
|
python_cmd_path = which(python_cmd)
|
2019-02-01 13:51:37 +00:00
|
|
|
if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
|
2020-12-30 14:09:52 +00:00
|
|
|
sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1])))
|
2018-08-21 23:28:53 +00:00
|
|
|
sys.exit(1)
|