Use environment variable for library override

This commit is contained in:
Mug 2023-04-10 17:00:35 +02:00
parent e3ea354547
commit 76131d5bb8

View file

@ -18,16 +18,16 @@ def _load_shared_library(lib_base_name):
# Construct the paths to the possible shared library names # Construct the paths to the possible shared library names
_base_path = pathlib.Path(__file__).parent.resolve() _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 # Searching for the library in the current directory under the name "libllama" (default name
# for llamacpp) and "llama" (default name for this repo) # for llamacpp) and "llama" (default name for this repo)
_lib_paths = [ _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{lib_base_name}{lib_ext}",
_base_path / f"{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) # Add the library directory to the DLL search path on Windows (if needed)
if sys.platform == "win32" and sys.version_info >= (3, 8): if sys.platform == "win32" and sys.version_info >= (3, 8):
os.add_dll_directory(str(_base_path)) os.add_dll_directory(str(_base_path))