Skip to content

Commit 0f2f664

Browse files
committed
misc: Add try except except to petsctools import with get_petscvariables
1 parent cd255de commit 0f2f664

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

devito/petsc/config.py

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

5-
from petsctools import get_petscvariables, MissingPetscException
5+
try:
6+
from petsctools import get_petscvariables, MissingPetscException
7+
petsc_variables = get_petscvariables()
8+
except ImportError:
9+
petsc_variables = {}
10+
except MissingPetscException:
11+
petsc_variables = {}
612

713
from devito.tools import memoized_func
814

@@ -46,12 +52,6 @@ def core_metadata():
4652
}
4753

4854

49-
try:
50-
petsc_variables = get_petscvariables()
51-
except MissingPetscException:
52-
petsc_variables = {}
53-
54-
5555
def get_petsc_type_mappings():
5656
try:
5757
petsc_precision = petsc_variables['PETSC_PRECISION']

0 commit comments

Comments
 (0)