Skip to content

Commit 45fefb5

Browse files
authored
rjieba: add build-rjieba.yml for riscv64 wheels (#1445)
* **Package**: `rjieba` * **Version**: 0.2.1 * **Source**: https://github.com/messense/rjieba-py * **Docs**: https://github.com/messense/rjieba-py Compiles a PyO3/maturin binding over the `jieba-rs` Chinese word segmentation crate. Upstream publishes no riscv64 wheel. Mirrors upstream's `CI.yml` `linux` job. **Differs from upstream** - musllinux dropped - rustup.rs ships no riscv64 musl toolchain **Testing** - same as upstream **License**: OK
1 parent f09c861 commit 45fefb5

2 files changed

Lines changed: 160 additions & 0 deletions

File tree

.github/workflows/build-rjieba.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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/messense/rjieba-py/blob/v0.2.1/.github/workflows/CI.yml
6+
name: Build rjieba wheels (riscv64)
7+
8+
on:
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: 'rjieba version to build (git tag without the leading v, e.g. 0.2.1)'
13+
required: true
14+
default: '0.2.1'
15+
pull_request:
16+
paths:
17+
- '.github/workflows/build-rjieba.yml'
18+
- 'patches/rjieba/**'
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ inputs.version || '0.2.1' }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
permissions:
25+
contents: read # to fetch code (actions/checkout)
26+
27+
env:
28+
# `inputs.version` is empty on pull_request events; default to 0.2.1 there.
29+
RJIEBA_VERSION: ${{ inputs.version || '0.2.1' }}
30+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
31+
32+
jobs:
33+
setup:
34+
uses: $/.github/workflows/_setup.yml
35+
36+
build_wheels:
37+
needs: [setup]
38+
name: Build rjieba ${{ inputs.version || '0.2.1' }} ${{ matrix.tag }}-manylinux_riscv64
39+
runs-on: ubuntu-24.04-riscv
40+
timeout-minutes: 60
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
include:
45+
# pyo3's abi3-py38 feature (Cargo.toml) gives one wheel for every
46+
# GIL-ful interpreter; free-threaded builds disable abi3 and get
47+
# their own (upstream's CI.yml builds them as a separate maturin
48+
# pass with `-i python3.14t` for the same reason).
49+
- tag: cp38-abi3
50+
# Built on cp312 -- the oldest interpreter in our matrix -- and
51+
# re-tested on cp313/cp314 via find_compatible_wheel.
52+
build: >-
53+
cp312-manylinux_riscv64 cp313-manylinux_riscv64
54+
cp314-manylinux_riscv64
55+
- tag: cp314t
56+
build: cp314t-manylinux_riscv64
57+
58+
steps:
59+
- name: Checkout rjieba v${{ env.RJIEBA_VERSION }}
60+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
61+
with:
62+
repository: messense/rjieba-py
63+
ref: v${{ env.RJIEBA_VERSION }}
64+
persist-credentials: false
65+
66+
- name: Checkout python-wheels
67+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
68+
with:
69+
path: python-wheels
70+
persist-credentials: false
71+
72+
- name: Patch rjieba source
73+
run: git apply python-wheels/patches/rjieba/${{ env.RJIEBA_VERSION }}/*.patch
74+
75+
- name: Build and test wheel
76+
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
77+
with:
78+
output-dir: wheelhouse/
79+
env:
80+
# musllinux is dropped: rustup.rs ships no riscv64 musl toolchain.
81+
CIBW_BUILD: ${{ matrix.build }}
82+
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
83+
# rjieba ships no [tool.cibuildwheel], so the Rust toolchain its
84+
# maturin backend needs is installed in-container here.
85+
CIBW_BEFORE_ALL_LINUX: >-
86+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
87+
CIBW_ENVIRONMENT_LINUX: PATH="$PATH:$HOME/.cargo/bin"
88+
CIBW_TEST_REQUIRES: pytest
89+
CIBW_TEST_SOURCES: tests
90+
CIBW_TEST_COMMAND: >-
91+
python -c "import rjieba; assert rjieba.rjieba.__file__.endswith('.so'), rjieba.rjieba.__file__" &&
92+
python -m pytest -v tests
93+
94+
- name: Check the licence made it into the wheel
95+
run: |
96+
python3 - wheelhouse/*.whl <<'EOF'
97+
import sys, zipfile
98+
for whl in sys.argv[1:]:
99+
names = zipfile.ZipFile(whl).namelist()
100+
assert any(n.endswith("dist-info/licenses/LICENSE") for n in names), names
101+
print(whl, "ok")
102+
EOF
103+
104+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
105+
with:
106+
name: rjieba-${{ env.RJIEBA_VERSION }}-${{ matrix.tag }}-manylinux_riscv64
107+
path: wheelhouse/*.whl
108+
if-no-files-found: error
109+
110+
publish:
111+
name: Publish rjieba ${{ inputs.version || '0.2.1' }}
112+
needs: [setup, build_wheels]
113+
permissions:
114+
contents: write
115+
pull-requests: write
116+
uses: $/.github/workflows/_publish-wheel.yml
117+
with:
118+
artifact-pattern: rjieba-${{ inputs.version || '0.2.1' }}-*-manylinux_riscv64
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From c3eb4865ac617f42cae6f199649d8d19ac175f08 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Mon, 7 Sep 2026 21:22:02 +0200
4+
Subject: [PATCH] pyproject: declare a [project] table so maturin bundles
5+
LICENSE
6+
7+
pyproject.toml has no [project] section, so maturin sources every
8+
metadata field straight from Cargo.toml (pure Cargo-metadata mode).
9+
In that mode maturin's license-file auto-discovery (LICEN[CS]E*,
10+
COPYING*, NOTICE*, AUTHORS*) never runs -- it only fires inside the
11+
[project]-merging code path -- so every wheel it builds ships no
12+
LICENSE at all, even though Cargo.toml declares license = "MIT" and
13+
a root LICENSE file exists.
14+
15+
Add a minimal [project] table with the currently Cargo-sourced fields
16+
listed under dynamic (so maturin keeps merging them from Cargo.toml
17+
unchanged) plus an explicit license-files glob, which makes maturin
18+
copy LICENSE into <pkg>.dist-info/licenses/LICENSE.
19+
20+
Upstream-Status: To upstream [not yet submitted; no fork of messense/rjieba-py to push from]
21+
---
22+
pyproject.toml | 5 +++++
23+
1 file changed, 5 insertions(+)
24+
25+
diff --git a/pyproject.toml b/pyproject.toml
26+
index 74b1b48..b89780a 100644
27+
--- a/pyproject.toml
28+
+++ b/pyproject.toml
29+
@@ -2,5 +2,10 @@
30+
requires = ["maturin>=1.0,<2"]
31+
build-backend = "maturin"
32+
33+
+[project]
34+
+name = "rjieba"
35+
+dynamic = ["version", "description", "readme", "authors", "license", "urls"]
36+
+license-files = ["LICENSE"]
37+
+
38+
[tool.maturin]
39+
features = ["pyo3/extension-module"]
40+
--
41+
2.50.1 (Apple Git-155)
42+

0 commit comments

Comments
 (0)