mirror of
https://github.com/abetlen/llama-cpp-python.git
synced 2023-09-07 17:34:22 +03:00
Use environment variable for library override
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user