|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# This workflow is based on the `linux` job of |
| 5 | +# https://github.com/huggingface/kernels/blob/v0.16.1/.github/workflows/kernels_data_python_release.yaml |
| 6 | +# and the test steps of its test_python.yaml. |
| 7 | +name: Build kernels-data 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/kernels-data.yaml not released yet' |
| 14 | + required: false |
| 15 | + default: '' |
| 16 | + pull_request: |
| 17 | + branches: [main] |
| 18 | + paths: |
| 19 | + - '.github/workflows/build-kernels-data.yml' |
| 20 | + - 'docs/packages/kernels-data.yaml' |
| 21 | + push: |
| 22 | + branches: [main] |
| 23 | + paths: |
| 24 | + - '.github/workflows/build-kernels-data.yml' |
| 25 | + - 'docs/packages/kernels-data.yaml' |
| 26 | + |
| 27 | +concurrency: |
| 28 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +permissions: |
| 32 | + contents: read # to fetch code (actions/checkout) |
| 33 | + |
| 34 | +env: |
| 35 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 36 | + |
| 37 | +jobs: |
| 38 | + setup: |
| 39 | + uses: $/.github/workflows/_setup.yml |
| 40 | + with: |
| 41 | + package: kernels-data |
| 42 | + version: ${{ inputs.version }} |
| 43 | + |
| 44 | + build_wheels: |
| 45 | + needs: [setup] |
| 46 | + if: needs.setup.outputs.versions != '[]' |
| 47 | + name: Build kernels-data ${{ matrix.version }} ${{ matrix.tag }}-manylinux_riscv64 |
| 48 | + runs-on: ubuntu-24.04-riscv |
| 49 | + timeout-minutes: 120 |
| 50 | + strategy: |
| 51 | + fail-fast: false |
| 52 | + matrix: |
| 53 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 54 | + # `tag` is a real matrix dimension, not an include-only key: two includes |
| 55 | + # that add the same new key collapse into one job (gotcha 402). |
| 56 | + tag: [cp38-abi3, cp314t] |
| 57 | + include: |
| 58 | + # kernels-data/bindings/python/Cargo.toml declares pyo3 with the |
| 59 | + # abi3/abi3-py38 features unconditionally, so one abi3 wheel serves |
| 60 | + # every GIL-ful interpreter; pyo3 disables abi3 under Py_GIL_DISABLED, |
| 61 | + # giving the free-threaded build its own wheel, which is why upstream |
| 62 | + # runs a second `-i python3.14t` maturin step. |
| 63 | + - tag: cp38-abi3 |
| 64 | + # 3.8 only names the tag's floor and is absent from the manylinux |
| 65 | + # image, so the wheel is built on this repo's cp312 floor and |
| 66 | + # re-tested on the newer interpreters. |
| 67 | + build: cp312-manylinux_riscv64 cp313-manylinux_riscv64 cp314-manylinux_riscv64 |
| 68 | + - tag: cp314t |
| 69 | + build: cp314t-manylinux_riscv64 |
| 70 | + |
| 71 | + env: |
| 72 | + KERNELS_DATA_VERSION: ${{ matrix.version }} |
| 73 | + |
| 74 | + steps: |
| 75 | + - name: Checkout kernels v${{ env.KERNELS_DATA_VERSION }} |
| 76 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 77 | + with: |
| 78 | + repository: huggingface/kernels |
| 79 | + ref: v${{ env.KERNELS_DATA_VERSION }} |
| 80 | + persist-credentials: false |
| 81 | + |
| 82 | + - name: Stage the licence beside kernels-data's pyproject.toml |
| 83 | + # maturin globs LICEN[CS]E* relative to the pyproject directory, which |
| 84 | + # is kernels-data/bindings/python/ in this workspace, and ignores the |
| 85 | + # `include ../../../LICENSE` in the MANIFEST.in next to it -- so |
| 86 | + # upstream's own wheels carry no licence file at all. |
| 87 | + run: cp LICENSE kernels-data/bindings/python/ |
| 88 | + |
| 89 | + - name: Build wheels |
| 90 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 91 | + with: |
| 92 | + package-dir: kernels-data/bindings/python |
| 93 | + output-dir: wheelhouse/ |
| 94 | + env: |
| 95 | + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. |
| 96 | + CIBW_BUILD: ${{ matrix.build }} |
| 97 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 98 | + # kernels-data ships no [tool.cibuildwheel], so the Rust toolchain |
| 99 | + # its maturin backend needs is installed in-container here. |
| 100 | + CIBW_BEFORE_ALL_LINUX: >- |
| 101 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 102 | + # mypy, which upstream's stubtest check needs, publishes no riscv64 |
| 103 | + # wheel on public PyPI; ours does. |
| 104 | + CIBW_ENVIRONMENT_LINUX: >- |
| 105 | + PATH="$PATH:$HOME/.cargo/bin" |
| 106 | + PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 107 | + CIBW_TEST_REQUIRES: pytest mypy |
| 108 | + CIBW_TEST_SOURCES: >- |
| 109 | + kernels-data/bindings/python/tests |
| 110 | + kernels-data/bindings/python/stubtest-allowlist.txt |
| 111 | + # maturin synthesises kernels_data/__init__.py as a re-export shim, so |
| 112 | + # the compiled module is the kernels_data.kernels_data submodule. |
| 113 | + CIBW_TEST_COMMAND: >- |
| 114 | + python -c "import kernels_data.kernels_data as m, importlib.metadata as md; |
| 115 | + assert m.__file__.endswith('.so'), m.__file__; |
| 116 | + files = md.files('kernels-data'); |
| 117 | + assert any(str(p).endswith('licenses/LICENSE') for p in files), files" && |
| 118 | + cd kernels-data/bindings/python && |
| 119 | + python -m pytest -v tests && |
| 120 | + python -m mypy.stubtest kernels_data --allowlist stubtest-allowlist.txt |
| 121 | +
|
| 122 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 123 | + with: |
| 124 | + name: kernels-data-${{ env.KERNELS_DATA_VERSION }}-${{ matrix.tag }}-manylinux_riscv64 |
| 125 | + path: wheelhouse/*.whl |
| 126 | + if-no-files-found: error |
| 127 | + |
| 128 | + publish: |
| 129 | + name: Publish kernels-data ${{ matrix.version }} |
| 130 | + needs: [setup, build_wheels] |
| 131 | + if: needs.setup.outputs.versions != '[]' |
| 132 | + strategy: |
| 133 | + fail-fast: false |
| 134 | + matrix: |
| 135 | + version: ${{ fromJSON(needs.setup.outputs.versions) }} |
| 136 | + permissions: |
| 137 | + contents: write |
| 138 | + pull-requests: write |
| 139 | + uses: $/.github/workflows/_publish-wheel.yml |
| 140 | + secrets: |
| 141 | + app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }} |
| 142 | + with: |
| 143 | + artifact-pattern: kernels-data-${{ matrix.version }}-*-manylinux_riscv64 |
0 commit comments