diff --git a/.github/workflows/build-reusable.yml b/.github/workflows/build-reusable.yml index a23439e..eeab519 100644 --- a/.github/workflows/build-reusable.yml +++ b/.github/workflows/build-reusable.yml @@ -204,7 +204,7 @@ jobs: # Create a virtual environment uv venv source .venv/bin/activate || source .venv/Scripts/activate - + # Install the built wheels if [[ "${{ matrix.os }}" == ubuntu-* ]]; then uv pip install packages/leann-core/dist/*.whl @@ -226,7 +226,7 @@ jobs: run: | # Activate virtual environment source .venv/bin/activate || source .venv/Scripts/activate - + # Run all tests pytest tests/ @@ -234,7 +234,7 @@ jobs: run: | # Activate virtual environment source .venv/bin/activate || source .venv/Scripts/activate - + # Run distance function tests if available if [ -f test/sanity_checks/test_distance_functions.py ]; then echo "Running distance function sanity checks..." diff --git a/.gitignore b/.gitignore index 6b9890d..3d49d4d 100755 --- a/.gitignore +++ b/.gitignore @@ -86,3 +86,5 @@ packages/leann-backend-diskann/third_party/DiskANN/_deps/ *.passages.json batchtest.py +tests/__pytest_cache__/ +tests/__pycache__/ diff --git a/packages/leann-backend-hnsw/CMakeLists.txt b/packages/leann-backend-hnsw/CMakeLists.txt index 100e70b..1f41393 100644 --- a/packages/leann-backend-hnsw/CMakeLists.txt +++ b/packages/leann-backend-hnsw/CMakeLists.txt @@ -10,12 +10,12 @@ if(APPLE) set(OpenMP_C_LIB_NAMES "omp") set(OpenMP_CXX_LIB_NAMES "omp") set(OpenMP_omp_LIBRARY "/opt/homebrew/opt/libomp/lib/libomp.dylib") - + # Force use of system libc++ to avoid version mismatch set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++") - + # Set minimum macOS version for better compatibility set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS version") endif() diff --git a/packages/leann-core/src/leann/__init__.py b/packages/leann-core/src/leann/__init__.py index 25cbc51..7ac156d 100644 --- a/packages/leann-core/src/leann/__init__.py +++ b/packages/leann-core/src/leann/__init__.py @@ -8,6 +8,10 @@ if platform.system() == "Darwin": os.environ["MKL_NUM_THREADS"] = "1" os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" os.environ["KMP_BLOCKTIME"] = "0" + # Additional fixes for PyTorch/sentence-transformers on macOS ARM64 only in CI + if os.environ.get("CI") == "true": + os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "0" + os.environ["TOKENIZERS_PARALLELISM"] = "false" from .api import LeannBuilder, LeannChat, LeannSearcher from .registry import BACKEND_REGISTRY, autodiscover_backends diff --git a/packages/leann-core/src/leann/api.py b/packages/leann-core/src/leann/api.py index 5848b87..9efefde 100644 --- a/packages/leann-core/src/leann/api.py +++ b/packages/leann-core/src/leann/api.py @@ -23,6 +23,11 @@ from .registry import BACKEND_REGISTRY logger = logging.getLogger(__name__) +def get_registered_backends() -> list[str]: + """Get list of registered backend names.""" + return list(BACKEND_REGISTRY.keys()) + + def compute_embeddings( chunks: list[str], model_name: str,