mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-08 22:48:25 -05:00
DLL: _PATH variables can be parent dir (#13753)
This commit is contained in:
committed by
GitHub
parent
159c0e92fa
commit
849e46da21
@@ -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'}?"))
|
||||
|
||||
Reference in New Issue
Block a user