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 34 35 framework = config.framework.Framework(sys.argv[1:]+['-configModules=PETSc.Configure']+configure_options, loadArgDB = 0) 36 framework.argDB['CPPFLAGS'] = '' 37 framework.argDB['LIBS'] = '' 38 try: 39 framework.configure(out = sys.stdout) 40 except Exception, e: 41 import traceback 42 43 msg = 'CONFIGURATION FAILURE (see configure.log for full details):\n'+str(e)+'\n' 44 print msg 45 if hasattr(framework, 'log'): 46 framework.log.write(msg) 47 traceback.print_tb(sys.exc_info()[2], file = framework.log) 48 sys.exit(1) 49 framework.storeSubstitutions(framework.argDB) 50 return 0 51 52if __name__ == '__main__': 53 for opt in sys.argv[1:]: 54 if opt.startswith('--prefix') or opt.startswith('-prefix'): 55 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' 56 sys.exit(1) 57 petsc_configure([]) 58 59