From 499cdd7822a045007227a51461c6af1969885441 Mon Sep 17 00:00:00 2001 From: Andy Lee Date: Fri, 25 Jul 2025 00:14:22 -0700 Subject: [PATCH] feat: add cibuildwheel workflow for better platform compatibility - Use cibuildwheel for professional wheel building - Specifically use manylinux2014 for Google Colab compatibility - Supports Python 3.9-3.12 on Linux and macOS - Handles monorepo structure with separate builds per package - Includes basic import tests for each package - This should resolve compatibility issues with older systems like Google Colab --- .github/workflows/build-cibuildwheel.yml | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/build-cibuildwheel.yml diff --git a/.github/workflows/build-cibuildwheel.yml b/.github/workflows/build-cibuildwheel.yml new file mode 100644 index 0000000..5ef5f49 --- /dev/null +++ b/.github/workflows/build-cibuildwheel.yml @@ -0,0 +1,100 @@ +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: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ inputs.ref }} + submodules: recursive + + # Build each package separately in our monorepo + - name: Build leann-core wheels + uses: pypa/cibuildwheel@v2.16.2 + with: + package-dir: packages/leann-core + output-dir: wheelhouse + env: + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* + CIBW_SKIP: "*-win32 *-manylinux_i686 pp*" + # Pure Python package, no special requirements + + - name: Build leann-backend-hnsw wheels + uses: pypa/cibuildwheel@v2.16.2 + with: + package-dir: packages/leann-backend-hnsw + output-dir: wheelhouse + env: + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + CIBW_SKIP: "*-win32 *-manylinux_i686 pp*" + + CIBW_BEFORE_ALL_LINUX: | + yum install -y epel-release + yum install -y boost-devel protobuf-compiler zeromq-devel \ + pkg-config openblas-devel + + CIBW_BEFORE_ALL_MACOS: | + brew install llvm libomp boost protobuf zeromq + + CIBW_ENVIRONMENT_MACOS: | + CC=$(brew --prefix llvm)/bin/clang + CXX=$(brew --prefix llvm)/bin/clang++ + + CIBW_TEST_REQUIRES: leann-core numpy pyzmq msgpack + CIBW_TEST_COMMAND: python -c "import leann_backend_hnsw" + + - name: Build leann-backend-diskann wheels + uses: pypa/cibuildwheel@v2.16.2 + with: + package-dir: packages/leann-backend-diskann + output-dir: wheelhouse + env: + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 + CIBW_SKIP: "*-win32 *-manylinux_i686 pp*" + + CIBW_BEFORE_ALL_LINUX: | + yum install -y epel-release + yum install -y protobuf-compiler openblas-devel \ + libaio-devel protobuf-devel + + CIBW_BEFORE_ALL_MACOS: | + brew install llvm libomp protobuf + + CIBW_ENVIRONMENT_MACOS: | + CC=$(brew --prefix llvm)/bin/clang + CXX=$(brew --prefix llvm)/bin/clang++ + + CIBW_TEST_REQUIRES: leann-core numpy + CIBW_TEST_COMMAND: python -c "import leann_backend_diskann" + + - name: Build leann meta-package + uses: pypa/cibuildwheel@v2.16.2 + with: + package-dir: packages/leann + output-dir: wheelhouse + env: + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* + CIBW_SKIP: "*-win32 *-manylinux_i686 pp*" + # Pure Python meta-package + + - uses: actions/upload-artifact@v3 + with: + name: cibw-wheels-${{ matrix.os }} + path: ./wheelhouse/*.whl \ No newline at end of file