Skip to content

Commit ecbfd45

Browse files
committed
sentencepiece: build wheels for riscv64
Refs #164 Signed-off-by: Bruno Verachten <gounthar@gmail.com>
1 parent 74b17f7 commit ecbfd45

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
name: Build sentencepiece wheels (riscv64)
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'sentencepiece version to build (git tag without leading v, e.g. 0.2.2)'
9+
required: true
10+
default: '0.2.2'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/build-sentencepiece.yml'
14+
- 'actions/publish-to-gitlab/**'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ inputs.version || '0.2.2' }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: read # to fetch code (actions/checkout)
22+
23+
env:
24+
SENTENCEPIECE_VERSION: ${{ inputs.version || '0.2.2' }}
25+
UV_EXTRA_INDEX_URL: https://pypi.riseproject.dev/simple/
26+
UV_INDEX_STRATEGY: unsafe-best-match
27+
UV_ONLY_BINARY: ':all:'
28+
29+
jobs:
30+
build_wheels:
31+
name: Build sentencepiece ${{ inputs.version || '0.2.2' }} ${{ matrix.python }}-manylinux_riscv64
32+
runs-on: ubuntu-24.04-riscv
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
python: ["cp312", "cp313", "cp314", "cp314t"]
37+
38+
steps:
39+
# sentencepiece's Python packaging lives in the `python/` subdirectory
40+
# (setup.py + pyproject.toml there), so cibuildwheel is pointed at it via
41+
# package-dir. The C++ core is vendored through a submodule, hence
42+
# submodules: true.
43+
- name: Checkout sentencepiece v${{ env.SENTENCEPIECE_VERSION }}
44+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
45+
with:
46+
repository: google/sentencepiece
47+
ref: v${{ env.SENTENCEPIECE_VERSION }}
48+
submodules: true
49+
persist-credentials: false
50+
51+
- name: Build wheels
52+
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
53+
with:
54+
package-dir: python
55+
env:
56+
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
57+
CIBW_BUILD_VERBOSITY: 1
58+
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=8
59+
# test-sources are resolved relative to the checkout root, so the
60+
# path is prefixed with python/. gen_stubs_test imports a repo-level
61+
# helper module that is not part of the copied test tree, and the
62+
# manual cleanup script is not a pytest module; both are skipped.
63+
CIBW_TEST_SOURCES: python/test
64+
CIBW_TEST_COMMAND: >-
65+
pytest -v python/test
66+
--ignore=python/test/gen_stubs_test.py
67+
--ignore=python/test/clean_sentencepiece_test_manual.py
68+
69+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
70+
with:
71+
name: sentencepiece-${{ env.SENTENCEPIECE_VERSION }}-${{ matrix.python }}-manylinux_riscv64
72+
path: ./wheelhouse/*.whl
73+
if-no-files-found: error
74+
75+
publish:
76+
name: Publish sentencepiece ${{ inputs.version || '0.2.2' }} to GitLab
77+
needs: build_wheels
78+
# Only publish when the workflow was triggered from main with a specific
79+
# version. Manual trigger is the only entry point, so checking the ref is
80+
# enough to gate uploads.
81+
if: github.ref == 'refs/heads/main'
82+
runs-on: ubuntu-latest
83+
permissions:
84+
contents: read
85+
86+
steps:
87+
- name: Download wheels
88+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
89+
with:
90+
pattern: sentencepiece-${{ env.SENTENCEPIECE_VERSION }}-*-manylinux_riscv64
91+
path: dist
92+
merge-multiple: true
93+
94+
- name: Publish to GitLab PyPI registry
95+
uses: riseproject-dev/python-wheels/actions/publish-to-gitlab@main
96+
with:
97+
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
98+
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
99+
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
100+
files: |
101+
dist/*.whl

0 commit comments

Comments
 (0)