-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.py
More file actions
33 lines (29 loc) · 1.46 KB
/
Copy pathbootstrap.py
File metadata and controls
33 lines (29 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
r"""Make `import devsim` work regardless of shell environment.
Windows + pip MKL: the `mkl` wheel installs mkl_rt.<N>.dll into
<python>\Library\bin, a directory Windows does not search by default, so
DEVSIM's loader never sees it and falls back to the (absent)
libopenblas/liblapack/libblas trio -> "Error loading math libraries".
PATH is what fixes it, and specifically PATH: DEVSIM's LoadBlasDLL calls plain
LoadLibrary (src/math/BlasHeaders.cc), which searches PATH but ignores the
AddDllDirectory list. Measured: add_dll_directory alone -> import still fails;
PATH alone -> 'Intel MKL with PARDISO LOADED'. The add_dll_directory call below
is belt-and-braces for anything loaded the Python 3.8+ way; it is not what
makes DEVSIM work.
DEVSIM_MATH_LIBS is deliberately NOT set. DEVSIM 2.8-2.10 probe mkl_rt.1.dll ..
mkl_rt.5.dll by name, so the 2026 wheel's mkl_rt.3.dll is found on its own;
setting the variable takes a different code path that loads only what it names
and skips the MKL probe entirely. See devsim/devsim#159.
"""
import os
import sys
from pathlib import Path
def import_devsim():
if sys.platform == "win32":
libbin = Path(sys.prefix) / "Library" / "bin"
if libbin.is_dir():
os.environ["PATH"] = str(libbin) + os.pathsep + \
os.environ.get("PATH", "")
os.add_dll_directory(str(libbin))
# Linux/macOS: DEVSIM's default search (libmkl_rt.so, libopenblas.so) works as-is
import devsim
return devsim