From c8b5d0b963c7339d9b3fa98ebc1a5a7b542a2ea7 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 --- examples/llama_cpp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/llama_cpp.py b/examples/llama_cpp.py index 8bc0b577b..63e8e97bf 100644 --- a/examples/llama_cpp.py +++ b/examples/llama_cpp.py @@ -29,16 +29,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_CPP_LIB" in os.environ): + _lib_paths = [pathlib.Path(os.environ["LLAMA_CPP_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))