Skip to content

Commit cb954ac

Browse files
committed
Fix Windows DLL lookup: search both oqs.dll and liboqs.dll (Issue #108)
1 parent 328ca53 commit cb954ac

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

oqs/oqs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ def _load_shared_obj(
7878
if platform.system() == "Darwin":
7979
paths.append(path.absolute() / Path(f"lib{name}").with_suffix(".dylib"))
8080
elif platform.system() == "Windows":
81-
paths.append(path.absolute() / Path(name).with_suffix(".dll"))
82-
# Does not work
83-
# os.environ["PATH"] += os.path.abspath(path)
81+
# Try both oqs.dll and liboqs.dll in the install path
82+
for dll_name in (name, f"lib{name}"):
83+
paths.append(
84+
path.absolute() / Path(dll_name).with_suffix(".dll")
85+
)
8486
else: # Linux/FreeBSD/UNIX
8587
paths.append(path.absolute() / Path(f"lib{name}").with_suffix(".so"))
8688
# https://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes
@@ -230,7 +232,7 @@ def native() -> ct.CDLL:
230232

231233

232234
def oqs_version() -> str:
233-
"""`liboqs` version string."""
235+
"""liboqs version string."""
234236
native().OQS_version.restype = ct.c_char_p
235237
return ct.c_char_p(native().OQS_version()).value.decode("UTF-8") # type: ignore[union-attr]
236238

@@ -751,4 +753,4 @@ def get_enabled_sig_mechanisms() -> tuple[str, ...]:
751753

752754
def get_supported_sig_mechanisms() -> tuple[str, ...]:
753755
"""Return the list of supported signature mechanisms."""
754-
return _supported_sigs
756+
return _supported_sigs

0 commit comments

Comments
 (0)