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