xref: /petsc/config/configure.py (revision 63b9fa5e258ef37d5bcff491ebacde33f30ed49b)
1#!/usr/bin/env python
2import os
3import sys
4
5if not hasattr(sys, 'version_info'):
6  raise RuntimeError('You must have Python version 2.2 or higher to run configure')
7
8def petsc_configure(configure_options):
9  # Should be run from the toplevel or from ./config
10  pythonDir = os.path.abspath(os.path.join('..', 'python'))
11  if not os.path.exists(pythonDir):
12    pythonDir = os.path.abspath(os.path.join('python'))
13    if not os.path.exists(pythonDir):
14      raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
15  sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem'))
16  sys.path.insert(0, pythonDir)
17  try:
18    import config.framework
19  except ImportError:
20    sys.exit('''Could not locate BuildSystem in $PETSC_DIR/python.
21    You can download this package using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"''')
22  framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0)
23  framework.argDB['CPPFLAGS'] = ''
24  framework.argDB['LIBS'] = ''
25  framework.configure()
26  framework.storeSubstitutions(framework.argDB)
27
28if __name__ == '__main__':
29  petsc_configure([])
30