Skip to content

Commit 8ce35dd

Browse files
authored
Add ImportError if ansys-dpf-gate, ansys-dpf-gatebin or ansys-grpc-dpf is detected as installed in the current Python environment. (#1418)
Signed-off-by: paul.profizi <[email protected]>
1 parent 1e95849 commit 8ce35dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ansys/dpf/core/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pkg_resources
23

34
from ansys.dpf.core._version import __version__
45

@@ -20,6 +21,14 @@
2021
except: # pragma: no cover
2122
pass
2223

24+
installed = [d.project_name for d in pkg_resources.working_set]
25+
check_for = ["ansys-dpf-gatebin", "ansys-dpf-gate", "ansys-grpc-dpf"]
26+
if any([c in installed for c in check_for]):
27+
raise ImportError(f"Error during import of ansys-dpf-core:\n"
28+
f"detected one of {check_for} installed. "
29+
f"The current version of ansys-dpf-core requires uninstalling these previous "
30+
f"dependencies to run correctly.")
31+
2332
from ansys.dpf.core.dpf_operator import Operator, Config
2433
from ansys.dpf.core.model import Model
2534
from ansys.dpf.core.field import Field, FieldDefinition

0 commit comments

Comments
 (0)