19d310bb7SBarry Smithimport config.base 29d310bb7SBarry Smithimport os 39d310bb7SBarry Smithimport re 49d310bb7SBarry Smith 59d310bb7SBarry Smithclass Configure(config.base.Configure): 69d310bb7SBarry Smith def __init__(self, framework): 79d310bb7SBarry Smith config.base.Configure.__init__(self, framework) 89d310bb7SBarry Smith return 99d310bb7SBarry Smith 109d310bb7SBarry Smith def setupDependencies(self, framework): 119d310bb7SBarry Smith self.sourceControl = framework.require('config.sourceControl',self) 129d310bb7SBarry Smith self.petscdir = framework.require('PETSc.options.petscdir', self) 139d310bb7SBarry Smith return 149d310bb7SBarry Smith 159d310bb7SBarry Smith def configureInstallationMethod(self): 169d310bb7SBarry Smith if os.path.exists(os.path.join(self.petscdir.dir,'bin','maint')): 179d310bb7SBarry Smith self.logPrint('bin/maint exists. This appears to be a repository clone') 189d310bb7SBarry Smith self.isClone = 1 199d310bb7SBarry Smith if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 20*6e709e5aSBarry Smith self.logPrint('.git directory exists') 219d310bb7SBarry Smith if hasattr(self.sourceControl,'git'): 22*6e709e5aSBarry Smith VERSION_GIT = os.popen("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" describe").read() 23*6e709e5aSBarry Smith if not VERSION_GIT: 24*6e709e5aSBarry Smith raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 25*6e709e5aSBarry Smith self.addDefine('VERSION_GIT','"'+VERSION_GIT.strip()+'"') 269d310bb7SBarry Smith self.addDefine('VERSION_DATE_GIT','"'+os.popen("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%ci").read()+'"') 279d310bb7SBarry Smith self.addDefine('VERSION_BRANCH_GIT','"'+re.compile('\* (.*)\n').search(os.popen('cd '+self.petscdir.dir+' && '+self.sourceControl.git+' branch').read()).group(1)+'"') 289d310bb7SBarry Smith else: 299d310bb7SBarry Smith self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a Git clone - but git is not found in PATH********\n') 309d310bb7SBarry Smith else: 31*6e709e5aSBarry Smith self.logPrint('This repository clone is obtained as a tarball as no .git dirs exist') 329d310bb7SBarry Smith else: 33*6e709e5aSBarry Smith if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 349d310bb7SBarry Smith raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 359d310bb7SBarry Smith else: 369d310bb7SBarry Smith self.logPrint('This is a tarball installation') 379d310bb7SBarry Smith self.isClone = 0 389d310bb7SBarry Smith return 399d310bb7SBarry Smith 409d310bb7SBarry Smith def configure(self): 419d310bb7SBarry Smith self.executeTest(self.configureInstallationMethod) 429d310bb7SBarry Smith return 43