@@ -126,8 +126,15 @@ def _load_core() -> CDLL:
126
126
Returns: DLL/SO object
127
127
128
128
"""
129
- if "CONDA_PREFIX" in os .environ :
130
- # if conda environment, use the dll file from the conda environment
129
+ # first try to find the DLL local
130
+ if platform .system () == "Windows" :
131
+ dll_file = "_power_grid_core.dll"
132
+ else :
133
+ dll_file = "_power_grid_core.so"
134
+ dll_path = Path (__file__ ).parent / dll_file
135
+
136
+ # if local DLL is not found, try to find the DLL from conda environment
137
+ if (not dll_path .exists ()) and ("CONDA_PREFIX" in os .environ ):
131
138
if platform .system () == "Windows" :
132
139
dll_file = "power_grid_model_c.dll"
133
140
elif platform .system () == "Darwin" :
@@ -137,15 +144,9 @@ def _load_core() -> CDLL:
137
144
else :
138
145
raise NotImplementedError (f"Unsupported platform: { platform .system ()} " )
139
146
# the dll will be found through conda environment
140
- dll_path = dll_file
141
- else :
142
- # else use the dll file from the current directory
143
- if platform .system () == "Windows" :
144
- dll_file = "_power_grid_core.dll"
145
- else :
146
- dll_file = "_power_grid_core.so"
147
- dll_path = str (Path (__file__ ).parent / dll_file )
148
- cdll = CDLL (dll_path )
147
+ dll_path = Path (dll_file )
148
+
149
+ cdll = CDLL (str (dll_path ))
149
150
# assign return types
150
151
# handle
151
152
cdll .PGM_create_handle .argtypes = []
0 commit comments