Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/build-sudachipy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# Based on the `build-wheels` job of
# https://github.com/WorksApplications/sudachi.rs/blob/v0.6.11/.github/workflows/build-python-wheels.yml
name: Build sudachipy wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'sudachipy version to build (git tag, e.g. v0.6.11)'
required: true
default: 'v0.6.11'
pull_request:
paths:
- '.github/workflows/build-sudachipy.yml'
- 'patches/sudachipy/**'

concurrency:
group: ${{ github.workflow }}-${{ inputs.version || 'v0.6.11' }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read # to fetch code (actions/checkout)

env:
# `inputs.version` is empty on pull_request events; default to v0.6.11 there.
SUDACHIPY_VERSION: ${{ inputs.version || 'v0.6.11' }}
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64

jobs:
setup:
uses: $/.github/workflows/_setup.yml

build_wheels:
needs: [setup]
name: Build sudachipy ${{ inputs.version || 'v0.6.11' }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
# No abi3: pyo3's abi3 feature isn't enabled in python/Cargo.toml.
python: ["cp312", "cp313", "cp314", "cp314t"]
include:
# tokenizers has no free-threaded wheel anywhere (abi3-only); its sdist
# build is unproven here, so drop just the one test module that needs it.
- python: "cp314t"
drop_pretokenizer_test: "rm tests/test_pretokenizers.py &&"
test_requires: 'sudachidict_core'

steps:
- name: Checkout sudachi.rs ${{ env.SUDACHIPY_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: WorksApplications/sudachi.rs
ref: ${{ env.SUDACHIPY_VERSION }}
persist-credentials: false

- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false

- name: Patch sudachi.rs source
run: git apply python-wheels/patches/sudachipy/${{ env.SUDACHIPY_VERSION }}/*.patch

- name: Build and test wheel
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
package-dir: python
env:
CIBW_ARCHS: riscv64
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
CIBW_SKIP: '*-musllinux_*' # rustup.rs has no riscv64 musl toolchain
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# No Rust in the manylinux image; install it and put cargo on PATH. Skips
# upstream's PGO before-all (external corpus download + release build of
# sudachi-cli), which would otherwise re-run once per matrix leg here.
CIBW_BEFORE_ALL_LINUX: >-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
CIBW_ENVIRONMENT: PATH="$PATH:$HOME/.cargo/bin" PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# pypi.riseproject.dev's newest tokenizers (0.22.2) is behind PyPI's
# (0.23.2, no riscv64 wheel); pin so pip resolves to ours.
CIBW_TEST_REQUIRES: ${{ matrix.test_requires || 'tokenizers==0.22.2 sudachidict_core' }}
# Upstream's own build_and_test.sh test command, run against {package}
# (gotcha 5) since cibuildwheel tests from an empty scratch directory.
CIBW_TEST_COMMAND: >-
bash -c "cd {package} && ${{ matrix.drop_pretokenizer_test }} python -m unittest discover -s tests -v"

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sudachipy-${{ env.SUDACHIPY_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: ./wheelhouse/*.whl
if-no-files-found: error

publish:
name: Publish sudachipy ${{ inputs.version || 'v0.6.11' }}
needs: [setup, build_wheels]
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
with:
artifact-pattern: sudachipy-${{ inputs.version || 'v0.6.11' }}-*-manylinux_riscv64
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Tue, 8 Sep 2026 16:00:00 +0200
Subject: [PATCH] python/pyproject: drop the removed cpython-freethreading
enable group

cibuildwheel 4.2.0 (the version this repo pins for riscv64 builds) no
longer recognises "cpython-freethreading" as an enable group -- it
errors "Failed to parse enable group" before any build starts, on
every interpreter, since [tool.cibuildwheel] is parsed as a whole
(same failure as patches/pi-heif/1.4.0). Free-threaded builds (cp314t)
no longer need an opt-in.

Upstream-Status: To upstream [not yet submitted; sudachi.rs's develop branch (checked at 2f5653eb, past the v0.6.11 tag) still carries the same enable list, so there is no existing upstream fix to backport]
---
python/pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/pyproject.toml b/python/pyproject.toml
index 0d61a4f2..887464de 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel", "setuptools-rust"]
[tool.cibuildwheel]
build = "cp39-* cp310-* cp311-* cp312-* cp313-* cp313t-* cp314-* cp314t-*"
skip = "*t-win* *-win32 *-musllinux_*"
-enable = ["cpython-prerelease", "cpython-freethreading"]
+enable = ["cpython-prerelease"]

manylinux-x86_64-image = "manylinux2014"
manylinux-aarch64-image = "manylinux2014"
--
2.43.0