Skip to content

Commit 0201132

Browse files
committed
numpy: add riscv64 workflow
Upstream numpy has started building riscv64 wheels, but they are not yet deploying them. In the meantime, we still need to support builds and publish them to the RISE registry. Use the custom publish-to-gitlab action in the publish step, since the registry is on GitLab. Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 36c57ff commit 0201132

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

.github/workflows/build-numpy.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
name: Build numpy wheels (riscv64)
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'numpy version to build (git tag without leading v, e.g. 2.5.0)'
9+
required: true
10+
default: '2.5.0'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/build-numpy.yml'
14+
- 'actions/publish-to-gitlab/**'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ inputs.version || '2.5.0' }}-${{ 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+
# `inputs.version` is empty on pull_request events; default to 2.5.0 there.
25+
NUMPY_VERSION: ${{ inputs.version || '2.5.0' }}
26+
27+
jobs:
28+
build_wheels:
29+
name: Build numpy ${{ env.NUMPY_VERSION }} ${{ matrix.python }}-manylinux_riscv64
30+
runs-on: ubuntu-24.04-riscv
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python: ["cp312"]
35+
36+
env:
37+
CCACHE_DIR: ${{ github.workspace }}/.ccache
38+
CCACHE_BASEDIR: "/project"
39+
CCACHE_COMPILERCHECK: "content"
40+
41+
steps:
42+
- name: Checkout python-wheels
43+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
44+
with:
45+
persist-credentials: false
46+
47+
- name: Checkout numpy v${{ env.NUMPY_VERSION }}
48+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
49+
with:
50+
repository: numpy/numpy
51+
ref: v${{ env.NUMPY_VERSION }}
52+
path: upstream
53+
submodules: true
54+
persist-credentials: false
55+
56+
- name: Restore compilation cache
57+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
58+
id: ccache-restore
59+
with:
60+
path: ${{ env.CCACHE_DIR }}
61+
key: ccache-wheels-numpy-v${{ env.NUMPY_VERSION }}-manylinux_riscv64-${{ matrix.python }}-${{ github.run_id }}
62+
restore-keys: |
63+
ccache-wheels-numpy-v${{ env.NUMPY_VERSION }}-manylinux_riscv64-${{ matrix.python }}-
64+
ccache-wheels-numpy-manylinux_riscv64-${{ matrix.python }}-
65+
66+
- name: Build wheels
67+
uses: pypa/cibuildwheel@294735312765b09d24a2fbec22660ce817587d55 # v4.1.0
68+
with:
69+
package-dir: upstream
70+
env:
71+
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
72+
CIBW_BEFORE_ALL_LINUX: |
73+
set -eux
74+
CCACHE_VERSION=4.13.6
75+
curl -fsSL https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static.tar.gz | \
76+
tar -xvzf - --strip-components 1 -C /usr/local/bin ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static/ccache
77+
ccache --version
78+
ccache --zero-stats
79+
CIBW_ENVIRONMENT_PASS_LINUX: >-
80+
CCACHE_BASEDIR
81+
CCACHE_COMPILERCHECK
82+
CIBW_CONTAINER_ENGINE: "docker; create_args: --volume ${{ env.CCACHE_DIR }}:/root/.ccache"
83+
84+
- name: Save compilation cache
85+
if: always() && github.ref == 'refs/heads/main'
86+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
87+
with:
88+
path: ${{ env.CCACHE_DIR }}
89+
key: ccache-wheels-numpy-v${{ env.NUMPY_VERSION }}-manylinux_riscv64-${{ matrix.python }}-${{ github.run_id }}
90+
91+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
92+
with:
93+
name: numpy-${{ env.NUMPY_VERSION }}-${{ matrix.python }}-manylinux_riscv64
94+
path: ./wheelhouse/*.whl
95+
if-no-files-found: error
96+
97+
publish:
98+
name: Publish numpy ${{ env.NUMPY_VERSION }} to GitLab
99+
needs: build_wheels
100+
# Only publish when the workflow was triggered from main with a specific
101+
# version. Manual trigger is the only entry point, so checking the ref is
102+
# enough to gate uploads.
103+
if: github.ref == 'refs/heads/main'
104+
runs-on: ubuntu-24.04-riscv
105+
permissions:
106+
contents: read
107+
108+
steps:
109+
- name: Checkout python-wheels
110+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
111+
with:
112+
persist-credentials: false
113+
114+
- name: Download wheels
115+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
116+
with:
117+
pattern: numpy-${{ env.NUMPY_VERSION }}-*-manylinux_riscv64
118+
path: dist
119+
merge-multiple: true
120+
121+
- name: Publish to GitLab Package Registry
122+
uses: ./actions/publish-to-gitlab
123+
with:
124+
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
125+
token-type: deploy-token
126+
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
127+
package-name: numpy
128+
package-version: ${{ env.NUMPY_VERSION }}
129+
files: |
130+
dist/*.whl

0 commit comments

Comments
 (0)