diff --git a/.circleci/config.yml b/.circleci/config.yml index 40ba933cf0d9..94090783b764 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,10 +103,10 @@ commands: - run: name: Install Python dependencies command: | - python -m pip install --user -r requirements/dev/build-requirements.txt + python -m pip install --user --group build python -m pip install --user \ numpy<< parameters.numpy_version >> \ - -r requirements/doc/doc-requirements.txt + --group doc python -m pip install --no-deps --user \ git+https://github.com/matplotlib/mpl-sphinx-theme.git diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index 8a01d76c00f5..9feed954a1f3 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -144,7 +144,7 @@ jobs: uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 with: path: C:\cygwin\home\runneradmin\.cache\pip - key: Cygwin-py3.${{ matrix.python-minor-version }}-pip-${{ hashFiles('requirements/*/*.txt') }} + key: Cygwin-py3.${{ matrix.python-minor-version }}-pip-${{ hashFiles('pyproject.toml') }} restore-keys: ${{ matrix.os }}-py3.${{ matrix.python-minor-version }}-pip- - name: Cache ccache @@ -175,15 +175,9 @@ jobs: - name: Install Python dependencies shell: bash.exe -eo pipefail -o igncr "{0}" run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install kiwisolver 'numpy>=1.22,<1.26' pillow importlib_resources - grep -v -F -e psutil requirements/testing/all.txt >requirements_test.txt - python -m pip install meson-python pybind11 + python -m pip install --group build 'numpy>=1.25,<1.26' export PATH="/usr/local/bin:$PATH" - python -m pip install --no-build-isolation 'contourpy>=1.0.1' - python -m pip install --upgrade cycler fonttools \ - packaging pyparsing python-dateutil setuptools-scm \ - -r requirements_test.txt sphinx ipython + python -m pip install --upgrade --group test sphinx ipython python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject && python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' && echo 'PyGObject is available' || diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 048b78f24761..bab3967df34f 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -69,7 +69,7 @@ jobs: python-version: '3.11' - name: Install mypy - run: pip3 install -r requirements/testing/mypy.txt -r requirements/testing/all.txt + run: pip3 install --group build --group typing - name: Set up reviewdog uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e79166758d1..46aa9bf13909 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,14 +52,14 @@ jobs: - name-suffix: "(Minimum Versions)" os: ubuntu-22.04 python-version: '3.11' - extra-requirements: '-c requirements/testing/minver.txt' + extra-requirements: '-c ci/minver-requirements.txt' delete-font-cache: true # https://github.com/matplotlib/matplotlib/issues/29844 pygobject-ver: '<3.52.0' - os: ubuntu-22.04 python-version: '3.11' CFLAGS: "-fno-lto" # Ensure that disabling LTO works. - extra-requirements: '-r requirements/testing/extra.txt' + extra-requirements: '--group test-extra' # https://github.com/matplotlib/matplotlib/issues/29844 pygobject-ver: '<3.52.0' - name-suffix: "(Extra TeX packages)" @@ -190,7 +190,9 @@ jobs: if: startsWith(runner.os, 'Linux') with: path: ~/.cache/pip - key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('requirements/*/*.txt') }} + key: | + ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ + hashFiles('pyproject.toml', 'ci/minver-requirements.txt') }} restore-keys: | ${{ matrix.os }}-py${{ matrix.python-version }}-pip- - name: Cache pip @@ -198,7 +200,7 @@ jobs: if: startsWith(runner.os, 'macOS') with: path: ~/Library/Caches/pip - key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('requirements/*/*.txt') }} + key: ${{ matrix.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }} restore-keys: | ${{ matrix.os }}-py${{ matrix.python-version }}-pip- - name: Cache ccache @@ -235,12 +237,8 @@ jobs: # Install dependencies from PyPI. # Preinstall build requirements to enable no-build-isolation builds. - python -m pip install --upgrade $PRE \ - 'contourpy>=1.0.1' cycler fonttools kiwisolver importlib_resources \ - packaging pillow 'pyparsing!=3.1.0' python-dateutil setuptools-scm \ - 'meson-python>=0.13.1' 'pybind11>=2.13.2' \ - -r requirements/testing/all.txt \ - ${{ matrix.extra-requirements }} + python -m pip install --upgrade $PRE --prefer-binary \ + --group build --group test ${{ matrix.extra-requirements }} # Install optional dependencies from PyPI. # Sphinx is needed to run sphinxext tests diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d68a9d36f0d3..829a1c7b9005 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -74,8 +74,8 @@ stages: - bash: | python -m pip install --upgrade pip - python -m pip install --upgrade -r requirements/dev/build-requirements.txt - python -m pip install -r requirements/testing/all.txt -r requirements/testing/extra.txt + python -m pip install --upgrade --group build + python -m pip install --prefer-binary --group test --group test-extra displayName: 'Install dependencies with pip' - bash: | diff --git a/requirements/testing/minver.txt b/ci/minver-requirements.txt similarity index 100% rename from requirements/testing/minver.txt rename to ci/minver-requirements.txt diff --git a/doc/api/next_api_changes/development/29181-ES.rst b/doc/api/next_api_changes/development/29181-ES.rst new file mode 100644 index 000000000000..a3c7e5eed448 --- /dev/null +++ b/doc/api/next_api_changes/development/29181-ES.rst @@ -0,0 +1,11 @@ +pip 25.1 suggested for development +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Dependencies for development (build and testing) are now specified as `Dependency Groups +`_ +instead of `individual requirements files +`_. + +Consequently, a version of pip that supports Dependency Groups is suggested, namely +version 25.1 or higher. Note that if you install build/testing dependencies manually (by +copying the list from ``pyproject.toml``), then an older version of pip is sufficient. diff --git a/doc/devel/development_setup.rst b/doc/devel/development_setup.rst index 55bf98b4d380..eade1822f6ff 100644 --- a/doc/devel/development_setup.rst +++ b/doc/devel/development_setup.rst @@ -177,7 +177,8 @@ setup. Install the Python dependencies with :: - pip install -r requirements/dev/dev-requirements.txt + pip install -U pip # You may skip this step if pip 25.1 is already available. + pip install --group dev Remember to activate the environment whenever you start working on Matplotlib! @@ -270,7 +271,7 @@ Install Matplotlib in editable mode Install Matplotlib in editable mode from the :file:`matplotlib` directory using the command :: - python -m pip install --verbose --no-build-isolation --editable ".[dev]" + python -m pip install --verbose --no-build-isolation --group dev --editable . The 'editable/develop mode' builds everything and places links in your Python environment so that Python will be able to import Matplotlib from your development source directory. diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst index 886b60240415..ccac5b4f8872 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -450,7 +450,7 @@ To build the documentation you must have the tagged version installed, but build the docs from the ``ver-doc`` branch. An easy way to arrange this is:: pip install matplotlib - pip install -r requirements/doc/doc-requirements.txt + pip install --group doc git checkout v3.7.0-doc git clean -xfd make -Cdoc O="-t release -j$(nproc)" html latexpdf LATEXMKOPTS="-silent -f" diff --git a/doc/install/dependencies.rst b/doc/install/dependencies.rst index d0567900ea4c..8f638ea5ed1d 100644 --- a/doc/install/dependencies.rst +++ b/doc/install/dependencies.rst @@ -406,17 +406,11 @@ Documentation dependencies Python ------ -The additional Python packages required to build the -:ref:`documentation ` are listed in -:file:`doc-requirements.txt` and can be installed using :: - - pip install -r requirements/doc/doc-requirements.txt - -The content of :file:`doc-requirements.txt` is also shown below: - -.. include:: ../../requirements/doc/doc-requirements.txt - :literal: +The additional Python packages required to build the :ref:`documentation +` are listed in :file:`pyproject.toml` and can be +installed using :: + pip install --group doc .. _doc-dependencies-external: diff --git a/environment.yml b/environment.yml index a629c782ac77..21f5c9052749 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ # # conda env create -f environment.yml # conda activate mpl-dev -# pip install --verbose --no-build-isolation --editable ".[dev]" +# pip install --verbose --no-build-isolation --group dev --editable . # --- name: mpl-dev diff --git a/pyproject.toml b/pyproject.toml index b2e5451818f4..d393ac4cab0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,10 @@ classifiers=[ # When updating the list of dependencies, add an api_changes/development # entry and also update the following places: +# - the `build` dependency group below # - lib/matplotlib/__init__.py (matplotlib._check_versions()) -# - requirements/testing/minver.txt +# - ci/minver-requirements.txt # - doc/devel/dependencies.rst -# - .github/workflows/tests.yml # - environment.yml dependencies = [ "contourpy >= 1.0.1", @@ -44,20 +44,6 @@ dependencies = [ # Also keep in sync with find_program of meson.build. requires-python = ">=3.11" -[project.optional-dependencies] -# Should be a copy of the build dependencies below. -dev = [ - "meson-python>=0.13.1,!=0.17.*", - "pybind11>=2.13.2,!=2.13.3", - "setuptools_scm>=7", - # Not required by us but setuptools_scm without a version, cso _if_ - # installed, then setuptools_scm 8 requires at least this version. - # Unfortunately, we can't do a sort of minimum-if-installed dependency, so - # we need to keep this for now until setuptools_scm _fully_ drops - # setuptools. - "setuptools>=64", -] - [project.urls] "Homepage" = "https://matplotlib.org" "Download" = "https://matplotlib.org/stable/install/index.html" @@ -69,7 +55,7 @@ dev = [ [build-system] build-backend = "mesonpy" -# Also keep in sync with optional dependencies above. +# Also keep in sync with dependency groups below. requires = [ # meson-python 0.17.x breaks symlinks in sdists. You can remove this pin if # you really need it and aren't using an sdist. @@ -78,6 +64,104 @@ requires = [ "setuptools_scm>=7", ] +[dependency-groups] +build = [ + # Should be the same as `[project] dependencies` above. + "contourpy >= 1.0.1", + "cycler >= 0.10", + "fonttools >= 4.22.0", + "kiwisolver >= 1.3.1", + "numpy >= 1.25", + "packaging >= 20.0", + "pillow >= 9", + "pyparsing >= 3", + "python-dateutil >= 2.7", + + # Should be the same as `[build-system] requires` above. + "meson-python>=0.13.1,!=0.17.*", + "pybind11>=2.13.2,!=2.13.3", + "setuptools_scm>=7", + # Not required by us but setuptools_scm without a version, so _if_ + # installed, then setuptools_scm 8 requires at least this version. + # Unfortunately, we can't do a sort of minimum-if-installed dependency, so + # we need to keep this for now until setuptools_scm _fully_ drops + # setuptools. + "setuptools>=64", +] +dev = [ + {include-group = "build"}, + {include-group = "doc"}, + {include-group = "test"}, + {include-group = "test-extra"}, + "pre-commit", +] +# Requirements for building docs +# +# You will first need a matching Matplotlib installation +# e.g (from the Matplotlib root directory) +# pip install --group build --no-build-isolation --editable . +# +# Install the documentation requirements with: +# pip install --group doc +# +doc = [ + "sphinx>=5.1.0,!=6.1.2", + "colorspacious", + "ipython", + "ipywidgets", + "ipykernel", + "numpydoc>=1.0", + "mpl-sphinx-theme~=3.10.0", + "pyyaml", + "PyStemmer", + "sphinxcontrib-svg2pdfconverter>=1.1.0", + "sphinxcontrib-video>=0.2.1", + "sphinx-copybutton", + "sphinx-design", + "sphinx-gallery[parallel]>=0.12.0", + "sphinx-tags>=0.4.0", +] + +# pip requirements for all the CI builds +test = [ + "black<26", + "certifi", + "coverage!=6.3", + "psutil; sys_platform != 'cygwin'", + "pytest!=4.6.0,!=5.4.0,!=8.1.0", + "pytest-cov", + "pytest-rerunfailures!=16.0", + "pytest-timeout", + "pytest-xdist", + "pytest-xvfb", + "tornado", +] + +# Extra pip requirements +test-extra = [ + "ipykernel", + # jupyter/nbconvert#1970 for the 7.3 series exclusions + "nbconvert[execute]!=6.0.0,!=6.0.1,!=7.3.0,!=7.3.1", + "nbformat!=5.0.0,!=5.0.1", + "pandas!=0.25.0", + "pikepdf", + "pytz", + "pywin32; sys_platform == 'win32'", + "xarray", +] + +# Extra pip requirements for the GitHub Actions mypy build +typing = [ + "mypy>=1.9", + "typing-extensions>=4.6", + # Extra stubs distributed separately from the main pypi package + "pandas-stubs", + "types-pillow", + "types-python-dateutil", + "types-psutil", + "sphinx", +] + [tool.meson-python.args] install = ['--tags=data,python-runtime,runtime'] diff --git a/requirements/dev/build-requirements.txt b/requirements/dev/build-requirements.txt deleted file mode 100644 index 4d2a098c3c4f..000000000000 --- a/requirements/dev/build-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pybind11>=2.13.2,!=2.13.3 -meson-python -setuptools-scm diff --git a/requirements/dev/dev-requirements.txt b/requirements/dev/dev-requirements.txt deleted file mode 100644 index 3208949ba0e8..000000000000 --- a/requirements/dev/dev-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ --r build-requirements.txt --r ../doc/doc-requirements.txt --r ../testing/all.txt --r ../testing/extra.txt -ruff diff --git a/requirements/doc/doc-requirements.txt b/requirements/doc/doc-requirements.txt deleted file mode 100644 index 1a352eaae975..000000000000 --- a/requirements/doc/doc-requirements.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Requirements for building docs -# -# You will first need a matching Matplotlib installation -# e.g (from the Matplotlib root directory) -# pip install --no-build-isolation --editable .[dev] -# -# Install the documentation requirements with: -# pip install -r requirements/doc/doc-requirements.txt -# -sphinx>=5.1.0,!=6.1.2 -colorspacious -ipython -ipywidgets -ipykernel -numpydoc>=1.0 -packaging>=20 -mpl-sphinx-theme~=3.10.0 -pyyaml -PyStemmer -sphinxcontrib-svg2pdfconverter>=1.1.0 -sphinxcontrib-video>=0.2.1 -sphinx-copybutton -sphinx-design -sphinx-gallery[parallel]>=0.12.0 -sphinx-tags>=0.4.0 diff --git a/requirements/testing/all.txt b/requirements/testing/all.txt deleted file mode 100644 index dd1dbf3f29fd..000000000000 --- a/requirements/testing/all.txt +++ /dev/null @@ -1,13 +0,0 @@ -# pip requirements for all the CI builds - -black<26 -certifi -coverage!=6.3 -psutil -pytest!=4.6.0,!=5.4.0,!=8.1.0 -pytest-cov -pytest-rerunfailures!=16.0 -pytest-timeout -pytest-xdist -pytest-xvfb -tornado diff --git a/requirements/testing/extra.txt b/requirements/testing/extra.txt deleted file mode 100644 index e0d84d71c781..000000000000 --- a/requirements/testing/extra.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Extra pip requirements - ---prefer-binary -ipykernel -# jupyter/nbconvert#1970 for the 7.3 series exclusions -nbconvert[execute]!=6.0.0,!=6.0.1,!=7.3.0,!=7.3.1 -nbformat!=5.0.0,!=5.0.1 -pandas!=0.25.0 -pikepdf -pytz -pywin32; sys.platform == 'win32' -xarray diff --git a/requirements/testing/mypy.txt b/requirements/testing/mypy.txt deleted file mode 100644 index 343517263f40..000000000000 --- a/requirements/testing/mypy.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Extra pip requirements for the GitHub Actions mypy build - -mypy>=1.9 -typing-extensions>=4.6 - -# Extra stubs distributed separately from the main pypi package -pandas-stubs -types-pillow -types-python-dateutil -types-psutil - -sphinx - -# Default requirements, included here because mpl itself does not -# need to be installed for mypy to run, but deps are needed -# and pip has no --deps-only install command -contourpy>=1.0.1 -cycler>=0.10 -fonttools>=4.22.0 -kiwisolver>=1.3.1 -packaging>=20.0 -pillow>=9 -pyparsing>=3 -python-dateutil>=2.7 -setuptools_scm>=7 -setuptools>=64 diff --git a/tox.ini b/tox.ini index 1d527a19ff52..956e4050cfa9 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,6 @@ changedir = {tox_root} commands = python tools/stubtest.py usedevelop = False -deps = - -r requirements/testing/mypy.txt - -r requirements/testing/all.txt +dependency_groups = + build + typing