File: petscclone.py

package info (click to toggle)
petsc 3.23.1%2Bdfsg1-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 515,576 kB
  • sloc: ansic: 751,607; cpp: 51,542; python: 38,598; f90: 17,352; javascript: 3,493; makefile: 3,157; sh: 1,502; xml: 619; objc: 445; java: 13; csh: 1
file content (54 lines) | stat: -rw-r--r-- 2,809 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import config.base
import os
import re

def noCheck(command, status, output, error):
  ''' Do no check result'''
  return

class Configure(config.base.Configure):
  def __init__(self, framework):
    config.base.Configure.__init__(self, framework)
    self.isClone = 0
    return

  def setupDependencies(self, framework):
    self.sourceControl = framework.require('config.sourceControl',self)
    self.petscdir = framework.require('PETSc.options.petscdir', self)
    return

  def configureInstallationMethod(self):
    '''Determine if PETSc was obtained via git or a tarball'''
    if os.path.exists(os.path.join(self.petscdir.dir,'lib','petsc','bin','maint')):
      self.logPrint('lib/petsc/bin/maint exists. This appears to be a repository clone')
      self.isClone = 1
      if os.path.exists(os.path.join(self.petscdir.dir, '.git')):
        self.logPrint('.git directory exists')
        if hasattr(self.sourceControl,'git'):
          (o1, e1, s1) = self.executeShellCommand([self.sourceControl.git, 'describe', '--match=v*'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir)
          (o2, e2, s2) = self.executeShellCommand([self.sourceControl.git, 'log', '-1', '--pretty=format:%H'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir)
          (o3, e3, s3) = self.executeShellCommand([self.sourceControl.git, 'log', '-1', '--pretty=format:%ci'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir)
          (o4, e4, s4) = self.executeShellCommand([self.sourceControl.git, 'rev-parse', '--abbrev-ref', 'HEAD'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir)
          (o5, e5, s5) = self.executeShellCommand([self.sourceControl.git, 'status', '--short', '-uno'],checkCommand = noCheck, log = self.log, cwd=self.petscdir.dir)
          if s2 or s3 or s4:
            self.logPrintWarning('Git branch check is giving errors! Check configure.log for output from "git status"')
            self.logPrint(e5)
          else:
            if not o1: o1 = o2
            self.addDefine('VERSION_GIT','"'+o1+'"')
            self.addDefine('VERSION_DATE_GIT','"'+o3+'"')
            self.addDefine('VERSION_BRANCH_GIT','"'+o4+'"')
        else:
          self.logPrintWarning('PETSC_DIR appears to be a Git clone - but git is not found in PATH')
      else:
        self.logPrint('This repository clone is obtained as a tarball as no .git dirs exist')
    else:
      if False and os.path.exists(os.path.join(self.petscdir.dir, '.git')):
        raise RuntimeError('Your PETSc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again')
      else:
        self.logPrint('This is a tarball installation')
    return

  def configure(self):
    self.executeTest(self.configureInstallationMethod)
    return