1#!/usr/bin/env python 2import os 3import sys 4import commands 5 6 7if not hasattr(sys, 'version_info'): 8 raise RuntimeError('You must have Python version 2.2 or higher to run configure') 9 10def getarch(): 11 return os.path.basename(sys.argv[0])[10:] 12 13def petsc_configure(configure_options): 14 # Should be run from the toplevel or from ./config 15 pythonDir = os.path.abspath(os.path.join('..', 'python')) 16 if not os.path.exists(pythonDir): 17 pythonDir = os.path.abspath(os.path.join('python')) 18 if not os.path.exists(pythonDir): 19 raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 20 21 if not os.path.isdir('python/BuildSystem'): 22 print '''Could not locate BuildSystem in $PETSC_DIR/python. 23 Downloading it using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"''' 24 (status,output) = commands.getstatusoutput('bk clone bk://sidl.bkbits.net/BuildSystem python/BuildSystem') 25 26 sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem')) 27 sys.path.insert(0, pythonDir) 28 import config.framework 29 import PETSc.packages.update 30 31 32 framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0) 33 framework.argDB['CPPFLAGS'] = '' 34 framework.argDB['LIBS'] = '' 35 try: 36 framework.configure(out = sys.stdout) 37 except PETSc.packages.update.UpdateException, e: 38 return 1 39 except Exception, e: 40 import traceback 41 42 msg = 'CONFIGURATION FAILURE (see configure.log for full details):\n'+str(e)+'\n' 43 print msg 44 if hasattr(framework, 'log'): 45 framework.log.write(msg) 46 traceback.print_tb(sys.exc_info()[2], file = framework.log) 47 sys.exit(1) 48 framework.storeSubstitutions(framework.argDB) 49 return 0 50 51if __name__ == '__main__': 52 for opt in sys.argv[1:]: 53 if opt.startswith('--prefix') or opt.startswith('-prefix'): 54 print '=====================================================================\nPETSc does NOT support the --prefix options. All installs are done in-place.\nMove your petsc directory to the location you wish it installed, before running configure\n' 55 sys.exit(1) 56 if petsc_configure([]): 57 print 'Updated the source code, rerunning configure' 58 petsc_configure([]) 59