Skip to content

Commit 4cec942

Browse files
committed
Remove usage of deprecated pkgutil.get_loader
1 parent 3c9d042 commit 4cec942

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/ansys/dpf/core/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib.util
12
import os
23

34
try:
@@ -11,18 +12,16 @@
1112
USER_DATA_PATH = None
1213
LOCAL_DOWNLOADED_EXAMPLES_PATH = None
1314
try:
14-
import pkgutil
15-
16-
spec = pkgutil.get_loader(__name__)
17-
USER_DATA_PATH = os.path.dirname(spec.get_filename(__name__))
15+
spec = importlib.util.find_spec(name=__name__)
16+
USER_DATA_PATH = os.path.dirname(spec.origin)
1817
if not os.path.exists(USER_DATA_PATH): # pragma: no cover
1918
os.makedirs(USER_DATA_PATH)
2019

2120
LOCAL_DOWNLOADED_EXAMPLES_PATH = os.path.join(USER_DATA_PATH, "examples")
2221
if not os.path.exists(LOCAL_DOWNLOADED_EXAMPLES_PATH): # pragma: no cover
2322
os.makedirs(LOCAL_DOWNLOADED_EXAMPLES_PATH)
24-
except: # pragma: no cover
25-
pass
23+
except Exception as e: # pragma: no cover
24+
raise e
2625

2726
installed = [d.metadata["Name"] for d in importlib_metadata.distributions()]
2827
check_for = ["ansys-dpf-gatebin", "ansys-dpf-gate", "ansys-grpc-dpf"]

0 commit comments

Comments
 (0)