Skip to content

Commit

Permalink
Fix: Use ctypes for Windows & Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Oct 10, 2024
1 parent 0fc72a2 commit ca58134
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions python/usearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
from typing import Optional, Tuple
from urllib.error import HTTPError


#! SimSIMD must come before USearch import
#! Load SimSIMD before the USearch compiled module
try:
import ctypes
import simsimd

#! We can't just use the `import simsimd` as on Linux and Windows (unlike MacOS),
#! the symbols are not automatically loaded into the global namespace.
simsimd_lib = ctypes.CDLL(simsimd.__file__, mode=ctypes.RTLD_GLOBAL)
except ImportError:
pass
pass # Well, the user doesn't want SimSIMD, I assume :)


from usearch.compiled import (
VERSION_MAJOR,
Expand Down
9 changes: 7 additions & 2 deletions python/usearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
import numpy as np
from tqdm import tqdm

#! SimSIMD must come before USearch import
#! Load SimSIMD before the USearch compiled module
try:
import ctypes
import simsimd

#! We can't just use the `import simsimd` as on Linux and Windows (unlike MacOS),
#! the symbols are not automatically loaded into the global namespace.
simsimd_lib = ctypes.CDLL(simsimd.__file__, mode=ctypes.RTLD_GLOBAL)
except ImportError:
pass
pass # Well, the user doesn't want SimSIMD, I assume :)

# Precompiled symbols that won't be exposed directly:
from usearch.compiled import (
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get_bool_env_w_name(name: str, preference: bool) -> tuple:
]
if use_simsimd:
include_dirs.append("simsimd/include")
install_requires.append("simsimd>=5.6.3")
install_requires.append("simsimd>=5.6.4")
if use_fp16lib:
include_dirs.append("fp16/include")

Expand Down

0 comments on commit ca58134

Please sign in to comment.