Skip to content

Commit 45b5275

Browse files
committed
Port requirements to PEP735
1 parent 4f26d9a commit 45b5275

File tree

18 files changed

+160
-164
lines changed

18 files changed

+160
-164
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ commands:
103103
- run:
104104
name: Install Python dependencies
105105
command: |
106-
python -m pip install --user -r requirements/dev/build-requirements.txt
106+
python -m pip install --user --group build
107107
python -m pip install --user \
108108
numpy<< parameters.numpy_version >> \
109-
-r requirements/doc/doc-requirements.txt
109+
--group doc
110110
python -m pip install --no-deps --user \
111111
git+https://github.com/matplotlib/mpl-sphinx-theme.git
112112

.github/workflows/cygwin.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
144144
with:
145145
path: C:\cygwin\home\runneradmin\.cache\pip
146-
key: Cygwin-py3.${{ matrix.python-minor-version }}-pip-${{ hashFiles('requirements/*/*.txt') }}
146+
key: Cygwin-py3.${{ matrix.python-minor-version }}-pip-${{ hashFiles('pyproject.toml') }}
147147
restore-keys: ${{ matrix.os }}-py3.${{ matrix.python-minor-version }}-pip-
148148

149149
- name: Cache ccache
@@ -174,15 +174,9 @@ jobs:
174174
- name: Install Python dependencies
175175
shell: bash.exe -eo pipefail -o igncr "{0}"
176176
run: |
177-
python -m pip install --upgrade pip setuptools wheel
178-
python -m pip install kiwisolver 'numpy>=1.22,<1.26' pillow importlib_resources
179-
grep -v -F -e psutil requirements/testing/all.txt >requirements_test.txt
180-
python -m pip install meson-python pybind11
177+
python -m pip install --group build 'numpy>=1.25,<1.26'
181178
export PATH="/usr/local/bin:$PATH"
182-
python -m pip install --no-build-isolation 'contourpy>=1.0.1'
183-
python -m pip install --upgrade cycler fonttools \
184-
packaging pyparsing python-dateutil setuptools-scm \
185-
-r requirements_test.txt sphinx ipython
179+
python -m pip install --upgrade --group test sphinx ipython
186180
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
187181
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
188182
echo 'PyGObject is available' ||

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
python-version: '3.11'
6666

6767
- name: Install mypy
68-
run: pip3 install -r requirements/testing/mypy.txt -r requirements/testing/all.txt
68+
run: pip3 install --group build --group typing
6969

7070
- name: Set up reviewdog
7171
uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v1.3.9

.github/workflows/tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ jobs:
5050
- name-suffix: "(Minimum Versions)"
5151
os: ubuntu-22.04
5252
python-version: '3.11'
53-
extra-requirements: '-c requirements/testing/minver.txt'
53+
extra-requirements: '--group test-minver'
5454
delete-font-cache: true
5555
# https://github.com/matplotlib/matplotlib/issues/29844
5656
pygobject-ver: '<3.52.0'
5757
- os: ubuntu-22.04
5858
python-version: '3.11'
5959
CFLAGS: "-fno-lto" # Ensure that disabling LTO works.
60-
extra-requirements: '-r requirements/testing/extra.txt'
60+
extra-requirements: '--group test-extra'
6161
# https://github.com/matplotlib/matplotlib/issues/29844
6262
pygobject-ver: '<3.52.0'
6363
- os: ubuntu-22.04-arm
@@ -180,15 +180,15 @@ jobs:
180180
if: startsWith(runner.os, 'Linux')
181181
with:
182182
path: ~/.cache/pip
183-
key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('requirements/*/*.txt') }}
183+
key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
184184
restore-keys: |
185185
${{ matrix.os }}-py${{ matrix.python-version }}-pip-
186186
- name: Cache pip
187187
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
188188
if: startsWith(runner.os, 'macOS')
189189
with:
190190
path: ~/Library/Caches/pip
191-
key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('requirements/*/*.txt') }}
191+
key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
192192
restore-keys: |
193193
${{ matrix.os }}-py${{ matrix.python-version }}-pip-
194194
- name: Cache ccache
@@ -225,12 +225,8 @@ jobs:
225225
226226
# Install dependencies from PyPI.
227227
# Preinstall build requirements to enable no-build-isolation builds.
228-
python -m pip install --upgrade $PRE \
229-
'contourpy>=1.0.1' cycler fonttools kiwisolver importlib_resources \
230-
packaging pillow 'pyparsing!=3.1.0' python-dateutil setuptools-scm \
231-
'meson-python>=0.13.1' 'pybind11>=2.13.2' \
232-
-r requirements/testing/all.txt \
233-
${{ matrix.extra-requirements }}
228+
python -m pip install --upgrade $PRE --prefer-binary \
229+
--group build --group test ${{ matrix.extra-requirements }}
234230
235231
# Install optional dependencies from PyPI.
236232
# Sphinx is needed to run sphinxext tests

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ stages:
7474
7575
- bash: |
7676
python -m pip install --upgrade pip
77-
python -m pip install --upgrade -r requirements/dev/build-requirements.txt
78-
python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt
77+
python -m pip install --upgrade --group build
78+
python -m pip install --prefer-binary --group test --group test-extra
7979
displayName: 'Install dependencies with pip'
8080
8181
- bash: |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pip 25.1 suggested for development
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Dependencies for development (build and testing) are now specified as `Dependency Groups
5+
<https://packaging.python.org/en/latest/specifications/dependency-groups/#dependency-groups>`_
6+
instead of `individual requirements files
7+
<https://pip.pypa.io/en/stable/reference/requirements-file-format/>`_.
8+
9+
Consequently, a version of pip that supports Dependency Groups is suggested, namely
10+
version 25.1 or higher. Note that if you install build/testing dependencies manually (by
11+
copying the list from ``pyproject.toml``), then an older version of pip is sufficient.

doc/devel/development_setup.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ setup.
177177

178178
Install the Python dependencies with ::
179179

180-
pip install -r requirements/dev/dev-requirements.txt
180+
pip install -U pip # You may skip this step if pip 25.1 is already available.
181+
pip install --group dev
181182

182183
Remember to activate the environment whenever you start working on Matplotlib!
183184

doc/devel/release_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ To build the documentation you must have the tagged version installed, but
429429
build the docs from the ``ver-doc`` branch. An easy way to arrange this is::
430430

431431
pip install matplotlib
432-
pip install -r requirements/doc/doc-requirements.txt
432+
pip install --group doc
433433
git checkout v3.7.0-doc
434434
git clean -xfd
435435
make -Cdoc O="-t release -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f"

doc/install/dependencies.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,11 @@ Documentation dependencies
396396
Python
397397
------
398398

399-
The additional Python packages required to build the
400-
:ref:`documentation <documenting-matplotlib>` are listed in
401-
:file:`doc-requirements.txt` and can be installed using ::
402-
403-
pip install -r requirements/doc/doc-requirements.txt
404-
405-
The content of :file:`doc-requirements.txt` is also shown below:
406-
407-
.. include:: ../../requirements/doc/doc-requirements.txt
408-
:literal:
399+
The additional Python packages required to build the :ref:`documentation
400+
<documenting-matplotlib>` are listed in :file:`pyproject.toml` and can be
401+
installed using ::
409402

403+
pip install --group doc
410404

411405
.. _doc-dependencies-external:
412406

pyproject.toml

Lines changed: 125 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ classifiers=[
2424

2525
# When updating the list of dependencies, add an api_changes/development
2626
# entry and also update the following places:
27+
# - the `build` and `test-minver` dependency groups below
2728
# - lib/matplotlib/__init__.py (matplotlib._check_versions())
28-
# - requirements/testing/minver.txt
2929
# - doc/devel/dependencies.rst
30-
# - .github/workflows/tests.yml
3130
# - environment.yml
3231
dependencies = [
3332
"contourpy >= 1.0.1",
@@ -43,20 +42,6 @@ dependencies = [
4342
# Also keep in sync with find_program of meson.build.
4443
requires-python = ">=3.11"
4544

46-
[project.optional-dependencies]
47-
# Should be a copy of the build dependencies below.
48-
dev = [
49-
"meson-python>=0.13.1,!=0.17.*",
50-
"pybind11>=2.13.2,!=2.13.3",
51-
"setuptools_scm>=7",
52-
# Not required by us but setuptools_scm without a version, cso _if_
53-
# installed, then setuptools_scm 8 requires at least this version.
54-
# Unfortunately, we can't do a sort of minimum-if-installed dependency, so
55-
# we need to keep this for now until setuptools_scm _fully_ drops
56-
# setuptools.
57-
"setuptools>=64",
58-
]
59-
6045
[project.urls]
6146
"Homepage" = "https://matplotlib.org"
6247
"Download" = "https://matplotlib.org/stable/install/index.html"
@@ -68,7 +53,7 @@ dev = [
6853

6954
[build-system]
7055
build-backend = "mesonpy"
71-
# Also keep in sync with optional dependencies above.
56+
# Also keep in sync with dependency groups below.
7257
requires = [
7358
# meson-python 0.17.x breaks symlinks in sdists. You can remove this pin if
7459
# you really need it and aren't using an sdist.
@@ -77,6 +62,129 @@ requires = [
7762
"setuptools_scm>=7",
7863
]
7964

65+
[dependency-groups]
66+
build = [
67+
# Should be the same as `[project] dependencies` above.
68+
"contourpy >= 1.0.1",
69+
"cycler >= 0.10",
70+
"fonttools >= 4.22.0",
71+
"kiwisolver >= 1.3.1",
72+
"numpy >= 1.25",
73+
"packaging >= 20.0",
74+
"pillow >= 9",
75+
"pyparsing >= 3",
76+
"python-dateutil >= 2.7",
77+
78+
# Should be the same as `[build-system] requires` above.
79+
"meson-python>=0.13.1,!=0.17.*",
80+
"pybind11>=2.13.2,!=2.13.3",
81+
"setuptools_scm>=7",
82+
# Not required by us but setuptools_scm without a version, so _if_
83+
# installed, then setuptools_scm 8 requires at least this version.
84+
# Unfortunately, we can't do a sort of minimum-if-installed dependency, so
85+
# we need to keep this for now until setuptools_scm _fully_ drops
86+
# setuptools.
87+
"setuptools>=64",
88+
]
89+
dev = [
90+
{include-group = "build"},
91+
{include-group = "doc"},
92+
{include-group = "test"},
93+
{include-group = "test-extra"},
94+
"pre-commit",
95+
]
96+
# Requirements for building docs
97+
#
98+
# You will first need a matching Matplotlib installation
99+
# e.g (from the Matplotlib root directory)
100+
# pip install --group build --no-build-isolation --editable .
101+
#
102+
# Install the documentation requirements with:
103+
# pip install --group doc
104+
#
105+
doc = [
106+
"sphinx>=5.1.0,!=6.1.2",
107+
"colorspacious",
108+
"ipython",
109+
"ipywidgets",
110+
"ipykernel",
111+
"numpydoc>=1.0",
112+
"pydata-sphinx-theme~=0.15.0",
113+
"mpl-sphinx-theme~=3.9.0",
114+
"pyyaml",
115+
"PyStemmer",
116+
"sphinxcontrib-svg2pdfconverter>=1.1.0",
117+
"sphinxcontrib-video>=0.2.1",
118+
"sphinx-copybutton",
119+
"sphinx-design",
120+
"sphinx-gallery[parallel]>=0.12.0",
121+
"sphinx-tags>=0.4.0",
122+
]
123+
124+
# pip requirements for all the CI builds
125+
test = [
126+
"black<24",
127+
"certifi",
128+
"coverage!=6.3",
129+
"psutil; sys_platform != 'cygwin'",
130+
"pytest!=4.6.0,!=5.4.0,!=8.1.0",
131+
"pytest-cov",
132+
"pytest-rerunfailures",
133+
"pytest-timeout",
134+
"pytest-xdist",
135+
"pytest-xvfb",
136+
"tornado",
137+
]
138+
139+
# Extra pip requirements
140+
test-extra = [
141+
"ipykernel",
142+
# jupyter/nbconvert#1970 for the 7.3 series exclusions
143+
"nbconvert[execute]!=6.0.0,!=6.0.1,!=7.3.0,!=7.3.1",
144+
"nbformat!=5.0.0,!=5.0.1",
145+
"pandas!=0.25.0",
146+
"pikepdf",
147+
"pytz",
148+
"pywin32; sys_platform == 'win32'",
149+
"xarray",
150+
]
151+
152+
# Extra pip requirements for the minimum-version CI run
153+
test-minver = [
154+
"contourpy==1.0.1",
155+
"cycler==0.10",
156+
"fonttools==4.22.0",
157+
"importlib-resources==3.2.0",
158+
"kiwisolver==1.3.2",
159+
"meson-python==0.13.1",
160+
"meson==1.1.0",
161+
"numpy==1.25.0",
162+
"packaging==20.0",
163+
"pillow==9.0.1",
164+
"pyparsing==3.0.0",
165+
"pytest==7.0.0",
166+
"python-dateutil==2.7",
167+
# Test ipython/matplotlib-inline before backend mapping moved to mpl.
168+
# This should be tested for a reasonably long transition period,
169+
# but we will eventually remove the test when we no longer support
170+
# ipython/matplotlib-inline versions from before the transition.
171+
"ipython==7.29.0",
172+
"ipykernel==5.5.6",
173+
"matplotlib-inline<0.1.7",
174+
]
175+
176+
# Extra pip requirements for the GitHub Actions mypy build
177+
typing = [
178+
"mypy>=1.9",
179+
"typing-extensions>=4.6",
180+
# Extra stubs distributed separately from the main pypi package
181+
"pandas-stubs",
182+
"types-pillow",
183+
"types-python-dateutil",
184+
"types-psutil",
185+
"sphinx",
186+
]
187+
80188
[tool.meson-python.args]
81189
install = ['--tags=data,python-runtime,runtime']
82190

requirements/dev/build-requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

requirements/dev/dev-requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

requirements/doc/doc-requirements.txt

Lines changed: 0 additions & 26 deletions
This file was deleted.

requirements/testing/all.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

requirements/testing/extra.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)