diff --git a/.github/workflows/build-cibuildwheel.yml b/.github/workflows/build-cibuildwheel.yml index 57e23b0..d628f12 100644 --- a/.github/workflows/build-cibuildwheel.yml +++ b/.github/workflows/build-cibuildwheel.yml @@ -59,6 +59,13 @@ jobs: # Install numpy before building CIBW_BEFORE_BUILD: | pip install numpy + pip install --upgrade pip setuptools wheel + + CIBW_BEFORE_BUILD_LINUX: | + pip install numpy + pip install --upgrade pip setuptools wheel + # 确保Python开发文件可用 + python -m pip install --force-reinstall numpy CIBW_BEFORE_ALL_MACOS: | brew install boost zeromq openblas cmake libomp @@ -76,8 +83,6 @@ jobs: # Linux-specific environment variables CIBW_ENVIRONMENT_LINUX: | CMAKE_BUILD_PARALLEL_LEVEL=8 - Python_FIND_VIRTUALENV=ONLY - Python3_FIND_VIRTUALENV=ONLY - name: Build leann-backend-diskann wheels uses: pypa/cibuildwheel@v2.20.0 @@ -99,6 +104,13 @@ jobs: # Install numpy before building CIBW_BEFORE_BUILD: | pip install numpy + pip install --upgrade pip setuptools wheel + + CIBW_BEFORE_BUILD_LINUX: | + pip install numpy + pip install --upgrade pip setuptools wheel + # 确保Python开发文件可用 + python -m pip install --force-reinstall numpy CIBW_BEFORE_ALL_MACOS: | brew install boost zeromq openblas cmake libomp @@ -116,6 +128,11 @@ jobs: CMAKE_BUILD_PARALLEL_LEVEL=8 Python_FIND_VIRTUALENV=ONLY Python3_FIND_VIRTUALENV=ONLY + Python_FIND_STRATEGY=LOCATION + Python3_FIND_STRATEGY=LOCATION + CMAKE_PREFIX_PATH=$VIRTUAL_ENV + Python_EXECUTABLE=$VIRTUAL_ENV/bin/python + Python3_EXECUTABLE=$VIRTUAL_ENV/bin/python - uses: actions/upload-artifact@v4 with: diff --git a/packages/leann-backend-hnsw/CMakeLists.txt b/packages/leann-backend-hnsw/CMakeLists.txt index 2b86b0a..d187fa8 100644 --- a/packages/leann-backend-hnsw/CMakeLists.txt +++ b/packages/leann-backend-hnsw/CMakeLists.txt @@ -24,6 +24,23 @@ set(MSGPACK_USE_BOOST OFF CACHE BOOL "" FORCE) add_compile_definitions(MSGPACK_NO_BOOST) include_directories(third_party/msgpack-c/include) +# Find Python before configuring Faiss +# Check if we're in scikit-build environment +if(DEFINED SKBUILD) + message(STATUS "Building with scikit-build, using provided Python") + # scikit-build-core provides Python_* variables +else() + find_package(Python REQUIRED COMPONENTS Interpreter Development NumPy) +endif() + +# Print Python information for debugging +message(STATUS "Python_FOUND: ${Python_FOUND}") +message(STATUS "Python_VERSION: ${Python_VERSION}") +message(STATUS "Python_EXECUTABLE: ${Python_EXECUTABLE}") +message(STATUS "Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}") +message(STATUS "Python_LIBRARIES: ${Python_LIBRARIES}") +message(STATUS "Python_NumPy_INCLUDE_DIRS: ${Python_NumPy_INCLUDE_DIRS}") + # Faiss configuration - streamlined build set(FAISS_ENABLE_PYTHON ON CACHE BOOL "" FORCE) set(FAISS_ENABLE_GPU OFF CACHE BOOL "" FORCE) diff --git a/packages/leann-backend-hnsw/pyproject.toml b/packages/leann-backend-hnsw/pyproject.toml index 8f6f7d1..03bb77f 100644 --- a/packages/leann-backend-hnsw/pyproject.toml +++ b/packages/leann-backend-hnsw/pyproject.toml @@ -24,4 +24,5 @@ cmake.verbose = true # CMake definitions to optimize compilation [tool.scikit-build.cmake.define] -CMAKE_BUILD_PARALLEL_LEVEL = "8" \ No newline at end of file +CMAKE_BUILD_PARALLEL_LEVEL = "8" +SKBUILD_SOABI = "YES" \ No newline at end of file