From 0543cc98162f9e37a4219f5dbb0adcb10798eb56 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Fri, 25 Jul 2025 10:20:02 -0700 Subject: [PATCH] fix: add missing dependencies for CI builds - Add libomp for macOS to fix OpenMP linking error - Add python3-devel for Linux (though may not be needed in manylinux) - Install numpy before building to satisfy faiss CMake requirements - Add before-build configuration to cibuildwheel --- .github/workflows/build-cibuildwheel.yml | 28 ++++++++++++++++++++---- pyproject.toml | 11 ++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-cibuildwheel.yml b/.github/workflows/build-cibuildwheel.yml index 7e219c5..57e23b0 100644 --- a/.github/workflows/build-cibuildwheel.yml +++ b/.github/workflows/build-cibuildwheel.yml @@ -53,11 +53,15 @@ jobs: # Linux dependencies - 使用yum因为manylinux2014基于CentOS 7 CIBW_BEFORE_ALL_LINUX: | yum install -y epel-release - yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 + yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 python3-devel ln -sf /usr/bin/cmake3 /usr/bin/cmake + # Install numpy before building + CIBW_BEFORE_BUILD: | + pip install numpy + CIBW_BEFORE_ALL_MACOS: | - brew install boost zeromq openblas cmake + brew install boost zeromq openblas cmake libomp # Test the wheel CIBW_TEST_COMMAND: | @@ -68,6 +72,12 @@ jobs: CMAKE_BUILD_PARALLEL_LEVEL=8 Python_FIND_VIRTUALENV=ONLY Python3_FIND_VIRTUALENV=ONLY + + # 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 @@ -83,11 +93,15 @@ jobs: CIBW_BEFORE_ALL_LINUX: | yum install -y epel-release - yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 + yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 python3-devel ln -sf /usr/bin/cmake3 /usr/bin/cmake + # Install numpy before building + CIBW_BEFORE_BUILD: | + pip install numpy + CIBW_BEFORE_ALL_MACOS: | - brew install boost zeromq openblas cmake + brew install boost zeromq openblas cmake libomp CIBW_TEST_COMMAND: | python -c "import leann_backend_diskann; print('DiskANN backend imported successfully')" @@ -96,6 +110,12 @@ jobs: CMAKE_BUILD_PARALLEL_LEVEL=8 Python_FIND_VIRTUALENV=ONLY Python3_FIND_VIRTUALENV=ONLY + + # Linux-specific environment variables + CIBW_ENVIRONMENT_LINUX: | + CMAKE_BUILD_PARALLEL_LEVEL=8 + Python_FIND_VIRTUALENV=ONLY + Python3_FIND_VIRTUALENV=ONLY - uses: actions/upload-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index b241169..1e9b804 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,10 +73,17 @@ manylinux-aarch64-image = "manylinux2014" [tool.cibuildwheel.linux] before-all = """ yum install -y epel-release - yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 + yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3 python3-devel ln -sf /usr/bin/cmake3 /usr/bin/cmake """ # macOS系统依赖 [tool.cibuildwheel.macos] -before-all = "brew install boost zeromq openblas cmake" +before-all = "brew install boost zeromq openblas cmake libomp" + +# 环境变量配置 +[tool.cibuildwheel.environment] +CMAKE_BUILD_PARALLEL_LEVEL = "8" + +# 构建前安装必要的Python包 +before-build = "pip install numpy"