Skip to content

docs: Update projects (#2194) #74

docs: Update projects (#2194)

docs: Update projects (#2194) #74

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `build_wheels` job of
# https://github.com/explosion/spacy-pkuseg/blob/release-v1.0.1/.github/workflows/cibuildwheel.yml
# and on the `tests` job of
# https://github.com/explosion/spacy-pkuseg/blob/release-v1.0.1/.github/workflows/tests.yml
name: Build spacy-pkuseg wheels (riscv64)
on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/spacy-pkuseg.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-spacy-pkuseg.yml'
- 'docs/packages/spacy-pkuseg.yaml'
- 'patches/spacy-pkuseg/**'
push:
branches: [main]
paths:
- '.github/workflows/build-spacy-pkuseg.yml'
- 'docs/packages/spacy-pkuseg.yaml'
- 'patches/spacy-pkuseg/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
env:
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
jobs:
setup:
uses: $/.github/workflows/_setup.yml
with:
package: spacy-pkuseg
version: ${{ inputs.version }}
build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build spacy-pkuseg ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
python:
- "cp312"
- "cp313"
- "cp314"
- "cp314t"
env:
SPACY_PKUSEG_VERSION: ${{ matrix.version }}
steps:
- name: Checkout spacy-pkuseg ${{ env.SPACY_PKUSEG_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: explosion/spacy-pkuseg
ref: release-v${{ env.SPACY_PKUSEG_VERSION }}
persist-credentials: false
- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false
- name: Patch spacy-pkuseg source
run: git apply python-wheels/patches/spacy-pkuseg/${{ env.SPACY_PKUSEG_VERSION }}/*.patch
- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
only: ${{ matrix.python }}-manylinux_riscv64
env:
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
# cython and numpy (build) and numpy and srsly (runtime) have no riscv64
# wheels on public PyPI; both environments resolve them from our registry.
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
# The extensions do not declare free-threading support, so importing them under
# cp314t re-enables the GIL with a RuntimeWarning that -Werror turns fatal;
# asking for the GIL up front is the same outcome without the warning. Ignored
# on the GIL builds.
CIBW_TEST_ENVIRONMENT: PYTHON_GIL=1
# Upstream leaves cibuildwheel's test-command empty and runs the suite from
# tests.yml instead; that is the pytest line below. The bundled suite only
# imports the package, so the checks before it exercise the extensions.
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: >-
python -c "import math, numpy as np;
from spacy_pkuseg.inference import run_viterbi;
from spacy_pkuseg.feature_extractor import get_slice_str;
score, states = run_viterbi(np.array([[0., 3.], [2., 0.], [0., 5.]]), np.array([[0., 1.], [.5, 0.]]));
assert list(states) == [1, 0, 1], states;
assert abs(score - math.exp(11.5)) < 1e-6 * score, score;
assert get_slice_str('abcdef', 1, 3, 6) == 'bcd'"
&& python -m pytest --pyargs spacy_pkuseg -Werror
- name: Check the extension modules made it into the wheel
run: |
python3 - wheelhouse/*.whl <<'EOF'
import sys, zipfile
expected = {"spacy_pkuseg/feature_extractor", "spacy_pkuseg/inference",
"spacy_pkuseg/postag/feature_extractor"}
for whl in sys.argv[1:]:
found = {n.split(".", 1)[0] for n in zipfile.ZipFile(whl).namelist()
if n.endswith(".so")}
assert found == expected, (whl, found)
print(whl, "ok")
EOF
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: spacy-pkuseg-${{ env.SPACY_PKUSEG_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: wheelhouse/*.whl
if-no-files-found: error
publish:
name: Publish spacy-pkuseg ${{ matrix.version }}
needs: [setup, build_wheels]
if: needs.setup.outputs.versions != '[]'
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
permissions:
contents: write
pull-requests: write
uses: $/.github/workflows/_publish-wheel.yml
secrets:
app-private-key: ${{ secrets.RISEPROJECT_APP_PRIVATE_KEY }}
with:
artifact-pattern: spacy-pkuseg-${{ matrix.version }}-*-manylinux_riscv64