From 76131d5bb812ad3a84b73134d8356285be4eb297 Mon Sep 17 00:00:00 2001 From: Mug <> Date: Mon, 10 Apr 2023 17:00:35 +0200 Subject: [PATCH] Use environment variable for library override --- llama_cpp/llama_cpp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llama_cpp/llama_cpp.py b/llama_cpp/llama_cpp.py index 8105f18..e937148 100644 --- a/llama_cpp/llama_cpp.py +++ b/llama_cpp/llama_cpp.py @@ -18,16 +18,16 @@ def _load_shared_library(lib_base_name): # Construct the paths to the possible shared library names _base_path = pathlib.Path(__file__).parent.resolve() - _local_path = pathlib.Path.cwd() # Searching for the library in the current directory under the name "libllama" (default name # for llamacpp) and "llama" (default name for this repo) _lib_paths = [ - _local_path / f"./lib{lib_base_name}{lib_ext}", - _local_path / f"./{lib_base_name}{lib_ext}", _base_path / f"lib{lib_base_name}{lib_ext}", _base_path / f"{lib_base_name}{lib_ext}" ] + if ("LLAMA_LIB" in os.environ): + _lib_paths = [pathlib.Path(os.environ["LLAMA_LIB"]).resolve()] + # Add the library directory to the DLL search path on Windows (if needed) if sys.platform == "win32" and sys.version_info >= (3, 8): os.add_dll_directory(str(_base_path))