|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `build`/`linux-x86_64` leg of upstream's own |
| 5 | +# wheel pipeline: |
| 6 | +# https://github.com/lance-format/lance-context/blob/v0.6.5/.github/workflows/python-publish.yml |
| 7 | +name: Build lance-context wheels (riscv64) |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + version: |
| 13 | + description: 'Version glob to (re)build; empty builds every version of docs/packages/lance-context.yaml not released yet' |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + pull_request: |
| 17 | + branches: [main] |
| 18 | + paths: |
| 19 | + - '.github/workflows/build-lance-context.yml' |
| 20 | + - 'docs/packages/lance-context.yaml' |
| 21 | + - 'patches/lance-context/**' |
| 22 | + push: |
| 23 | + branches: [main] |
| 24 | + paths: |
| 25 | + - '.github/workflows/build-lance-context.yml' |
| 26 | + - 'docs/packages/lance-context.yaml' |
| 27 | + - 'patches/lance-context/**' |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +permissions: |
| 34 | + contents: read # to fetch code (actions/checkout) |
| 35 | + |
| 36 | +env: |
| 37 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 38 | + |
| 39 | +jobs: |
| 40 | + setup: |
| 41 | + uses: $/.github/workflows/_setup.yml |
| 42 | + with: |
| 43 | + package: lance-context |
| 44 | + version: ${{ inputs.version }} |
| 45 | + |
| 46 | + build_wheels: |
| 47 | + needs: [setup] |
| 48 | + if: needs.setup.outputs.versions != '[]' |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 53 | + # pyo3 carries `abi3-py39` unconditionally in python/Cargo.toml, so |
| 54 | + # upstream ships one cp39-abi3 wheel. Our registry's pyarrow (a hard |
| 55 | + # runtime dependency) has no riscv64 wheel below cp312, so the build |
| 56 | + # floor here is cp312 instead -- the wheel is still tagged cp39-abi3 by |
| 57 | + # the pyo3 feature regardless of which interpreter compiles it (CLAUDE.md |
| 58 | + # gotcha 96), it is simply only tested on cp312 (same as |
| 59 | + # build-pylance.yml/build-lancedb.yml). python/pyproject.toml's own |
| 60 | + # `requires-python = ">=3.11,<3.14"` would also rule out cp314/cp314t, |
| 61 | + # had the pyarrow floor not already stopped at one interpreter. |
| 62 | + name: Build lance-context ${{ matrix.version }} cp39-abi3-manylinux_riscv64 |
| 63 | + runs-on: ubuntu-24.04-riscv |
| 64 | + timeout-minutes: 1440 |
| 65 | + |
| 66 | + env: |
| 67 | + LANCE_CONTEXT_VERSION: ${{ matrix.version }} |
| 68 | + |
| 69 | + steps: |
| 70 | + # python/ is a member of the lance-context Cargo workspace and builds |
| 71 | + # against its sibling crates, so the checkout lands at the workspace root. |
| 72 | + - name: Checkout lance-context v${{ env.LANCE_CONTEXT_VERSION }} |
| 73 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 74 | + with: |
| 75 | + repository: lance-format/lance-context |
| 76 | + ref: v${{ env.LANCE_CONTEXT_VERSION }} |
| 77 | + persist-credentials: false |
| 78 | + |
| 79 | + - name: Checkout python-wheels |
| 80 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 81 | + with: |
| 82 | + path: python-wheels |
| 83 | + sparse-checkout: patches/lance-context |
| 84 | + persist-credentials: false |
| 85 | + |
| 86 | + # lance-graph is declared in crates/lance-context-core/Cargo.toml but |
| 87 | + # never imported anywhere in this workspace, and its own Cargo.toml |
| 88 | + # pins lance-core/lance-linalg at an incompatible `1.x` line that |
| 89 | + # Cargo's [patch] table cannot redirect alongside the `7.0.0` line |
| 90 | + # crates/lance-context-core depends on directly (CLAUDE.md gotcha 300). |
| 91 | + - name: Apply lance-context patches |
| 92 | + run: git apply -v python-wheels/patches/lance-context/${{ env.LANCE_CONTEXT_VERSION }}/0001*.patch |
| 93 | + |
| 94 | + # lance-core's SIMD_SUPPORT static and lance-linalg's f32x8/f32x16/ |
| 95 | + # i32x8/f64x4/f64x8 SIMD types compile only for x86_64/aarch64/ |
| 96 | + # loongarch64 upstream (CLAUDE.md gotcha 300); both are pulled in from |
| 97 | + # crates.io at a pinned `lance = "7.0.0"` (crates/lance-context-core/ |
| 98 | + # Cargo.toml), so riscv64-fixed copies are vendored here and wired in |
| 99 | + # via `[patch.crates-io]`. |
| 100 | + - name: Vendor riscv64-fixed lance-core and lance-linalg |
| 101 | + run: | |
| 102 | + curl -fsSL -A "python-wheels (https://github.com/riseproject-dev/python-wheels)" -o lance-core.tar.gz "https://crates.io/api/v1/crates/lance-core/7.0.0/download" |
| 103 | + mkdir lance-core-7.0.0-riscv64 |
| 104 | + tar xzf lance-core.tar.gz -C lance-core-7.0.0-riscv64 --strip-components=1 |
| 105 | + rm lance-core.tar.gz |
| 106 | + patch -p1 -d lance-core-7.0.0-riscv64 < python-wheels/patches/lance-context/${{ env.LANCE_CONTEXT_VERSION }}/0002-lance-core-riscv64-simd-fallback.patch |
| 107 | +
|
| 108 | + curl -fsSL -A "python-wheels (https://github.com/riseproject-dev/python-wheels)" -o lance-linalg.tar.gz "https://crates.io/api/v1/crates/lance-linalg/7.0.0/download" |
| 109 | + mkdir lance-linalg-7.0.0-riscv64 |
| 110 | + tar xzf lance-linalg.tar.gz -C lance-linalg-7.0.0-riscv64 --strip-components=1 |
| 111 | + rm lance-linalg.tar.gz |
| 112 | + patch -p1 -d lance-linalg-7.0.0-riscv64 < python-wheels/patches/lance-context/${{ env.LANCE_CONTEXT_VERSION }}/0004-lance-linalg-riscv64-simd-fallback.patch |
| 113 | +
|
| 114 | + git apply python-wheels/patches/lance-context/${{ env.LANCE_CONTEXT_VERSION }}/0003-cargo-patch-lance-crates-for-riscv64.patch |
| 115 | +
|
| 116 | + - name: Free disk space |
| 117 | + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 |
| 118 | + |
| 119 | + # This workspace links ~960 crates (datafusion, arrow, the embedded |
| 120 | + # lancedb/lance/lance-index Rust crates, the aws/azure/gcp/huggingface/ |
| 121 | + # tencent object-store backends, ...); same OOM guard build-lancedb.yml/ |
| 122 | + # build-rerun-sdk.yml need for a comparably sized Rust workspace. |
| 123 | + - name: Set swap space |
| 124 | + uses: pierotofy/set-swap-space@fc79b3f67fa8a838184ce84a674ca12238d2c761 # master |
| 125 | + with: |
| 126 | + swap-size-gb: 16 |
| 127 | + |
| 128 | + - name: Build wheel |
| 129 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 130 | + with: |
| 131 | + package-dir: python |
| 132 | + output-dir: wheelhouse/ |
| 133 | + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. |
| 134 | + only: cp312-manylinux_riscv64 |
| 135 | + env: |
| 136 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 137 | + # lance-context ships no [tool.cibuildwheel], so the Rust toolchain |
| 138 | + # its maturin backend needs is installed in-container here. Rocky |
| 139 | + # 10's CRB repo (enabled in the manylinux image) has protoc; |
| 140 | + # PROTOC_INCLUDE is needed because it resolves |
| 141 | + # google/protobuf/*.proto from disk rather than from the binary |
| 142 | + # (same as build-pylance.yml/build-lancedb.yml). |
| 143 | + CIBW_BEFORE_ALL_LINUX: >- |
| 144 | + yum install -y protobuf-compiler protobuf-devel && |
| 145 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal |
| 146 | + # python/pyproject.toml leaves [tool.maturin] at the default `dev` |
| 147 | + # profile, so a plain PEP 517 build ships an unoptimised wheel |
| 148 | + # unless `--profile release` is passed explicitly (CLAUDE.md |
| 149 | + # gotcha 141; the deltalake case). |
| 150 | + CIBW_ENVIRONMENT_LINUX: >- |
| 151 | + PATH="$PATH:$HOME/.cargo/bin" |
| 152 | + PROTOC=/usr/bin/protoc |
| 153 | + PROTOC_INCLUDE=/usr/include |
| 154 | + MATURIN_PEP517_ARGS="--profile release --strip" |
| 155 | + CARGO_BUILD_JOBS=2 |
| 156 | + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 157 | + # Without this pip prefers PyPI's pyarrow, which has no riscv64 |
| 158 | + # wheel, and source-builds Arrow's whole C++ library here. |
| 159 | + CIBW_TEST_ENVIRONMENT: PIP_ONLY_BINARY=pyarrow |
| 160 | + # The `tests` extra also lists pylance/lance-namespace/lancedb, but |
| 161 | + # none of this suite imports them (only `pyarrow` and stub |
| 162 | + # embedding providers -- see test_embeddings.py/ |
| 163 | + # test_multimodal_embeddings.py); pinning the extra as-is would |
| 164 | + # resolve pylance>=7,<8/lancedb==0.27.1 against versions our |
| 165 | + # registry doesn't carry (it only hosts pylance==11.0.0/ |
| 166 | + # lancedb==0.37.1+) and either fail or source-build the whole lance |
| 167 | + # Rust workspace a second time, so the suite's actual requirements |
| 168 | + # are listed directly instead. |
| 169 | + CIBW_TEST_REQUIRES: pytest pytest-asyncio moto[s3,server] boto3 botocore |
| 170 | + CIBW_TEST_SOURCES: python/pyproject.toml python/tests |
| 171 | + # Mirrors upstream's own `test`/`Run tests` step (python-test.yml: |
| 172 | + # `pytest -v` from python/, no extra flags). test_rollout_remote.py |
| 173 | + # skips itself when target/debug/lance-context-server hasn't been |
| 174 | + # built, which it isn't here (that crate is a workspace member |
| 175 | + # neither the Python wheel nor its tests otherwise need). |
| 176 | + CIBW_TEST_COMMAND: >- |
| 177 | + cd python && |
| 178 | + python -m pytest tests -v |
| 179 | +
|
| 180 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 181 | + with: |
| 182 | + name: lance-context-${{ env.LANCE_CONTEXT_VERSION }}-cp39-abi3-manylinux_riscv64 |
| 183 | + path: wheelhouse/*.whl |
| 184 | + if-no-files-found: error |
| 185 | + |
| 186 | + publish: |
| 187 | + name: Publish lance-context ${{ matrix.version }} |
| 188 | + needs: [setup, build_wheels] |
| 189 | + if: needs.setup.outputs.versions != '[]' |
| 190 | + strategy: |
| 191 | + fail-fast: false |
| 192 | + matrix: |
| 193 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 194 | + permissions: |
| 195 | + contents: write |
| 196 | + pull-requests: write |
| 197 | + uses: $/.github/workflows/_publish-wheel.yml |
| 198 | + secrets: |
| 199 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 200 | + with: |
| 201 | + artifact-pattern: lance-context-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments