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