Skip to content

Commit 70c1ca3

Browse files
committed
Merge branch 'release'
2 parents ea2c7d1 + 284bb5c commit 70c1ca3

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

config/install.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,11 @@ def runcopy(self):
584584

585585
def runfix(self):
586586
self.fixConf()
587-
if os.environ.get('PEP517_BUILD_BACKEND'):
587+
using_build_backend = any(
588+
os.environ.get(prefix + '_BUILD_BACKEND')
589+
for prefix in ('_PYPROJECT_HOOKS', 'PEP517')
590+
)
591+
if using_build_backend:
588592
self.fixPythonWheel()
589593
return
590594

config/packages/slepc.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def Process(self,slepcconf,slepcvars,slepcrules,slepc,petsc,archdir=''):
5555
self.AddDefine(slepcconf,'PETSC_ARCH',petsc.arch)
5656
self.AddDefine(slepcconf,'DIR',slepc.dir)
5757
self.AddDefine(slepcconf,'LIB_DIR',os.path.join(slepc.prefixdir,'lib'))
58-
if slepc.isrepo:
58+
if slepc.isrepo and slepc.gitrev != 'unknown':
5959
self.AddDefine(slepcconf,'VERSION_GIT',slepc.gitrev)
6060
self.AddDefine(slepcconf,'VERSION_DATE_GIT',slepc.gitdate)
6161
self.AddDefine(slepcconf,'VERSION_BRANCH_GIT',slepc.branch)
@@ -69,7 +69,7 @@ def Process(self,slepcconf,slepcvars,slepcrules,slepc,petsc,archdir=''):
6969

7070
def ShowInfo(self):
7171
self.log.Println('\nSLEPc directory:\n '+self.dir)
72-
if self.isrepo:
72+
if self.isrepo and self.gitrev != 'unknown':
7373
self.log.Println(' It is a git repository on branch: '+self.branch)
7474
if self.isinstall:
7575
self.log.Println('SLEPc prefix directory:\n '+self.prefixdir)
@@ -110,28 +110,36 @@ def LoadVersion(self):
110110
# Check whether this is a working copy of the repository
111111
self.isrepo = False
112112
if os.path.exists(os.path.join(self.dir,'src','docs')):
113+
self.log.write('This appears to be a repository clone - src/docs exists')
113114
self.isrepo = True
114-
(status, output) = self.RunCommand('git help')
115-
if status:
116-
self.log.Warn('SLEPC_DIR appears to be a git working copy, but git is not found in PATH')
117-
self.gitrev = 'unknown'
118-
self.gitdate = 'unknown'
119-
self.branch = 'unknown'
120-
else:
121-
(status, output) = self.RunCommand('git rev-parse')
115+
if os.path.exists(os.path.join(self.dir,'.git')):
116+
self.log.write('.git directory exists')
117+
(status, output) = self.RunCommand('git help')
122118
if status:
123-
self.log.Warn('SLEPC_DIR appears to be a git working copy, but the .git folder is missing')
119+
self.log.Warn('SLEPC_DIR appears to be a git working copy, but git is not found in PATH')
124120
self.gitrev = 'unknown'
125121
self.gitdate = 'unknown'
126122
self.branch = 'unknown'
127123
else:
128-
(status, self.gitrev) = self.RunCommand('git describe')
124+
(status, self.gitrev) = self.RunCommand('git describe --match=v*')
129125
if not self.gitrev:
130126
(status, self.gitrev) = self.RunCommand('git log -1 --pretty=format:%H')
131127
(status, self.gitdate) = self.RunCommand('git log -1 --pretty=format:%ci')
132128
(status, self.branch) = self.RunCommand('git describe --contains --all HEAD')
133129
if status:
134-
self.branch = 'unknown'
130+
(status, self.branch) = self.RunCommand('git rev-parse --abbrev-ref HEAD')
131+
if status:
132+
self.branch = 'unknown'
133+
else:
134+
self.log.write('This repository clone is obtained as a tarball as no .git dirs exist')
135+
self.gitrev = 'unknown'
136+
self.gitdate = 'unknown'
137+
self.branch = 'unknown'
138+
else:
139+
if os.path.exists(os.path.join(self.dir,'.git')):
140+
self.log.Exit('Your SLEPc source tree is broken. Use "git status" to check, or remove the entire directory and start all over again')
141+
else:
142+
self.log.write('This is a tarball installation')
135143

136144
def CreateFile(self,basedir,fname):
137145
''' Create file basedir/fname and return path string '''

setup.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,32 @@ def config(prefix, dry_run=False):
156156
status = os.system(" ".join(command))
157157
if status != 0:
158158
raise RuntimeError(status)
159+
# Fix SLEPc configuration
160+
using_build_backend = any(
161+
os.environ.get(prefix + '_BUILD_BACKEND')
162+
for prefix in ('_PYPROJECT_HOOKS', 'PEP517')
163+
)
164+
if using_build_backend:
165+
pdir = os.environ['SLEPC_DIR']
166+
parch = os.environ['PETSC_ARCH']
167+
if not parch:
168+
makefile = os.path.join(pdir, 'lib', 'slepc', 'conf', 'slepcvariables')
169+
with open(makefile, 'r') as mfile:
170+
contents = mfile.readlines()
171+
for line in contents:
172+
if line.startswith('PETSC_ARCH'):
173+
parch = line.split('=')[1].strip()
174+
break
175+
include = os.path.join(pdir, parch, 'include')
176+
for filename in (
177+
'slepcconf.h',
178+
):
179+
filename = os.path.join(include, filename)
180+
with open(filename, 'r') as old_fh:
181+
contents = old_fh.read()
182+
contents = contents.replace(prefix, '${SLEPC_DIR}')
183+
with open(filename, 'w') as new_fh:
184+
new_fh.write(contents)
159185

160186

161187
def build(dry_run=False):

0 commit comments

Comments
 (0)