xref: /petsc/config/configure.py (revision 70ae1cd54c32a8fabb150004e53e6d72bb9a1b24)
15d5a5a7bSMatthew Knepley#!/usr/bin/env python
25d5a5a7bSMatthew Knepleyimport os
35d5a5a7bSMatthew Knepleyimport sys
45d5a5a7bSMatthew Knepley
52fb34ac0SMatthew Knepleyif not hasattr(sys, 'version_info'):
62fb34ac0SMatthew Knepley  raise RuntimeError('You must have Python version 2.2 or higher to run configure')
72fb34ac0SMatthew Knepley
85d5a5a7bSMatthew Knepleydef petsc_configure(configure_options):
95d5a5a7bSMatthew Knepley  # Should be run from the toplevel or from ./config
105d5a5a7bSMatthew Knepley  pythonDir = os.path.abspath(os.path.join('..', 'python'))
115d5a5a7bSMatthew Knepley  if not os.path.exists(pythonDir):
125d5a5a7bSMatthew Knepley    pythonDir = os.path.abspath(os.path.join('python'))
135d5a5a7bSMatthew Knepley    if not os.path.exists(pythonDir):
145d5a5a7bSMatthew Knepley      raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
155d5a5a7bSMatthew Knepley  sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem'))
165d5a5a7bSMatthew Knepley  sys.path.insert(0, pythonDir)
175d5a5a7bSMatthew Knepley  try:
185d5a5a7bSMatthew Knepley    import config.framework
195d5a5a7bSMatthew Knepley  except ImportError:
205d5a5a7bSMatthew Knepley    sys.exit('''Could not locate BuildSystem in $PETSC_DIR/python.
215d5a5a7bSMatthew Knepley    You can download this package using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"''')
222c4e8892SMatthew Knepley  framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0)
235d5a5a7bSMatthew Knepley  framework.argDB['CPPFLAGS'] = ''
245d5a5a7bSMatthew Knepley  framework.argDB['LIBS'] = ''
25*70ae1cd5SMatthew Knepley  try:
265d5a5a7bSMatthew Knepley    framework.configure()
27*70ae1cd5SMatthew Knepley  except Exception, e:
28*70ae1cd5SMatthew Knepley    import traceback
29*70ae1cd5SMatthew Knepley
30*70ae1cd5SMatthew Knepley    msg = 'CONFIGURATION FAILURE:\n'+str(e)+'\n'
31*70ae1cd5SMatthew Knepley    print msg
32*70ae1cd5SMatthew Knepley    framework.log.write(msg)
33*70ae1cd5SMatthew Knepley    traceback.print_tb(sys.exc_info()[2], file = framework.log)
34*70ae1cd5SMatthew Knepley    sys.exit(1)
35358ebc22SMatthew Knepley  framework.storeSubstitutions(framework.argDB)
365d5a5a7bSMatthew Knepley
375d5a5a7bSMatthew Knepleyif __name__ == '__main__':
385d5a5a7bSMatthew Knepley  petsc_configure([])
39