Skip to content

Commit facfbcc

Browse files
committed
Prepare for upstream reformat in mkl-service
1 parent d14f83b commit facfbcc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

patches/mkl-service/dll_directory.patch

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
diff --git a/mkl/__init__.py b/mkl/__init__.py
2-
index d2fefc7..47f35b9 100644
2+
index 4a86a64..1ebe93a 100644
33
--- a/mkl/__init__.py
44
+++ b/mkl/__init__.py
5-
@@ -23,7 +23,11 @@
5+
@@ -23,7 +23,10 @@
66
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
77
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88

99
+import contextlib
1010
+import os
1111
import sys
1212
+from importlib.metadata import PackageNotFoundError, files
13-
+
1413

15-
class RTLD_for_MKL():
16-
def __init__(self):
17-
@@ -38,6 +42,20 @@ class RTLD_for_MKL():
14+
15+
class RTLD_for_MKL:
16+
@@ -41,6 +44,21 @@ class RTLD_for_MKL:
1817
sys.setdlopenflags(self.saved_rtld | ctypes.RTLD_GLOBAL)
1918
except AttributeError:
2019
pass
@@ -23,12 +22,13 @@ index d2fefc7..47f35b9 100644
2322
+ AttributeError, FileNotFoundError, StopIteration, PackageNotFoundError
2423
+ ):
2524
+ if os.name == "nt":
26-
+ # Add MKL library to DLL search path on Windows.
25+
+ # Add MKL library path to DLL search path on Windows.
2726
+ dll = next(p for p in files("mkl") if p.match("*mkl_rt*.dll"))
2827
+ dll_dir = dll.locate().resolve().parent
2928
+ os.add_dll_directory(dll_dir)
3029
+ else:
31-
+ # Preload MKL library on Linux.
30+
+ # There's no easy way to expand LD_LIBRARY_PATH at runtime in
31+
+ # Linux. Instead preload MKL library directly.
3232
+ dll = next(p for p in files("mkl") if p.match("*libmkl_rt.so*"))
3333
+ ctypes.CDLL(dll.locate().resolve(), mode=ctypes.RTLD_GLOBAL)
3434
+

0 commit comments

Comments
 (0)