1import config.base 2import os 3import re 4 5def noCheck(command, status, output, error): 6 ''' Do no check result''' 7 return 8 9class Configure(config.base.Configure): 10 def __init__(self, framework): 11 config.base.Configure.__init__(self, framework) 12 self.isClone = 0 13 return 14 15 def setupDependencies(self, framework): 16 self.sourceControl = framework.require('config.sourceControl',self) 17 self.petscdir = framework.require('PETSc.options.petscdir', self) 18 return 19 20 def configureInstallationMethod(self): 21 if os.path.exists(os.path.join(self.petscdir.dir,'lib','petsc','bin','maint')): 22 self.logPrint('lib/petsc/bin/maint exists. This appears to be a repository clone') 23 self.isClone = 1 24 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 25 self.logPrint('.git directory exists') 26 if hasattr(self.sourceControl,'git'): 27 (o1, e1, s1) = self.executeShellCommand([self.sourceControl.git, 'describe', '--match=v*'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir) 28 (o2, e2, s2) = self.executeShellCommand([self.sourceControl.git, 'log', '-1', '--pretty=format:%H'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir) 29 (o3, e3, s3) = self.executeShellCommand([self.sourceControl.git, 'log', '-1', '--pretty=format:%ci'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir) 30 (o4, e4, s4) = self.executeShellCommand([self.sourceControl.git, 'rev-parse', '--abbrev-ref', 'HEAD'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir) 31 if s2 or s3 or s4: 32 self.logPrintBox('***** WARNING: Git branch check is giving errors! Checking the repo with "git status"') 33 (o5, e5, s5) = self.executeShellCommand([self.sourceControl.git, 'status'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir) 34 self.logPrint(e5) 35 else: 36 if not o1: o1 = o2 37 self.addDefine('VERSION_GIT','"'+o1+'"') 38 self.addDefine('VERSION_DATE_GIT','"'+o3+'"') 39 self.addDefine('VERSION_BRANCH_GIT','"'+o4+'"') 40 else: 41 self.logPrintBox('\n*****WARNING: PETSC_DIR appears to be a Git clone - but git is not found in PATH********\n') 42 else: 43 self.logPrint('This repository clone is obtained as a tarball as no .git dirs exist') 44 else: 45 if os.path.exists(os.path.join(self.petscdir.dir, '.git')): 46 raise RuntimeError('Your petsc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again') 47 else: 48 self.logPrint('This is a tarball installation') 49 return 50 51 def configure(self): 52 self.executeTest(self.configureInstallationMethod) 53 return 54