Skip to content

Commit 9f29dbe

Browse files
luhenrygounthar
andcommitted
Add wheel building and testing on Linux-riscv64
Co-Authored-By: Bruno Verachten <[email protected]>
1 parent 8ed4764 commit 9f29dbe

3 files changed

Lines changed: 92 additions & 2 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Workflow to build and test wheels, similarly to numpy/numpy-release.
2+
# To work on these jobs in a fork, comment out:
3+
#
4+
# if: github.repository == 'numpy/numpy'
5+
name: Linux-riscv64 Wheel builder
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
- maintenance/**
12+
paths-ignore:
13+
- '**.pyi'
14+
- '**.md'
15+
- '**.rst'
16+
- 'tools/stubtest/**'
17+
workflow_dispatch:
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read # to fetch code (actions/checkout)
25+
26+
jobs:
27+
build_wheels:
28+
name: Build wheel ${{ matrix.python }}-manylinux_riscv64-
29+
# To enable this job on a fork, comment out:
30+
if: github.repository == 'numpy/numpy'
31+
runs-on: ubuntu-24.04-riscv
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
python: ["cp312"]
36+
37+
env:
38+
CCACHE_DIR: ${{ github.workspace }}/.ccache
39+
CCACHE_BASEDIR: "/project"
40+
CCACHE_COMPILERCHECK: "content"
41+
steps:
42+
- name: Checkout numpy
43+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
44+
with:
45+
submodules: true
46+
persist-credentials: false
47+
48+
- name: Restore compilation cache
49+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
50+
id: ccache-restore
51+
with:
52+
path: ${{ env.CCACHE_DIR }}
53+
key: ccache-wheels-manylinux_riscv64-${{ matrix.python }}-${{ github.run_id }}
54+
restore-keys: |
55+
ccache-wheels-manylinux_riscv64-${{ matrix.python }}-
56+
57+
- name: Build wheels
58+
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
59+
env:
60+
CIBW_BUILD: ${{ matrix.python }}-manylinux_riscv64
61+
CIBW_BEFORE_ALL_LINUX: |
62+
set -eux
63+
CCACHE_VERSION=4.13.6
64+
curl -fsSL https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static.tar.gz | \
65+
tar -xvzf - --strip-components 1 -C /usr/local/bin ccache-${CCACHE_VERSION}-linux-$(uname -m)-musl-static/ccache
66+
ccache --version
67+
ccache --zero-stats
68+
CIBW_ENVIRONMENT_PASS_LINUX: >-
69+
CCACHE_BASEDIR
70+
CCACHE_COMPILERCHECK
71+
CIBW_CONTAINER_ENGINE: "docker; create_args: --volume ${{ env.CCACHE_DIR }}:/root/.ccache"
72+
73+
- name: Save compilation cache
74+
if: always() && github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
75+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
76+
with:
77+
path: ${{ env.CCACHE_DIR }}
78+
key: ccache-wheels-manylinux_riscv64-${{ matrix.python }}-${{ github.run_id }}
79+
80+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
81+
with:
82+
name: ${{ matrix.python }}-manylinux_riscv64-
83+
path: ./wheelhouse/*.whl

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ build-dir = "build"
202202
[tool.cibuildwheel.linux]
203203
manylinux-x86_64-image = "manylinux_2_28"
204204
manylinux-aarch64-image = "manylinux_2_28"
205+
manylinux-riscv64-image = "manylinux_2_39"
205206
musllinux-x86_64-image = "musllinux_1_2"
206207
musllinux-aarch64-image = "musllinux_1_2"
207208

‎tools/wheels/cibw_test_command.sh‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ fi
2727

2828
# Run full tests with -n=auto. This makes pytest-xdist distribute tests across
2929
# the available N CPU cores. Also print the durations for the 10 slowest tests
30-
# to help with debugging slow or hanging tests
31-
python -c "import sys; import numpy; sys.exit(not numpy.test(label='full', extra_argv=['-n=auto', '--durations=10']))"
30+
# to help with debugging slow or hanging tests.
31+
# On riscv64 use 'fast' to stay within the CI time budget (the slowest 'full'
32+
# tests alone add ~15 min on native hardware).
33+
if [[ "$(uname -m)" == "riscv64" ]]; then
34+
python -c "import sys; import numpy; sys.exit(not numpy.test(label='fast', extra_argv=['-n=auto', '--durations=10']))"
35+
else
36+
python -c "import sys; import numpy; sys.exit(not numpy.test(label='full', extra_argv=['-n=auto', '--durations=10']))"
37+
fi

0 commit comments

Comments
 (0)