diff --git a/.github/workflows/build-rjieba.yml b/.github/workflows/build-rjieba.yml new file mode 100644 index 000000000..6d55736e3 --- /dev/null +++ b/.github/workflows/build-rjieba.yml @@ -0,0 +1,118 @@ +# SPDX-FileCopyrightText: 2026 The RISE Project +# SPDX-License-Identifier: MIT +--- +# This workflow is based on the `linux` job of +# https://github.com/messense/rjieba-py/blob/v0.2.1/.github/workflows/CI.yml +name: Build rjieba wheels (riscv64) + +on: + workflow_dispatch: + inputs: + version: + description: 'rjieba version to build (git tag without the leading v, e.g. 0.2.1)' + required: true + default: '0.2.1' + pull_request: + paths: + - '.github/workflows/build-rjieba.yml' + - 'patches/rjieba/**' + +concurrency: + group: ${{ github.workflow }}-${{ inputs.version || '0.2.1' }}-${{ 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 0.2.1 there. + RJIEBA_VERSION: ${{ inputs.version || '0.2.1' }} + MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64 + +jobs: + setup: + uses: $/.github/workflows/_setup.yml + + build_wheels: + needs: [setup] + name: Build rjieba ${{ inputs.version || '0.2.1' }} ${{ matrix.tag }}-manylinux_riscv64 + runs-on: ubuntu-24.04-riscv + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + include: + # pyo3's abi3-py38 feature (Cargo.toml) gives one wheel for every + # GIL-ful interpreter; free-threaded builds disable abi3 and get + # their own (upstream's CI.yml builds them as a separate maturin + # pass with `-i python3.14t` for the same reason). + - tag: cp38-abi3 + # Built on cp312 -- the oldest interpreter in our matrix -- and + # re-tested on cp313/cp314 via find_compatible_wheel. + build: >- + cp312-manylinux_riscv64 cp313-manylinux_riscv64 + cp314-manylinux_riscv64 + - tag: cp314t + build: cp314t-manylinux_riscv64 + + steps: + - name: Checkout rjieba v${{ env.RJIEBA_VERSION }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: messense/rjieba-py + ref: v${{ env.RJIEBA_VERSION }} + persist-credentials: false + + - name: Checkout python-wheels + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + path: python-wheels + persist-credentials: false + + - name: Patch rjieba source + run: git apply python-wheels/patches/rjieba/${{ env.RJIEBA_VERSION }}/*.patch + + - name: Build and test wheel + uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 + with: + output-dir: wheelhouse/ + env: + # musllinux is dropped: rustup.rs ships no riscv64 musl toolchain. + CIBW_BUILD: ${{ matrix.build }} + CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }} + # rjieba ships no [tool.cibuildwheel], so the Rust toolchain its + # maturin backend needs is installed in-container here. + CIBW_BEFORE_ALL_LINUX: >- + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin" + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_SOURCES: tests + CIBW_TEST_COMMAND: >- + python -c "import rjieba; assert rjieba.rjieba.__file__.endswith('.so'), rjieba.rjieba.__file__" && + python -m pytest -v tests + + - name: Check the licence made it into the wheel + run: | + python3 - wheelhouse/*.whl <<'EOF' + import sys, zipfile + for whl in sys.argv[1:]: + names = zipfile.ZipFile(whl).namelist() + assert any(n.endswith("dist-info/licenses/LICENSE") for n in names), names + print(whl, "ok") + EOF + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: rjieba-${{ env.RJIEBA_VERSION }}-${{ matrix.tag }}-manylinux_riscv64 + path: wheelhouse/*.whl + if-no-files-found: error + + publish: + name: Publish rjieba ${{ inputs.version || '0.2.1' }} + needs: [setup, build_wheels] + permissions: + contents: write + pull-requests: write + uses: $/.github/workflows/_publish-wheel.yml + with: + artifact-pattern: rjieba-${{ inputs.version || '0.2.1' }}-*-manylinux_riscv64 diff --git a/patches/rjieba/0.2.1/0001-pyproject-declare-a-project-table-so-maturin-bundles.patch b/patches/rjieba/0.2.1/0001-pyproject-declare-a-project-table-so-maturin-bundles.patch new file mode 100644 index 000000000..cffe04595 --- /dev/null +++ b/patches/rjieba/0.2.1/0001-pyproject-declare-a-project-table-so-maturin-bundles.patch @@ -0,0 +1,42 @@ +From c3eb4865ac617f42cae6f199649d8d19ac175f08 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 7 Sep 2026 21:22:02 +0200 +Subject: [PATCH] pyproject: declare a [project] table so maturin bundles + LICENSE + +pyproject.toml has no [project] section, so maturin sources every +metadata field straight from Cargo.toml (pure Cargo-metadata mode). +In that mode maturin's license-file auto-discovery (LICEN[CS]E*, +COPYING*, NOTICE*, AUTHORS*) never runs -- it only fires inside the +[project]-merging code path -- so every wheel it builds ships no +LICENSE at all, even though Cargo.toml declares license = "MIT" and +a root LICENSE file exists. + +Add a minimal [project] table with the currently Cargo-sourced fields +listed under dynamic (so maturin keeps merging them from Cargo.toml +unchanged) plus an explicit license-files glob, which makes maturin +copy LICENSE into .dist-info/licenses/LICENSE. + +Upstream-Status: To upstream [not yet submitted; no fork of messense/rjieba-py to push from] +--- + pyproject.toml | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/pyproject.toml b/pyproject.toml +index 74b1b48..b89780a 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -2,5 +2,10 @@ + requires = ["maturin>=1.0,<2"] + build-backend = "maturin" + ++[project] ++name = "rjieba" ++dynamic = ["version", "description", "readme", "authors", "license", "urls"] ++license-files = ["LICENSE"] ++ + [tool.maturin] + features = ["pyo3/extension-module"] +-- +2.50.1 (Apple Git-155) +