1#!/usr/bin/env python 2 3""" 4 Make PETSc appear to be a Python package; so it can be depended on by petsc4py 5""" 6 7def setup(): 8 import os,sys 9 os.environ['PETSC_DIR'] = os.path.abspath(os.getcwd()) 10 os.environ['PETSC_ARCH'] = 'arch-python-test' 11 os.chdir(os.environ['PETSC_DIR']) 12 sys.path.insert(0,os.path.join(os.environ['PETSC_DIR'],'config')) 13 return 14 15def configure(prefix): 16 import configure 17 configure.petsc_configure(['--with-fc=0','--with-mpi=0','--with-shared-libraries','--prefix='+prefix]) 18 # force save of configure information, or build will fail to load it 19 20 # work around bug in logger.Logger that when log file is closed Logger.defaultLog still points to something 21 import logger 22 logger.Logger.defaultLog = None 23 return 24 25def build(): 26 import builder 27 builder.PETScMaker().run() 28 # work around bug in logger.Logger that when log file is closed Logger.defaultLog still points to something 29 import logger 30 logger.Logger.defaultLog = None 31 return 32 33def install(prefix): 34 import install 35 import sys 36 install.Installer(sys.argv[1:]+['--destDir='+prefix]).run() 37 # temporary hack - delete log files created by BuildSystem - when 'sudo make install' is invoked 38 delfiles=['RDict.db','RDict.log','build.log','default.log','build.log.bkp','default.log.bkp'] 39 for delfile in delfiles: 40 if os.path.exists(delfile) and (os.stat(delfile).st_uid==0): 41 os.remove(delfile) 42 43if __name__ == '__main__': 44 setup() 45 configure("/Users/barrysmith/tmp/petsc-install") 46 build() 47 install("/Users/barrysmith/tmp/petsc-install") 48# ----------------------------------------------------------------------------- 49