Skip to content

Commit f82f26f

Browse files
Build updates
1 parent 37d0c3d commit f82f26f

2 files changed

Lines changed: 81 additions & 104 deletions

File tree

.github/workflows/dev_build.yml

Lines changed: 71 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
2-
# Exercises the documented development build paths (venv+pip, conda, uv) from
3-
# doc/devel/development_setup.rst on all platforms.
4-
name: Dev build paths
2+
# Exercises the documented build paths from doc/devel/development_setup.rst.
3+
name: Dev builds
54

65
concurrency:
76
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
@@ -18,19 +17,19 @@ on:
1817
permissions: {}
1918

2019
jobs:
21-
# venv + pip
22-
venv-pip:
20+
build:
2321
permissions:
2422
contents: read
25-
name: "venv + pip (${{ matrix.os }})"
23+
name: "Dev builds on ${{ matrix.os }}"
2624
runs-on: ${{ matrix.os }}
2725
strategy:
2826
fail-fast: false
2927
matrix:
3028
os: [ubuntu-latest, macos-latest, windows-latest]
3129
defaults:
3230
run:
33-
shell: bash
31+
# Login shell so the conda environment can be activated in its step.
32+
shell: bash -el {0}
3433
steps:
3534
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3635
with:
@@ -40,110 +39,82 @@ jobs:
4039
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4140
with:
4241
python-version: '3.13'
42+
cache: pip
43+
cache-dependency-path: pyproject.toml
4344

44-
- name: Create environment and install
45+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
46+
with:
47+
enable-cache: true
48+
49+
- uses: mamba-org/setup-micromamba@d7c9bd84e824b79d2af72a2d4196c7f4300d3476 # v3.0.0
50+
with:
51+
init-shell: bash
52+
cache-downloads: true
53+
54+
- name: Build with venv + pip
55+
id: venv_pip
56+
continue-on-error: true
4557
run: |
46-
python -m venv .venv
47-
source .venv/bin/activate 2>/dev/null || source .venv/Scripts/activate
58+
rm -rf build
59+
python -m venv .venv-pip
60+
source .venv-pip/bin/activate 2>/dev/null || source .venv-pip/Scripts/activate
4861
python -m pip install -U pip # --group needs pip >= 25.1
4962
python -m pip install --group dev
50-
python -m pip install --verbose --no-build-isolation --group dev --editable .
63+
# Strawberry Perl's gcc on PATH shadows MSVC; --vsenv forces MSVC.
64+
VSENV=()
65+
[ "$RUNNER_OS" = Windows ] && VSENV=(--config-settings=setup-args=--vsenv)
66+
python -m pip install --verbose --no-build-isolation --group dev "${VSENV[@]}" --editable .
67+
python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
5168
52-
- name: Verify the installation
69+
- name: Build with conda + pip
70+
id: conda
71+
continue-on-error: true
5372
run: |
54-
source .venv/bin/activate 2>/dev/null || source .venv/Scripts/activate
73+
rm -rf build
74+
# Create directly, since the action's `micromamba list` crashes on
75+
# environment.yml's nbconvert[execute] spec.
76+
micromamba create -y -n mpl-dev -f environment.yml
77+
micromamba activate mpl-dev
78+
python -m pip install --verbose --no-build-isolation --group dev --editable .
5579
python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
5680
57-
# conda + pip
58-
conda:
59-
permissions:
60-
contents: read
61-
name: "conda (${{ matrix.os }})"
62-
runs-on: ${{ matrix.os }}
63-
strategy:
64-
fail-fast: false
65-
matrix:
66-
os: [ubuntu-latest, macos-latest, windows-latest]
67-
defaults:
68-
run:
69-
# Login shell so the conda environment is activated for every step.
70-
shell: bash -el {0}
71-
steps:
72-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
73-
with:
74-
fetch-depth: 0 # full history so setuptools-scm can determine the version
75-
persist-credentials: false
76-
77-
- uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2.0.7
78-
with:
79-
environment-file: environment.yml
80-
create-args: python=3.13
81-
82-
- name: Install Matplotlib in editable mode
83-
run: python -m pip install --verbose --no-build-isolation --group dev --editable .
84-
85-
- name: Verify the installation
86-
run: python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
87-
88-
# uv (pip interface)
89-
uv-pip:
90-
permissions:
91-
contents: read
92-
name: "uv pip (${{ matrix.os }})"
93-
runs-on: ${{ matrix.os }}
94-
strategy:
95-
fail-fast: false
96-
matrix:
97-
os: [ubuntu-latest, macos-latest, windows-latest]
98-
defaults:
99-
run:
100-
shell: bash
101-
steps:
102-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
103-
with:
104-
fetch-depth: 0 # full history so setuptools-scm can determine the version
105-
persist-credentials: false
106-
107-
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
108-
with:
109-
enable-cache: true
110-
111-
- name: Create environment and install
81+
- name: Build with uv pip
82+
id: uv_pip
83+
continue-on-error: true
11284
run: |
113-
uv venv --python 3.13
85+
rm -rf build
86+
uv venv --python 3.13 .venv-uvpip
87+
source .venv-uvpip/bin/activate 2>/dev/null || source .venv-uvpip/Scripts/activate
11488
uv pip install --group dev
115-
uv pip install --verbose --no-build-isolation --group dev --editable .
89+
VSENV=()
90+
[ "$RUNNER_OS" = Windows ] && VSENV=(-C setup-args=--vsenv)
91+
uv pip install --verbose --no-build-isolation --group dev "${VSENV[@]}" --editable .
92+
python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
11693
117-
- name: Verify the installation
94+
- name: Build with uv sync
95+
id: uv_sync
96+
continue-on-error: true
97+
env:
98+
UV_PROJECT_ENVIRONMENT: .venv-uvsync
11899
run: |
119-
source .venv/bin/activate 2>/dev/null || source .venv/Scripts/activate
100+
rm -rf build
101+
# Build separately without isolation, since meson-python editable breaks if
102+
# its build env is deleted.
103+
uv sync --python 3.13 --group dev --no-install-project
104+
source .venv-uvsync/bin/activate 2>/dev/null || source .venv-uvsync/Scripts/activate
105+
VSENV=()
106+
[ "$RUNNER_OS" = Windows ] && VSENV=(-C setup-args=--vsenv)
107+
uv pip install --verbose --no-build-isolation --group dev "${VSENV[@]}" --editable .
120108
python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
121109
122-
# uv sync
123-
uv-sync:
124-
permissions:
125-
contents: read
126-
name: "uv sync (${{ matrix.os }})"
127-
runs-on: ${{ matrix.os }}
128-
strategy:
129-
fail-fast: false
130-
matrix:
131-
os: [ubuntu-latest, macos-latest, windows-latest]
132-
defaults:
133-
run:
134-
shell: bash
135-
steps:
136-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
137-
with:
138-
fetch-depth: 0 # full history so setuptools-scm can determine the version
139-
persist-credentials: false
140-
141-
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
142-
with:
143-
enable-cache: true
144-
145-
- name: Create environment and install
146-
run: uv sync --python 3.13 --group dev
147-
148-
- name: Verify the installation
149-
run: uv run --python 3.13 python -c "import matplotlib; print(matplotlib.__file__, matplotlib.__version__)"
110+
- name: Summary
111+
if: always()
112+
run: |
113+
echo "venv + pip : ${{ steps.venv_pip.outcome }}"
114+
echo "conda : ${{ steps.conda.outcome }}"
115+
echo "uv pip : ${{ steps.uv_pip.outcome }}"
116+
echo "uv sync : ${{ steps.uv_sync.outcome }}"
117+
test "${{ steps.venv_pip.outcome }}" = success \
118+
&& test "${{ steps.conda.outcome }}" = success \
119+
&& test "${{ steps.uv_pip.outcome }}" = success \
120+
&& test "${{ steps.uv_sync.outcome }}" = success

doc/devel/development_setup.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,16 @@ setup.
222222

223223
uv pip install --verbose --no-build-isolation --group dev --editable .
224224

225-
Alternatively, ``uv sync`` installs the dependencies and performs the
226-
editable build in a single step, managing the environment for you. You
227-
can then run a single script in that environment without activating it
228-
using ``uv run path/to/script.py``.
225+
You can also manage the environment from a lockfile with ``uv sync``.
226+
Because Matplotlib has a compiled (meson-python) build, install the
227+
dependencies and the editable build in separate steps ::
228+
229+
uv sync --group dev --no-install-project
230+
uv pip install --no-build-isolation --no-deps --editable .
231+
232+
then activate the environment as above. Avoid ``uv run`` for this build,
233+
as it re-syncs the project and rebuilds the editable install with build
234+
isolation, which is incompatible with the meson-python editable rebuild.
229235

230236
Remember to activate the environment whenever you start working on Matplotlib!
231237

0 commit comments

Comments
 (0)