1#!/bin/sh 2 3# Locate an acceptable Python interpreter and then re-execute the script. 4# Note that the mix of single and double quotes is intentional, 5# as is the fact that the ] goes on a new line. 6_=[ 'exec' '/bin/sh' '-c' ''' 7command -v python3.12 >/dev/null && exec python3.12 "$0" "$@" 8command -v python3.11 >/dev/null && exec python3.11 "$0" "$@" 9command -v python3.10 >/dev/null && exec python3.10 "$0" "$@" 10command -v python3.9 >/dev/null && exec python3.9 "$0" "$@" 11command -v python3.8 >/dev/null && exec python3.8 "$0" "$@" 12command -v python3.7 >/dev/null && exec python3.7 "$0" "$@" 13command -v python3.6 >/dev/null && exec python3.6 "$0" "$@" 14command -v python3 >/dev/null && exec python3 "$0" "$@" 15exec python "$0" "$@" 16''' "$0" "$@" 17] 18del _ 19 20import sys 21try: 22 from shutil import which 23except ImportError: 24 from distutils.spawn import find_executable as which 25 26print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info)) 27acceptable_pythons = ((3, 12), (3, 11), (3, 10), (3, 9), (3, 8), (3, 7), (3, 6)) 28if sys.version_info[:2] in acceptable_pythons: 29 import configure 30else: 31 python_cmds = ['python{}.{}'.format(*vers) for vers in acceptable_pythons] 32 sys.stderr.write('Please use {}.\n'.format(' or '.join(python_cmds))) 33 for python_cmd in python_cmds: 34 python_cmd_path = which(python_cmd) 35 if python_cmd_path and 'pyenv/shims' not in python_cmd_path: 36 sys.stderr.write('\t{} {}\n'.format(python_cmd_path, ' '.join(sys.argv[:1]))) 37 sys.exit(1) 38