#!/bin/sh

"true" '''\'
for pyimpl in python3 python python2; do
  which $pyimpl > /dev/null 2>&1  && echo "Using $pyimpl for Python" && exec $pyimpl "$0" "$@"
done
echo "Error! Could not locate python! Please install and have python3, python, or python2 in PATH."
echo "Or use: /path/to/valid/python configure $@"
exit 127
'''

import os, sys

if sys.version_info < (3,0):
  print('************************************************************************')
  print('*             python2 support in configure is deprecated               *')
  print('*         SLEPc version 3.18+ will require at least python3.4          *')
  print('************************************************************************')

if sys.version_info < (2,7) or (sys.version_info >= (3,0) and sys.version_info < (3,4)):
  print('*******************************************************************************')
  print('*        Python version 2.7 or 3.4+ is required to run ./configure            *')
  print('*           Try: "python3 ./configure" or "python2.7 ./configure"             *')
  print('*******************************************************************************')
  sys.exit(4)

exec(open(os.path.join(os.path.dirname(__file__), 'config', 'configure.py')).read())
