xref: /petsc/configure (revision b2d3fc2fff6b0b3e3ee1d03a12efee565de8bc1c)
1#!/bin/sh
2
3"true" '''\'
4for pyimpl in python3 python python2; do
5  which $pyimpl > /dev/null 2>&1
6  if [ $? -eq 0 ]; then
7    $pyimpl -c "import distutils.sysconfig" > /dev/null 2>&1
8    if [ $? -eq 0 ]; then
9      echo "Using $pyimpl for Python" && exec $pyimpl "$0" "$@"
10    else
11      echo "$pyimpl is missing distutils.sysconfig, Skipping..."
12    fi
13  fi
14done
15echo "Error! Could not locate Python (with distutils.sysconfig)! Please install and have python3, python, or python2 (with distutils.sysconfig) in PATH."
16echo "Or use: /path/to/valid/python configure $@"
17exit 127
18'''
19
20import sys, os
21
22if sys.version_info < (2,6) or (sys.version_info >= (3,0) and sys.version_info < (3,4)):
23  print('************************************************************************')
24  print('*      Python version 2.6+ or 3.4+ is required to run ./configure      *')
25  print('*         Try: "python2.7 ./configure" or "python3 ./configure"        *')
26  print('************************************************************************')
27  sys.exit(4)
28
29try:
30  import distutils.sysconfig
31except:
32  print('************************************************************************')
33  print('* '+sys.executable+' is missing "distutils.sysconfig" module! Its required to build PETSc **')
34  print('* Try installing (for ex: on Ubuntu) "python3-distutils"  or equivalent package that is compatible with '+sys.executable+' ***')
35  print('************************************************************************')
36  sys.exit(4)
37
38sys.path.insert(0, os.path.abspath('config'))
39import configure
40configure.petsc_configure([])
41