Skip to content

Commit 35e54f5

Browse files
committed
misc: Edit petsc internals.py
1 parent a7fedd0 commit 35e54f5

1 file changed

Lines changed: 5 additions & 27 deletions

File tree

devito/petsc/internals.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import ctypes
33
from pathlib import Path
44

5-
from petsctools import get_petscvariables
5+
from petsctools import get_petscvariables, MissingPetscException
66

77
from devito.tools import memoized_func
88

@@ -46,32 +46,10 @@ def core_metadata():
4646
}
4747

4848

49-
@memoized_func
50-
def get_petsc_variables():
51-
"""
52-
Taken from https://www.firedrakeproject.org/_modules/firedrake/petsc.html
53-
Get a dict of PETSc environment variables from the file:
54-
$PETSC_DIR/$PETSC_ARCH/lib/petsc/conf/petscvariables
55-
"""
56-
try:
57-
petsc_dir = get_petsc_dir()
58-
except PetscOSError:
59-
petsc_variables = {}
60-
else:
61-
path = [petsc_dir[-1], 'lib', 'petsc', 'conf', 'petscvariables']
62-
variables_path = Path(*path)
63-
64-
with open(variables_path) as fh:
65-
# Split lines on first '=' (assignment)
66-
splitlines = (line.split("=", maxsplit=1) for line in fh.readlines())
67-
petsc_variables = {k.strip(): v.strip() for k, v in splitlines}
68-
69-
return petsc_variables
70-
71-
72-
# petsc_variables = get_petsc_variables()
73-
petsc_variables = get_petscvariables()
74-
# TODO: Use petsctools get_petscvariables() instead?
49+
try:
50+
petsc_variables = get_petscvariables()
51+
except MissingPetscException:
52+
petsc_variables = {}
7553

7654

7755
def get_petsc_type_mappings():

0 commit comments

Comments
 (0)