1import config.base 2import os 3import re 4 5class Configure(config.base.Configure): 6 def __init__(self, framework): 7 config.base.Configure.__init__(self, framework) 8 return 9 10 def setupDependencies(self, framework): 11 self.sourceControl = framework.require('config.sourceControl',self) 12 self.petscdir = framework.require('PETSc.options.petscdir', self) 13 return 14 15 def configureInstallationMethod(self): 16 if os.path.exists(os.path.join(self.petscdir.dir,'bin','maint')): 17 self.logPrint('bin/maint exists. This appears to be a repository clone') 18 self.isClone = 1 19 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 20 self.logPrint('.git directory exists') 21 if hasattr(self.sourceControl,'git'): 22 VERSION_GIT = os.popen("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" describe").read() 23 if not VERSION_GIT: 24 raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 25 self.addDefine('VERSION_GIT','"'+VERSION_GIT.strip()+'"') 26 self.addDefine('VERSION_DATE_GIT','"'+os.popen("cd "+self.petscdir.dir+" && "+self.sourceControl.git+" log -1 --pretty=format:%ci").read()+'"') 27 self.addDefine('VERSION_BRANCH_GIT','"'+re.compile('\* (.*)\n').search(os.popen('cd '+self.petscdir.dir+' && '+self.sourceControl.git+' branch').read()).group(1)+'"') 28 else: 29 self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a Git clone - but git is not found in PATH********\n') 30 else: 31 self.logPrint('This repository clone is obtained as a tarball as no .git dirs exist') 32 else: 33 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 34 raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 35 else: 36 self.logPrint('This is a tarball installation') 37 self.isClone = 0 38 return 39 40 def configure(self): 41 self.executeTest(self.configureInstallationMethod) 42 return 43