From 559f8253a5d7644990ad76c17c090d5ccef182aa Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 10 Dec 2024 23:33:01 -0500 Subject: [PATCH] Port requirements to PEP735 --- .github/workflows/cygwin.yml | 5 +- .github/workflows/reviewdog.yml | 4 +- .github/workflows/tests.yml | 16 ++-- azure-pipelines.yml | 3 +- doc/devel/development_setup.rst | 2 +- doc/devel/release_guide.rst | 2 +- doc/install/dependencies.rst | 14 +-- pyproject.toml | 112 ++++++++++++++++++++++++ requirements/dev/build-requirements.txt | 3 - requirements/dev/dev-requirements.txt | 5 -- requirements/doc/doc-requirements.txt | 26 ------ requirements/testing/all.txt | 13 --- requirements/testing/extra.txt | 12 --- requirements/testing/flake8.txt | 9 -- requirements/testing/minver.txt | 15 ---- requirements/testing/mypy.txt | 26 ------ tox.ini | 6 +- 17 files changed, 132 insertions(+), 141 deletions(-) delete mode 100644 requirements/dev/build-requirements.txt delete mode 100644 requirements/dev/dev-requirements.txt delete mode 100644 requirements/doc/doc-requirements.txt delete mode 100644 requirements/testing/all.txt delete mode 100644 requirements/testing/extra.txt delete mode 100644 requirements/testing/flake8.txt delete mode 100644 requirements/testing/minver.txt delete mode 100644 requirements/testing/mypy.txt diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index bde902013412..c55b99ff3a85 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -143,7 +143,7 @@ jobs: uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 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 @@ -174,10 +174,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 --group build 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 export PATH="/usr/local/bin:$PATH" python -m pip install --no-build-isolation 'contourpy>=1.0.1' python -m pip install --upgrade cycler fonttools \ diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 24980f7a075b..36cb6051a17c 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -22,7 +22,7 @@ jobs: python-version: '3.10' - name: Install flake8 - run: pip3 install -r requirements/testing/flake8.txt + run: pip3 install --group lint - name: Set up reviewdog uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v1.3.9 @@ -51,7 +51,7 @@ jobs: python-version: '3.10' - name: Install mypy - run: pip3 install -r requirements/testing/mypy.txt -r requirements/testing/all.txt + run: pip3 install --group typing - name: Set up reviewdog uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v1.3.9 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 47f6a09eb72d..237fe09b7e8c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,7 +50,7 @@ jobs: - name-suffix: "(Minimum Versions)" os: ubuntu-20.04 python-version: '3.10' - extra-requirements: '-c requirements/testing/minver.txt' + extra-requirements: '--group test-minver' delete-font-cache: true # Oldest versions with Py3.10 wheels. pyqt5-ver: '==5.15.5 sip==6.3.0' @@ -61,7 +61,7 @@ jobs: python-version: '3.10' # One CI run tests ipython/matplotlib-inline before backend mapping moved to mpl extra-requirements: - -r requirements/testing/extra.txt + --group test-extra "ipython==7.29.0" "ipykernel==5.5.6" "matplotlib-inline<0.1.7" @@ -77,7 +77,7 @@ jobs: pyqt6-ver: '!=6.6.0' # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-2346 pyside6-ver: '!=6.5.1' - extra-requirements: '-r requirements/testing/extra.txt' + extra-requirements: '--group test-extra' - os: ubuntu-22.04 python-version: '3.12' # https://www.riverbankcomputing.com/pipermail/pyqt/2023-November/045606.html @@ -209,7 +209,7 @@ 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') }} restore-keys: | ${{ matrix.os }}-py${{ matrix.python-version }}-pip- - name: Cache pip @@ -217,7 +217,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 @@ -254,11 +254,7 @@ 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 \ + python -m pip install --upgrade $PRE --group build --group test \ ${{ matrix.extra-requirements }} # Install optional dependencies from PyPI. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index eed605cd32b6..d4c4072ac5ab 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -71,8 +71,7 @@ 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 --group build --group test --group test-extra displayName: 'Install dependencies with pip' - bash: | diff --git a/doc/devel/development_setup.rst b/doc/devel/development_setup.rst index cffda17939a7..70917c584c1d 100644 --- a/doc/devel/development_setup.rst +++ b/doc/devel/development_setup.rst @@ -137,7 +137,7 @@ setup. Install the Python dependencies with :: - pip install -r requirements/dev/dev-requirements.txt + pip install --group dev Remember to activate the environment whenever you start working on Matplotlib! diff --git a/doc/devel/release_guide.rst b/doc/devel/release_guide.rst index 0e0ebb98fd1d..460ac194bb4e 100644 --- a/doc/devel/release_guide.rst +++ b/doc/devel/release_guide.rst @@ -420,7 +420,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 ea1c6787b52b..fd2f86702629 100644 --- a/doc/install/dependencies.rst +++ b/doc/install/dependencies.rst @@ -390,17 +390,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/pyproject.toml b/pyproject.toml index 5451e972de8d..29382b56c403 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,118 @@ requires = [ "setuptools_scm>=7", ] +[dependency-groups] +build = [ + "pybind11>=2.13.2,!=2.13.3", + "meson-python", + "setuptools-scm", +] +dev = [ + {include-group= "build"}, + {include-group = "doc"}, + {include-group = "test"}, + {include-group = "test-extra"}, + {include-group = "lint"}, +] +# 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 +# +doc = [ + "sphinx>=5.1.0,!=6.1.2", + "colorspacious", + "ipython", + "ipywidgets", + "ipykernel", + "numpydoc>=1.0", + "packaging>=20", + "pydata-sphinx-theme~=0.15.0", + "mpl-sphinx-theme~=3.9.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<24", + "certifi", + "coverage!=6.3", + "psutil", + "pytest!=4.6.0,!=5.4.0,!=8.1.0", + "pytest-cov", + "pytest-rerunfailures", + "pytest-timeout", + "pytest-xdist", + "pytest-xvfb", + "tornado", +] + +# Extra pip requirements for the Python 3.10+ builds +test-extra = [ + "--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", +] + +# Extra pip requirements for the minimum-version CI run +test-minver = [ + "contourpy==1.0.1", + "cycler==0.10", + "fonttools==4.22.0", + "importlib-resources==3.2.0", + "kiwisolver==1.3.2", + "meson-python==0.13.1", + "meson==1.1.0", + "numpy==1.23.0", + "packaging==20.0", + "pillow==8.3.2", + "pyparsing==2.3.1", + "pytest==7.0.0", + "python-dateutil==2.7", +] + +# Extra pip requirements for the GitHub Actions flake8 build +lint = [ + "flake8>=3.8", + # versions less than 5.1.0 raise on some interp'd docstrings + "pydocstyle>=5.1.0", + # 1.4.0 adds docstring-convention=all + "flake8-docstrings>=1.4.0", + # fix bug where flake8 aborts checking on syntax error + "flake8-force", +] + +# 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", + {include-group = build}, +] + [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 e5cbc1091bb2..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 --r ../testing/flake8.txt diff --git a/requirements/doc/doc-requirements.txt b/requirements/doc/doc-requirements.txt deleted file mode 100644 index 77cb606130b0..000000000000 --- a/requirements/doc/doc-requirements.txt +++ /dev/null @@ -1,26 +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 -pydata-sphinx-theme~=0.15.0 -mpl-sphinx-theme~=3.9.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 e386924a9b67..000000000000 --- a/requirements/testing/all.txt +++ /dev/null @@ -1,13 +0,0 @@ -# pip requirements for all the CI builds - -black<24 -certifi -coverage!=6.3 -psutil -pytest!=4.6.0,!=5.4.0,!=8.1.0 -pytest-cov -pytest-rerunfailures -pytest-timeout -pytest-xdist -pytest-xvfb -tornado diff --git a/requirements/testing/extra.txt b/requirements/testing/extra.txt deleted file mode 100644 index a5c1bef5f03a..000000000000 --- a/requirements/testing/extra.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Extra pip requirements for the Python 3.10+ builds - ---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/flake8.txt b/requirements/testing/flake8.txt deleted file mode 100644 index a4d006b8551e..000000000000 --- a/requirements/testing/flake8.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Extra pip requirements for the GitHub Actions flake8 build - -flake8>=3.8 -# versions less than 5.1.0 raise on some interp'd docstrings -pydocstyle>=5.1.0 -# 1.4.0 adds docstring-convention=all -flake8-docstrings>=1.4.0 -# fix bug where flake8 aborts checking on syntax error -flake8-force diff --git a/requirements/testing/minver.txt b/requirements/testing/minver.txt deleted file mode 100644 index 3932e68eb015..000000000000 --- a/requirements/testing/minver.txt +++ /dev/null @@ -1,15 +0,0 @@ -# Extra pip requirements for the minimum-version CI run - -contourpy==1.0.1 -cycler==0.10 -fonttools==4.22.0 -importlib-resources==3.2.0 -kiwisolver==1.3.2 -meson-python==0.13.1 -meson==1.1.0 -numpy==1.23.0 -packaging==20.0 -pillow==8.3.2 -pyparsing==2.3.1 -pytest==7.0.0 -python-dateutil==2.7 diff --git a/requirements/testing/mypy.txt b/requirements/testing/mypy.txt deleted file mode 100644 index aa20581ee69b..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>=8 -pyparsing>=2.3.1 -python-dateutil>=2.7 -setuptools_scm>=7 -setuptools>=64 diff --git a/tox.ini b/tox.ini index 3e19b48b6ba7..afff154dcdcf 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 = + test + typing