1#!/usr/bin/env python 2import os 3import sys 4import commands 5 6if not hasattr(sys, 'version_info'): 7 raise RuntimeError('You must have Python version 2.2 or higher to run configure') 8 9def petsc_configure(configure_options): 10 # Should be run from the toplevel or from ./config 11 pythonDir = os.path.abspath(os.path.join('..', 'python')) 12 if not os.path.exists(pythonDir): 13 pythonDir = os.path.abspath(os.path.join('python')) 14 if not os.path.exists(pythonDir): 15 raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 16 17 if not os.path.isdir('python/BuildSystem'): 18 print '''Could not locate BuildSystem in $PETSC_DIR/python. 19 Downloading it using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"''' 20 (status,output) = commands.getstatusoutput('bk clone bk://sidl.bkbits.net/BuildSystem python/BuildSystem') 21 22 sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem')) 23 sys.path.insert(0, pythonDir) 24 import config.framework 25 26 framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0) 27 framework.argDB['CPPFLAGS'] = '' 28 framework.argDB['LIBS'] = '' 29 try: 30 framework.configure() 31 except Exception, e: 32 import traceback 33 34 msg = 'CONFIGURATION FAILURE:\n'+str(e)+'\n' 35 print msg 36 framework.log.write(msg) 37 traceback.print_tb(sys.exc_info()[2], file = framework.log) 38 sys.exit(1) 39 framework.storeSubstitutions(framework.argDB) 40 41if __name__ == '__main__': 42 petsc_configure([]) 43