Skip to content

Commit bfc85ae

Browse files
committed
matplotlib: add build, test workflows for riscv64
We make use of uv to simplify the pipeline in several ways: - replace 'python -m pip' with 'uv pip' - set cache to match uv usage - use uv for CIBW_BUILD_FRONTEND - set UV_EXTRA_INDEX_URL to our GitLab registry, with UV_INDEX_STRATEGY=unsafe-best-match and UV_ONLY_BINARY=:all: so we pick whichever source has a binary wheel - drop 'allow-prereleases' from setup-uv since this only applies to the setup-python action Also make sure we explicitly skip musllinux builds, since upstream isn't building them either. Otherwise, we run into issues with uv setup: |Building cp314-musllinux_riscv64 wheel |CPython 3.14 musllinux riscv64 | |Setting up build environment... | | + mkdir -p / | + /opt/python/cp39-cp39/bin/python -c 'import sys, json, os; json.dump(os.environ.copy(), sys.stdout)' | + which python | + which uv | ✕ 4.07s |Error: cibuildwheel: Command ['which', 'uv'] failed with code 1. | |Error: Process completed with exit code 1. Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 713f371 commit bfc85ae

2 files changed

Lines changed: 446 additions & 0 deletions

File tree

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
---
2+
name: Build matplotlib wheels (riscv64)
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'matplotlib version to build (git tag without leading v, e.g. 3.11.0)'
9+
required: true
10+
default: '3.11.0'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/build-matplotlib.yml'
14+
- '.github/workflows/test-matplotlib.yml'
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ inputs.version || '3.11.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 there.
25+
MPL_VERSION: ${{ inputs.version || '3.11.0' }}
26+
# Query PyPI + gitlab riscv64 mirror; pick best compatible wheel
27+
# (`unsafe-best-match` = pip-like). Refuse sdist for dependencies so uv
28+
# selects the gitlab riscv64 wheel when PyPI lacks one instead of falling
29+
# back to a source build.
30+
UV_EXTRA_INDEX_URL: https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
31+
UV_INDEX_STRATEGY: unsafe-best-match
32+
UV_ONLY_BINARY: ':all:'
33+
34+
jobs:
35+
build_sdist:
36+
name: Build matplotlib ${{ inputs.version || '3.11.0' }} sdist
37+
runs-on: ubuntu-24.04-riscv
38+
permissions:
39+
contents: read
40+
outputs:
41+
SDIST_NAME: ${{ steps.sdist.outputs.SDIST_NAME }}
42+
43+
steps:
44+
- name: Checkout python-wheels
45+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
46+
with:
47+
path: python-wheels-repo
48+
persist-credentials: false
49+
50+
- name: Checkout matplotlib v${{ env.MPL_VERSION }}
51+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
52+
with:
53+
repository: matplotlib/matplotlib
54+
ref: v${{ env.MPL_VERSION }}
55+
fetch-depth: 0
56+
persist-credentials: false
57+
58+
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
59+
name: Install Python
60+
with:
61+
python-version: '3.12'
62+
activate-environment: true
63+
enable-cache: false
64+
65+
# Something changed somewhere that prevents the downloaded-at-build-time
66+
# licenses from being included in built wheels, so pre-download them so
67+
# that they exist before the build and are included.
68+
- name: Pre-download bundled licenses
69+
run: >
70+
curl -Lo LICENSE/LICENSE_QHULL
71+
https://github.com/qhull/qhull/raw/2020.2/COPYING.txt
72+
73+
- name: Install dependencies
74+
run: uv pip install build twine
75+
76+
- name: Build sdist
77+
id: sdist
78+
run: |
79+
python -m build --sdist
80+
python ci/export_sdist_name.py
81+
82+
- name: Check README rendering for PyPI
83+
run: twine check dist/*
84+
85+
- name: Upload sdist result
86+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
87+
with:
88+
name: matplotlib-${{ env.MPL_VERSION }}-cibw-sdist
89+
path: dist/*.tar.gz
90+
if-no-files-found: error
91+
92+
build_wheels:
93+
needs: build_sdist
94+
name: Build matplotlib ${{ inputs.version || '3.11.0' }} wheels for riscv64
95+
permissions:
96+
contents: read
97+
runs-on: ubuntu-24.04-riscv
98+
99+
steps:
100+
- name: Checkout python-wheels
101+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
102+
with:
103+
path: python-wheels-repo
104+
persist-credentials: false
105+
106+
- name: Download sdist
107+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
108+
with:
109+
name: matplotlib-${{ env.MPL_VERSION }}-cibw-sdist
110+
path: dist/
111+
112+
- name: Build wheels for CPython 3.14
113+
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
114+
with:
115+
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
116+
env:
117+
CIBW_BUILD: "cp314-* cp314t-*"
118+
CIBW_ARCHS: "riscv64"
119+
# Skip musllinux: upstream matplotlib isn't building it either
120+
CIBW_SKIP: "*-musllinux_*"
121+
CIBW_BUILD_FRONTEND: "build[uv]"
122+
CIBW_ENVIRONMENT: >-
123+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
124+
UV_INDEX_STRATEGY=unsafe-best-match
125+
UV_ONLY_BINARY=:all:
126+
127+
- name: Build wheels for CPython 3.13
128+
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
129+
with:
130+
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
131+
env:
132+
CIBW_BUILD: "cp313-*"
133+
CIBW_ARCHS: "riscv64"
134+
# Skip musllinux: upstream matplotlib isn't building it either
135+
CIBW_SKIP: "*-musllinux_*"
136+
CIBW_BUILD_FRONTEND: "build[uv]"
137+
CIBW_ENVIRONMENT: >-
138+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
139+
UV_INDEX_STRATEGY=unsafe-best-match
140+
UV_ONLY_BINARY=:all:
141+
142+
- name: Build wheels for CPython 3.12
143+
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
144+
with:
145+
package-dir: dist/${{ needs.build_sdist.outputs.SDIST_NAME }}
146+
env:
147+
CIBW_BUILD: "cp312-*"
148+
CIBW_ARCHS: "riscv64"
149+
# Skip musllinux: upstream matplotlib isn't building it either
150+
CIBW_SKIP: "*-musllinux_*"
151+
CIBW_BUILD_FRONTEND: "build[uv]"
152+
CIBW_ENVIRONMENT: >-
153+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
154+
UV_INDEX_STRATEGY=unsafe-best-match
155+
UV_ONLY_BINARY=:all:
156+
157+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
158+
with:
159+
name: matplotlib-${{ env.MPL_VERSION }}-cibw-wheels-riscv64
160+
path: ./wheelhouse/*.whl
161+
if-no-files-found: error
162+
163+
publish:
164+
name: Publish matplotlib ${{ inputs.version || '3.11.0' }} to GitLab
165+
needs: build_wheels
166+
# Only publish when the workflow was triggered from main with a specific
167+
# version. Manual trigger is the only entry point that reaches main;
168+
# PR runs sit on refs/pull/<n>/merge and skip this job.
169+
if: github.ref == 'refs/heads/main'
170+
runs-on: ubuntu-24.04-riscv
171+
permissions:
172+
contents: read
173+
174+
steps:
175+
- name: Checkout python-wheels
176+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
177+
with:
178+
path: python-wheels-repo
179+
persist-credentials: false
180+
181+
- name: Download wheels
182+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
183+
with:
184+
name: matplotlib-${{ env.MPL_VERSION }}-cibw-wheels-riscv64
185+
path: dist
186+
187+
- name: Publish to GitLab PyPI registry
188+
uses: ./python-wheels-repo/actions/publish-to-gitlab
189+
with:
190+
gitlab-username: ${{ vars.GITLAB_DEPLOY_USER }}
191+
gitlab-token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
192+
gitlab-project-id: ${{ vars.GITLAB_PROJECT_ID }}
193+
files: |
194+
dist/*.whl

0 commit comments

Comments
 (0)