@@ -29,15 +29,32 @@ def _find_library() -> ctypes.CDLL:
29
29
30
30
# On Windows, ensure OpenBLAS and its dependencies can be found
31
31
if os .name == "nt" :
32
- # Add MSYS2 bin directory to DLL search path
33
- msys2_bin = Path ("C:/msys64/mingw64/bin" )
34
- if msys2_bin .exists ():
35
- os .add_dll_directory (str (msys2_bin )) # type: ignore[attr-defined]
36
- try :
37
- # Load OpenBLAS directly from MSYS2
38
- ctypes .CDLL (str (msys2_bin / "libopenblas.dll" ))
39
- except OSError as e :
40
- print (f"Warning: Failed to load OpenBLAS: { e } " )
32
+ # Common locations for OpenBLAS on Windows
33
+ possible_blas_paths = [
34
+ Path ("C:/msys64/mingw64/bin" ), # MSYS2 MinGW64
35
+ Path ("C:/msys64/ucrt64/bin" ), # MSYS2 UCRT64
36
+ Path ("C:/msys64/clang64/bin" ), # MSYS2 Clang64
37
+ Path (os .environ .get ("OPENBLAS_PATH" , "" )).parent
38
+ / "bin" , # Custom installation
39
+ Path (os .environ .get ("CONDA_PREFIX" , "" )) / "Library" / "bin" , # Conda
40
+ ]
41
+
42
+ # Try to find and load OpenBLAS from any of these locations
43
+ blas_loaded = False
44
+ for path in possible_blas_paths :
45
+ if path .exists ():
46
+ try :
47
+ os .add_dll_directory (str (path )) # type: ignore[attr-defined]
48
+ openblas_path = path / "libopenblas.dll"
49
+ if openblas_path .exists ():
50
+ ctypes .CDLL (str (openblas_path ))
51
+ blas_loaded = True
52
+ break
53
+ except OSError as e :
54
+ print (f"Warning: Failed to load OpenBLAS from { path } : { e } " )
55
+
56
+ if not blas_loaded :
57
+ print ("Warning: Could not load OpenBLAS from any known location" )
41
58
42
59
# Try all possible library names
43
60
lib_names = [
0 commit comments