Files
LEANN/.github/workflows/build-cibuildwheel.yml
Andy Lee a73194c3f6 feat: simplify build using cibuildwheel with standard configuration
- Add Python_FIND_VIRTUALENV hints to pyproject.toml for CMake
- Create standardized cibuildwheel workflow using manylinux_2_28
- Simplify system dependency installation
- Add global cibuildwheel configuration in root pyproject.toml
- Create streamlined test workflow for manylinux compatibility
2025-07-25 10:03:23 -07:00

103 lines
3.3 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, windows-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*"
# Use manylinux_2_28 for better compatibility
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
# Install dependencies before building
CIBW_BEFORE_ALL_LINUX: |
dnf install -y epel-release
dnf install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake
CIBW_BEFORE_ALL_MACOS: |
brew install boost zeromq openblas cmake
CIBW_BEFORE_ALL_WINDOWS: |
choco install cmake -y
# 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
- 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: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_BEFORE_ALL_LINUX: |
dnf install -y epel-release
dnf install -y gcc-c++ boost-devel zeromq-devel openblas-devel cmake
CIBW_BEFORE_ALL_MACOS: |
brew install boost zeromq openblas cmake
CIBW_BEFORE_ALL_WINDOWS: |
choco install cmake -y
CIBW_TEST_COMMAND: |
python -c "import leann_backend_diskann; print('DiskANN backend imported successfully')"
CIBW_ENVIRONMENT: |
CMAKE_BUILD_PARALLEL_LEVEL=8
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl