Skip to content

Commit 5816bb0

Browse files
committed
matplotlib: use uv
- 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 Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent f6b759e commit 5816bb0

2 files changed

Lines changed: 46 additions & 16 deletions

File tree

.github/workflows/build-matplotlib.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ on:
1010

1111
permissions: {}
1212

13+
env:
14+
# Query PyPI + gitlab riscv64 mirror; pick best compatible wheel
15+
# (`unsafe-best-match` = pip-like). `first-index` stops at PyPI for sdist
16+
# packages like cffi, never consulting gitlab for the riscv64 wheel.
17+
UV_EXTRA_INDEX_URL: https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
18+
UV_INDEX_STRATEGY: unsafe-best-match
19+
# Refuse sdist for dependencies — wheels only. Forces uv to pick the gitlab
20+
# riscv64 wheel instead of falling back to building cffi/cryptography/etc.
21+
UV_ONLY_BINARY: ':all:'
22+
1323
jobs:
1424
build_sdist:
1525
name: Build sdist
@@ -50,7 +60,7 @@ jobs:
5060
https://github.com/qhull/qhull/raw/2020.2/COPYING.txt
5161
5262
- name: Install dependencies
53-
run: python -m pip install build twine
63+
run: uv pip install build twine
5464

5565
- name: Build sdist
5666
id: sdist
@@ -96,7 +106,11 @@ jobs:
96106
env:
97107
CIBW_BUILD: "cp314-* cp314t-*"
98108
CIBW_ARCHS: "riscv64"
99-
CIBW_ENVIRONMENT: 'PIP_PREFER_BINARY=1 PIP_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple'
109+
CIBW_BUILD_FRONTEND: "build[uv]"
110+
CIBW_ENVIRONMENT: >-
111+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
112+
UV_INDEX_STRATEGY=unsafe-best-match
113+
UV_ONLY_BINARY=:all:
100114
101115
- name: Build wheels for CPython 3.13
102116
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
@@ -105,7 +119,11 @@ jobs:
105119
env:
106120
CIBW_BUILD: "cp313-*"
107121
CIBW_ARCHS: "riscv64"
108-
CIBW_ENVIRONMENT: 'PIP_PREFER_BINARY=1 PIP_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple'
122+
CIBW_BUILD_FRONTEND: "build[uv]"
123+
CIBW_ENVIRONMENT: >-
124+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
125+
UV_INDEX_STRATEGY=unsafe-best-match
126+
UV_ONLY_BINARY=:all:
109127
110128
- name: Build wheels for CPython 3.12
111129
uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
@@ -114,7 +132,11 @@ jobs:
114132
env:
115133
CIBW_BUILD: "cp312-*"
116134
CIBW_ARCHS: "riscv64"
117-
CIBW_ENVIRONMENT: 'PIP_PREFER_BINARY=1 PIP_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple'
135+
CIBW_BUILD_FRONTEND: "build[uv]"
136+
CIBW_ENVIRONMENT: >-
137+
UV_EXTRA_INDEX_URL=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
138+
UV_INDEX_STRATEGY=unsafe-best-match
139+
UV_ONLY_BINARY=:all:
118140
119141
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
120142
with:

.github/workflows/test-matplotlib.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ env:
1717
NO_AT_BRIDGE: 1 # Necessary for GTK3 interactive test.
1818
OPENBLAS_NUM_THREADS: 1
1919
PYTHONFAULTHANDLER: 1
20+
# Query PyPI + gitlab riscv64 mirror; pick best compatible wheel.
21+
# `first-index` is wrong here — PyPI has cffi sdist so uv would never check
22+
# gitlab for the riscv64 wheel. `unsafe-best-match` is pip-like and selects
23+
# the riscv64 wheel from gitlab when PyPI lacks one.
24+
UV_EXTRA_INDEX_URL: https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
25+
UV_INDEX_STRATEGY: unsafe-best-match
26+
# Refuse sdist for dependencies — wheels only. Forces uv to pick the gitlab
27+
# riscv64 wheel instead of falling back to building cffi/cryptography/etc.
28+
UV_ONLY_BINARY: ':all:'
2029

2130
jobs:
2231
test:
@@ -53,7 +62,6 @@ jobs:
5362
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
5463
with:
5564
python-version: ${{ matrix.python-version }}
56-
allow-prereleases: true
5765
activate-environment: true
5866
enable-cache: false
5967

@@ -103,15 +111,15 @@ jobs:
103111
sudo apt-get install -yy --no-install-recommends ffmpeg poppler-utils
104112
sudo apt-get install -yy --no-install-recommends libgirepository-2.0-dev
105113
106-
- name: Cache pip
114+
- name: Cache uv
107115
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
108116
with:
109-
path: ~/.cache/pip
117+
path: ~/.cache/uv
110118
key: |
111-
${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{
119+
${{ matrix.os }}-py${{ matrix.python-version }}-uv-${{
112120
hashFiles('upstream/pyproject.toml', 'upstream/ci/minver-requirements.txt') }}
113121
restore-keys: |
114-
${{ matrix.os }}-py${{ matrix.python-version }}-pip-
122+
${{ matrix.os }}-py${{ matrix.python-version }}-uv-
115123
- name: Cache ccache
116124
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
117125
with:
@@ -136,24 +144,24 @@ jobs:
136144
run: |
137145
# Upgrade pip and setuptools and wheel to get as clean an install as
138146
# possible.
139-
python -m pip install --upgrade pip setuptools wheel
147+
uv pip install --upgrade pip setuptools wheel
140148
141149
# Install dependencies from PyPI.
142150
# Preinstall build requirements to enable no-build-isolation builds.
143-
python -m pip install --upgrade --prefer-binary \
151+
uv pip install --upgrade --prefer-binary \
144152
--group build --group test
145153
146154
# Install optional dependencies from PyPI.
147155
# Sphinx is needed to run sphinxext tests
148-
python -m pip install --upgrade sphinx!=6.1.2
156+
uv pip install --upgrade sphinx!=6.1.2
149157
150158
# GUI toolkits are pip-installable only for some versions of Python
151159
# so don't fail if we can't install them. Make it easier to check
152160
# whether the install was successful by trying to import the toolkit
153161
# (sometimes, the install appears to be successful but shared
154162
# libraries cannot be loaded at runtime, so an actual import is a
155163
# better check).
156-
python -m pip install --upgrade pycairo 'cairocffi>=0.8' 'PyGObject' &&
164+
uv pip install --upgrade pycairo 'cairocffi>=0.8' 'PyGObject' &&
157165
(
158166
python -c 'import gi; gi.require_version("Gtk", "4.0"); from gi.repository import Gtk' &&
159167
echo 'PyGObject 4 is available' || echo 'PyGObject 4 is not available'
@@ -163,11 +171,11 @@ jobs:
163171
)
164172
165173
# PyQt5 has no riscv64 wheels; skip.
166-
python -mpip install --upgrade --only-binary :all: pyqt6 &&
174+
uv pip install --upgrade --only-binary :all: pyqt6 &&
167175
python -c 'import PyQt6.QtCore' &&
168176
echo 'PyQt6 is available' ||
169177
echo 'PyQt6 is not available'
170-
python -mpip install --upgrade --only-binary :all: pyside6 &&
178+
uv pip install --upgrade --only-binary :all: pyside6 &&
171179
python -c 'import PySide6.QtCore' &&
172180
echo 'PySide6 is available' ||
173181
echo 'PySide6 is not available'
@@ -179,7 +187,7 @@ jobs:
179187
180188
export CPPFLAGS='--coverage -fprofile-abs-path'
181189
182-
python -m pip install --no-deps --no-build-isolation --verbose \
190+
uv pip install --no-deps --no-build-isolation --verbose \
183191
--config-settings=setup-args="-DrcParams-backend=Agg" \
184192
--editable .[dev]
185193

0 commit comments

Comments
 (0)