From a3da39af79cecb1dd94bf9e01f11d7a06a1b493e Mon Sep 17 00:00:00 2001 From: Andrei Betlen Date: Fri, 24 Mar 2023 18:43:29 -0400 Subject: [PATCH] Bugfix: cross-platform method to find shared lib --- examples/llama_cpp.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/llama_cpp.py b/examples/llama_cpp.py index f7149ed67..bafc40112 100644 --- a/examples/llama_cpp.py +++ b/examples/llama_cpp.py @@ -12,11 +12,15 @@ from ctypes import ( ) import pathlib +from itertools import chain # Load the library -libfile = pathlib.Path(__file__).parent / "libllama.so" -_lib = ctypes.CDLL(str(libfile)) - +# TODO: fragile, should fix +_base_path = pathlib.Path(__file__).parent +(_lib_path,) = chain( + _base_path.glob("*.so"), _base_path.glob("*.dylib"), _base_path.glob("*.dll") +) +_lib = ctypes.CDLL(str(_lib_path)) # C types llama_context_p = c_void_p