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 if os.path.basename(sys.argv[0]).startswith('configure'): return '' 12 else: return os.path.basename(sys.argv[0])[:-3] 13 14def petsc_configure(configure_options): 15 # use the name of the config/configure_arch.py to determine the arch 16 if getarch(): configure_options.append('-PETSC_ARCH='+getarch()) 17 18 # Should be run from the toplevel or from ./config 19 pythonDir = os.path.abspath(os.path.join('..', 'python')) 20 if not os.path.exists(pythonDir): 21 pythonDir = os.path.abspath(os.path.join('python')) 22 if not os.path.exists(pythonDir): 23 raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 24 25 if not os.path.isdir('python/BuildSystem'): 26 print '''Could not locate BuildSystem in $PETSC_DIR/python. 27 Downloading it using "bk clone bk://sidl.bkbits.net/BuildSystem $PETSC_DIR/python/BuildSystem"''' 28 (status,output) = commands.getstatusoutput('bk clone bk://sidl.bkbits.net/BuildSystem python/BuildSystem') 29 30 sys.path.insert(0, os.path.join(pythonDir, 'BuildSystem')) 31 sys.path.insert(0, pythonDir) 32 import config.framework 33 import PETSc.packages.update 34 35 36 framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0) 37 framework.argDB['CPPFLAGS'] = '' 38 framework.argDB['LIBS'] = '' 39 try: 40 framework.configure(out = sys.stdout) 41 except PETSc.packages.update.UpdateException, e: 42 return 1 43 except Exception, e: 44 import traceback 45 46 msg = 'CONFIGURATION FAILURE (see configure.log for full details):\n'+str(e)+'\n' 47 print msg 48 if hasattr(framework, 'log'): 49 framework.log.write(msg) 50 traceback.print_tb(sys.exc_info()[2], file = framework.log) 51 sys.exit(1) 52 framework.storeSubstitutions(framework.argDB) 53 return 0 54 55if __name__ == '__main__': 56 for opt in sys.argv[1:]: 57 if opt.startswith('--prefix') or opt.startswith('-prefix'): 58 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' 59 sys.exit(1) 60 if petsc_configure([]): 61 print 'Updated the source code, rerunning configure' 62 petsc_configure([]) 63