blob: f199a353482bec7dd8f6180f8d856f0faca648af [file] [log] [blame]
Refael Ackermanncc9dd0f2018-08-21 23:28:531#!/bin/sh
2
cclaussbe926c72019-02-01 13:51:373# 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# When a 'which' call is made for a specific version of Python on Travis CI,
7# pyenv will alert which shims are available and then will fail the build.
Refael Ackermanncc9dd0f2018-08-21 23:28:538_=[ 'exec' '/bin/sh' '-c' '''
cclaussbe926c72019-02-01 13:51:379test ${TRAVIS} && exec python "$0" "$@" # workaround for pyenv on Travis CI
Michaël Zasso3a076ba2019-10-31 11:01:2610which python3.8 >/dev/null && exec python3.8 "$0" "$@"
cclaussbe926c72019-02-01 13:51:3711which python3.7 >/dev/null && exec python3.7 "$0" "$@"
12which python3.6 >/dev/null && exec python3.6 "$0" "$@"
13which python3.5 >/dev/null && exec python3.5 "$0" "$@"
Sam Robertsb2ccbb22019-10-23 16:55:1314which python2.7 >/dev/null && exec python2.7 "$0" "$@"
Refael Ackermanncc9dd0f2018-08-21 23:28:5315exec python "$0" "$@"
16''' "$0" "$@"
17]
18del _
19
20import sys
cclaussbe926c72019-02-01 13:51:3721from distutils.spawn import find_executable
Refael Ackermanncc9dd0f2018-08-21 23:28:5322
cclaussbe926c72019-02-01 13:51:3723print('Node configure: Found Python {0}.{1}.{2}...'.format(*sys.version_info))
Michaël Zasso3a076ba2019-10-31 11:01:2624acceptable_pythons = ((3, 8), (3, 7), (3, 6), (3, 5), (2, 7))
cclaussbe926c72019-02-01 13:51:3725if sys.version_info[:2] in acceptable_pythons:
26 import configure
27else:
28 python_cmds = ['python{0}.{1}'.format(*vers) for vers in acceptable_pythons]
29 sys.stderr.write('Please use {0}.\n'.format(' or '.join(python_cmds)))
30 for python_cmd in python_cmds:
31 python_cmd_path = find_executable(python_cmd)
32 if python_cmd_path and 'pyenv/shims' not in python_cmd_path:
33 sys.stderr.write('\t{0} {1}\n'.format(python_cmd_path,
34 ' '.join(sys.argv[:1])))
Refael Ackermanncc9dd0f2018-08-21 23:28:5335 sys.exit(1)