|
| 1 | +# SPDX-FileCopyrightText: 2026 The RISE Project |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +--- |
| 4 | +# Based on the `build-wheels` job of |
| 5 | +# https://github.com/WorksApplications/sudachi.rs/blob/v0.6.11/.github/workflows/build-python-wheels.yml |
| 6 | +name: Build sudachipy wheels (riscv64) |
| 7 | + |
| 8 | +on: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + version: |
| 12 | + description: 'sudachipy version to build (git tag, e.g. v0.6.11)' |
| 13 | + required: true |
| 14 | + default: 'v0.6.11' |
| 15 | + pull_request: |
| 16 | + paths: |
| 17 | + - '.github/workflows/build-sudachipy.yml' |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ inputs.version || 'v0.6.11' }}-${{ github.head_ref || github.run_id }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read # to fetch code (actions/checkout) |
| 25 | + |
| 26 | +env: |
| 27 | + # `inputs.version` is empty on pull_request events; default to v0.6.11 there. |
| 28 | + SUDACHIPY_VERSION: ${{ inputs.version || 'v0.6.11' }} |
| 29 | + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 |
| 30 | + |
| 31 | +jobs: |
| 32 | + setup: |
| 33 | + uses: $/.github/workflows/_setup.yml |
| 34 | + |
| 35 | + build_wheels: |
| 36 | + needs: [setup] |
| 37 | + name: Build sudachipy ${{ inputs.version || 'v0.6.11' }} ${{ matrix.python }}-manylinux_riscv64 |
| 38 | + runs-on: ubuntu-24.04-riscv |
| 39 | + timeout-minutes: 90 |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + # No abi3: pyo3's abi3 feature isn't enabled in python/Cargo.toml. |
| 44 | + python: ["cp312", "cp313", "cp314", "cp314t"] |
| 45 | + include: |
| 46 | + # tokenizers has no free-threaded wheel anywhere (abi3-only); its sdist |
| 47 | + # build is unproven here, so drop just the one test module that needs it. |
| 48 | + - python: "cp314t" |
| 49 | + drop_pretokenizer_test: "rm tests/test_pretokenizers.py &&" |
| 50 | + test_requires: 'sudachidict_core' |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout sudachi.rs ${{ env.SUDACHIPY_VERSION }} |
| 54 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 55 | + with: |
| 56 | + repository: WorksApplications/sudachi.rs |
| 57 | + ref: ${{ env.SUDACHIPY_VERSION }} |
| 58 | + persist-credentials: false |
| 59 | + |
| 60 | + - name: Build and test wheel |
| 61 | + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 62 | + with: |
| 63 | + package-dir: python |
| 64 | + env: |
| 65 | + CIBW_ARCHS: riscv64 |
| 66 | + CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64 |
| 67 | + CIBW_SKIP: '*-musllinux_*' # rustup.rs has no riscv64 musl toolchain |
| 68 | + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} |
| 69 | + # No Rust in the manylinux image; install it and put cargo on PATH. Skips |
| 70 | + # upstream's PGO before-all (external corpus download + release build of |
| 71 | + # sudachi-cli), which would otherwise re-run once per matrix leg here. |
| 72 | + CIBW_BEFORE_ALL_LINUX: >- |
| 73 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 74 | + CIBW_ENVIRONMENT: PATH="$PATH:$HOME/.cargo/bin" PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ |
| 75 | + # pypi.riseproject.dev's newest tokenizers (0.22.2) is behind PyPI's |
| 76 | + # (0.23.2, no riscv64 wheel); pin so pip resolves to ours. |
| 77 | + CIBW_TEST_REQUIRES: ${{ matrix.test_requires || 'tokenizers==0.22.2 sudachidict_core' }} |
| 78 | + # Upstream's own build_and_test.sh test command, run against {package} |
| 79 | + # (gotcha 5) since cibuildwheel tests from an empty scratch directory. |
| 80 | + CIBW_TEST_COMMAND: >- |
| 81 | + bash -c "cd {package} && ${{ matrix.drop_pretokenizer_test }} python -m unittest discover -s tests -v" |
| 82 | +
|
| 83 | + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 84 | + with: |
| 85 | + name: sudachipy-${{ env.SUDACHIPY_VERSION }}-${{ matrix.python }}-manylinux_riscv64 |
| 86 | + path: ./wheelhouse/*.whl |
| 87 | + if-no-files-found: error |
| 88 | + |
| 89 | + publish: |
| 90 | + name: Publish sudachipy ${{ inputs.version || 'v0.6.11' }} |
| 91 | + needs: [setup, build_wheels] |
| 92 | + permissions: |
| 93 | + contents: write |
| 94 | + pull-requests: write |
| 95 | + uses: $/.github/workflows/_publish-wheel.yml |
| 96 | + with: |
| 97 | + artifact-pattern: sudachipy-${{ inputs.version || 'v0.6.11' }}-*-manylinux_riscv64 |
0 commit comments