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 try: 26 framework.configure() 27 except Exception, e: 28 import traceback 29 30 msg = 'CONFIGURATION FAILURE:\n'+str(e)+'\n' 31 print msg 32 framework.log.write(msg) 33 traceback.print_tb(sys.exc_info()[2], file = framework.log) 34 sys.exit(1) 35 framework.storeSubstitutions(framework.argDB) 36 37if __name__ == '__main__': 38 petsc_configure([]) 39