Files
LEANN/.github/workflows/build-cibuildwheel.yml
Andy Lee cf58b3e31b fix: re-enable Faiss Python bindings and improve Python finding
- Re-enable FAISS_ENABLE_PYTHON since we need the Python bindings
- Use Development.Module component for better compatibility
- Pass Python information to Faiss through CMake cache variables
- Add CMAKE_PREFIX_PATH= to help CMake find Python in manylinux
2025-07-25 10:45:07 -07:00

136 lines
4.6 KiB
YAML

name: Build with cibuildwheel
on:
workflow_call:
inputs:
ref:
description: 'Git ref to build'
required: false
type: string
default: ''
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# Build pure Python packages separately
- name: Build pure Python packages (leann-core, leann)
if: matrix.os == 'ubuntu-latest' # Only build once
run: |
python -m pip install --upgrade pip build
python -m build packages/leann-core --outdir wheelhouse/
python -m build packages/leann --outdir wheelhouse/
- name: Build leann-backend-hnsw wheels
uses: pypa/cibuildwheel@v2.20.0
with:
package-dir: packages/leann-backend-hnsw
output-dir: wheelhouse
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *musllinux*"
# 使用manylinux2014生成兼容性更好的wheels
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
# 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
ln -sf /usr/bin/cmake3 /usr/bin/cmake
# 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 swig
CIBW_BEFORE_ALL_MACOS: |
brew install boost zeromq openblas cmake libomp
# Test the wheel
CIBW_TEST_COMMAND: |
python -c "import leann_backend_hnsw; print('HNSW backend imported successfully')"
# Environment variables for build
CIBW_ENVIRONMENT: |
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
- name: Build leann-backend-diskann wheels
uses: pypa/cibuildwheel@v2.20.0
with:
package-dir: packages/leann-backend-diskann
output-dir: wheelhouse
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* cp313-*
CIBW_SKIP: "*-win32 *-manylinux_i686 pp* *musllinux*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: |
yum install -y epel-release
yum install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake3
ln -sf /usr/bin/cmake3 /usr/bin/cmake
# 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 swig
CIBW_BEFORE_ALL_MACOS: |
brew install boost zeromq openblas cmake libomp
CIBW_TEST_COMMAND: |
python -c "import leann_backend_diskann; print('DiskANN backend imported successfully')"
CIBW_ENVIRONMENT: |
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
CMAKE_PREFIX_PATH=$VIRTUAL_ENV
Python_FIND_VIRTUALENV=ONLY
Python3_FIND_VIRTUALENV=ONLY
Python_FIND_STRATEGY=LOCATION
Python3_FIND_STRATEGY=LOCATION
Python_EXECUTABLE=$VIRTUAL_ENV/bin/python
Python3_EXECUTABLE=$VIRTUAL_ENV/bin/python
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl