Skip to content

Commit cbac19b

Browse files
committed
Add winmode arg only on windows if python version supports it
1 parent c804efe commit cbac19b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llama_cpp/llama_cpp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,17 @@ def _load_shared_library(lib_base_name: str):
4444
_base_path = _lib.parent.resolve()
4545
_lib_paths = [_lib.resolve()]
4646

47+
cdll_args = dict() # type: ignore
4748
# Add the library directory to the DLL search path on Windows (if needed)
4849
if sys.platform == "win32" and sys.version_info >= (3, 8):
4950
os.add_dll_directory(str(_base_path))
51+
cdll_args["winmode"] = 0
5052

5153
# Try to load the shared library, handling potential errors
5254
for _lib_path in _lib_paths:
5355
if _lib_path.exists():
5456
try:
55-
return ctypes.CDLL(str(_lib_path), winmode=0)
57+
return ctypes.CDLL(str(_lib_path), **cdll_args)
5658
except Exception as e:
5759
raise RuntimeError(f"Failed to load shared library '{_lib_path}': {e}")
5860

0 commit comments

Comments
 (0)