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(): 16 import configure 17 configure.petsc_configure(['--with-fc=0','--with-mpi=0','--with-shared-libraries']) 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 import os 37 install.Installer(sys.argv[1:]+['--destDir='+prefix,'--prefix='+prefix]).run() 38 # temporary hack - delete log files created by BuildSystem - when 'sudo make install' is invoked 39 delfiles=['RDict.db','RDict.log','build.log','default.log','build.log.bkp','default.log.bkp'] 40 for delfile in delfiles: 41 if os.path.exists(delfile) and (os.stat(delfile).st_uid==0): 42 os.remove(delfile) 43 44if __name__ == '__main__': 45 setup() 46 configure() 47 build() 48 install("/Users/barrysmith/tmp/petsc-install") 49# ----------------------------------------------------------------------------- 50