Skip to content

Commit 76131d5

Browse files
author
Mug
committed
Use environment variable for library override
1 parent e3ea354 commit 76131d5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llama_cpp/llama_cpp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ def _load_shared_library(lib_base_name):
1818

1919
# Construct the paths to the possible shared library names
2020
_base_path = pathlib.Path(__file__).parent.resolve()
21-
_local_path = pathlib.Path.cwd()
2221
# Searching for the library in the current directory under the name "libllama" (default name
2322
# for llamacpp) and "llama" (default name for this repo)
2423
_lib_paths = [
25-
_local_path / f"./lib{lib_base_name}{lib_ext}",
26-
_local_path / f"./{lib_base_name}{lib_ext}",
2724
_base_path / f"lib{lib_base_name}{lib_ext}",
2825
_base_path / f"{lib_base_name}{lib_ext}"
2926
]
3027

28+
if ("LLAMA_LIB" in os.environ):
29+
_lib_paths = [pathlib.Path(os.environ["LLAMA_LIB"]).resolve()]
30+
3131
# Add the library directory to the DLL search path on Windows (if needed)
3232
if sys.platform == "win32" and sys.version_info >= (3, 8):
3333
os.add_dll_directory(str(_base_path))

0 commit comments

Comments
 (0)