xref: /petsc/config/configure.py (revision 43c7788619fb8ccd4e96726747793c52d1a3cd69)
15d5a5a7bSMatthew Knepley#!/usr/bin/env python
25d5a5a7bSMatthew Knepleyimport os
35d5a5a7bSMatthew Knepleyimport sys
44f8a5b45SBarry Smithimport commands
55d5a5a7bSMatthew Knepley
62fb34ac0SMatthew Knepleyif not hasattr(sys, 'version_info'):
72fb34ac0SMatthew Knepley  raise RuntimeError('You must have Python version 2.2 or higher to run configure')
82fb34ac0SMatthew Knepley
95d5a5a7bSMatthew Knepleydef petsc_configure(configure_options):
105d5a5a7bSMatthew Knepley  # Should be run from the toplevel or from ./config
115d5a5a7bSMatthew Knepley  pythonDir = os.path.abspath(os.path.join('..', 'python'))
125d5a5a7bSMatthew Knepley  if not os.path.exists(pythonDir):
135d5a5a7bSMatthew Knepley    pythonDir = os.path.abspath(os.path.join('python'))
145d5a5a7bSMatthew Knepley    if not os.path.exists(pythonDir):
155d5a5a7bSMatthew Knepley      raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
164f8a5b45SBarry Smith
174f8a5b45SBarry Smith  if not os.path.isdir('python/BuildSystem'):
184f8a5b45SBarry Smith    print '''Could not locate BuildSystem in $PETSC_DIR/python.
194f8a5b45SBarry Smith    Downloading it using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"'''
204f8a5b45SBarry Smith    (status,output) = commands.getstatusoutput('bk clone bk://sidl.bkbits.net/BuildSystem python/BuildSystem')
214f8a5b45SBarry Smith
225d5a5a7bSMatthew Knepley  sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem'))
235d5a5a7bSMatthew Knepley  sys.path.insert(0, pythonDir)
245d5a5a7bSMatthew Knepley  import config.framework
254f8a5b45SBarry Smith
262c4e8892SMatthew Knepley  framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0)
275d5a5a7bSMatthew Knepley  framework.argDB['CPPFLAGS'] = ''
285d5a5a7bSMatthew Knepley  framework.argDB['LIBS'] = ''
2970ae1cd5SMatthew Knepley  try:
303e4f49c0SMatthew Knepley    framework.configure(out = sys.stdout)
3170ae1cd5SMatthew Knepley  except Exception, e:
3270ae1cd5SMatthew Knepley    import traceback
3370ae1cd5SMatthew Knepley
34*43c77886SBarry Smith    msg = 'CONFIGURATION FAILURE (see configure.log for full details):\n'+str(e)+'\n'
3570ae1cd5SMatthew Knepley    print msg
363bd70c20SMatthew Knepley    if hasattr(framework, 'log'):
3770ae1cd5SMatthew Knepley      framework.log.write(msg)
3870ae1cd5SMatthew Knepley      traceback.print_tb(sys.exc_info()[2], file = framework.log)
3970ae1cd5SMatthew Knepley    sys.exit(1)
40358ebc22SMatthew Knepley  framework.storeSubstitutions(framework.argDB)
415d5a5a7bSMatthew Knepley
425d5a5a7bSMatthew Knepleyif __name__ == '__main__':
435d5a5a7bSMatthew Knepley  petsc_configure([])
44