From 849e46da21193391f63cf195f805b6a55108e7e9 Mon Sep 17 00:00:00 2001 From: Christopher Milan Date: Thu, 18 Dec 2025 21:28:02 -0800 Subject: [PATCH] DLL: _PATH variables can be parent dir (#13753) --- tinygrad/runtime/support/c.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tinygrad/runtime/support/c.py b/tinygrad/runtime/support/c.py index b30b7c1979..9f99e783a5 100644 --- a/tinygrad/runtime/support/c.py +++ b/tinygrad/runtime/support/c.py @@ -49,7 +49,7 @@ class DLL(ctypes.CDLL): if (pth:=pathlib.Path(p)).is_absolute(): if pth.is_file(): return p else: continue - for pre in (pathlib.Path(pre) for pre in libpaths.get(os.name, []) + libpaths.get(sys.platform, []) + extra_paths): + for pre in (pathlib.Path(pre) for pre in ([path] if path else []) + libpaths.get(os.name, []) + libpaths.get(sys.platform, []) + extra_paths): if not pre.is_dir(): continue if WIN or OSX: for base in ([f"lib{p}.dylib", f"{p}.dylib", str(p)] if OSX else [f"{p}.dll"]): @@ -67,7 +67,10 @@ class DLL(ctypes.CDLL): try: super().__init__(path, **kwargs) self.loaded = True - except OSError as e: self.emsg = str(e) + except OSError as e: + self.emsg = str(e) + if DEBUG >= 3: print(f"loading {nm} failed: {e}") + elif DEBUG >= 3: print(f"loading {nm} failed: not found on system") def __getattr__(self, nm): if not self.loaded: raise AttributeError(f"failed to load library {self.nm}: " + (self.emsg or f"try setting {self.nm.upper()+'_PATH'}?"))