From bc03322c6ea92c0be3aaf486a75b102941f1729f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= Date: Sat, 26 Oct 2024 17:28:09 +0200 Subject: [PATCH] MNT: migrate requirement files to PEP 735 dependency groups --- .github/dependabot.yml | 10 ---- .github/workflows/test.yml | 59 +++++++++++-------- .readthedocs.yaml | 2 +- MANIFEST.in | 1 - docs/requirements.in | 6 ++ docs/requirements.txt | 112 +++++++++++++++++++++++++++++++++++++ docs/source/conf.py | 1 - pyproject.toml | 21 ++++++- requirements/dev.txt | 4 -- requirements/docs.txt | 6 -- requirements/typecheck.txt | 2 - src/cmasher/utils.py | 2 +- 12 files changed, 175 insertions(+), 51 deletions(-) create mode 100644 docs/requirements.in create mode 100644 docs/requirements.txt delete mode 100644 requirements/dev.txt delete mode 100644 requirements/docs.txt delete mode 100644 requirements/typecheck.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bace19ff..a045d192 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,16 +4,6 @@ version: 2 updates: -- package-ecosystem: pip - directory: /requirements - target-branch: develop - schedule: - interval: monthly - groups: - actions: - patterns: - - '*' - - package-ecosystem: github-actions directory: /.github/workflows target-branch: develop diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc06e9de..f4cef435 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ on: jobs: build: - name: ${{ matrix.os }}, Python ${{ matrix.python-version }} + name: ${{ matrix.os }}, Python ${{ matrix.python-version }} ${{ matrix.install-args }} ${{ matrix.viscm-flavor }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -29,29 +29,39 @@ jobs: - '3.11' - '3.12' - '3.13' - test-args: [viscm>=0.10] - venv-loc: [bin] + install-args: [''] + viscm-flavor: [''] include: - os: ubuntu-20.04 python-version: '3.10' - venv-loc: bin install-args: --resolution=lowest-direct - os: windows-latest python-version: '3.10' - venv-loc: Scripts - os: windows-latest python-version: '3.11' - venv-loc: Scripts - os: windows-latest python-version: '3.12' - venv-loc: Scripts + + # check with viscm + Python 3.12 + # note that 3.13 is not usable at the time of writing because + # viscm 0.10.0 pin numpy<2, and numpy 1.x doesn't support Python 3.13 + # see https://github.com/matplotlib/viscm/pull/82 + - os: ubuntu-latest + python-version: '3.12' + viscm-flavor: PyQt + - os: ubuntu-latest + python-version: '3.12' + viscm-flavor: Pyside + - os: macos-latest + python-version: '3.12' + viscm-flavor: PyQt - os: windows-latest - python-version: '3.13' - venv-loc: Scripts + python-version: '3.12' + viscm-flavor: PyQt concurrency: - group: ${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}-build + group: ${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.install-args }}-${{ matrix.viscm-flavor }}-build cancel-in-progress: true steps: @@ -62,10 +72,13 @@ jobs: cache-dependency-glob: pyproject.toml - name: Build + shell: bash # for windows-compat run: | - uv venv --python ${{ matrix.python-version }} - uv pip install -e . ${{ matrix.install-args }} - uv pip install -r requirements/dev.txt ${{ matrix.test-args }} + uv venv -p ${{ matrix.python-version }} + uv pip install ${{ matrix.install-args }} . + - name: Inject viscm + if: matrix.viscm-flavor != '' + run: uv pip install "viscm[ ${{ matrix.viscm-flavor }} ]" - run: uv pip list @@ -73,14 +86,14 @@ jobs: if: ${{ !startsWith( matrix.os , 'ubuntu' ) }} shell: bash # for windows-compat run: | - source .venv/${{matrix.venv-loc}}/activate - pytest --color=yes --mpl + uv run --verbose --group dev \ + pytest --color=yes --mpl - name: Test package (with coverage) if: startsWith( matrix.os , 'ubuntu' ) run: | - source .venv/${{matrix.venv-loc}}/activate - coverage run --parallel-mode -m pytest --color=yes --mpl + uv run --verbose --group dev \ + coverage run -m pytest --color=yes --mpl - name: Upload coverage data # only using reports from ubuntu because @@ -88,7 +101,7 @@ jobs: if: startsWith( matrix.os , 'ubuntu' ) uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: - name: cmasher_coverage_data-${{ matrix.os }}-${{ matrix.python-version }} + name: cmasher_coverage_data-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.install-args }}-${{ matrix.viscm-flavor }} path: .coverage.* if-no-files-found: ignore include-hidden-files: true @@ -128,6 +141,7 @@ jobs: name: type check w/ Python ${{ matrix.python-version }} strategy: + fail-fast: false matrix: python-version: - '3.10' @@ -147,10 +161,7 @@ jobs: cache-dependency-glob: pyproject.toml - name: Run mypy - run: | - uvx --python ${{ matrix.python-version }} \ - --with-requirements=requirements/typecheck.txt --with . \ - mypy src/cmasher + run: uv run -p ${{ matrix.python-version }} --group dev mypy src/cmasher docs: name: Build docs @@ -169,8 +180,8 @@ jobs: - name: Build run: | - uvx --python 3.12 --with-requirements=requirements/docs.txt --from sphinx \ - sphinx-build -M html docs/source site -W + uvx -p 3.13 --with-requirements=docs/requirements.txt --compile-bytecode \ + --from sphinx sphinx-build -M html docs/source site -W - name: Upload artifacts uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e84d96c3..94b5a391 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -17,4 +17,4 @@ sphinx: python: install: - - requirements: requirements/docs.txt + - requirements: docs/requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index 35fe7ad4..5bacba50 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,7 +2,6 @@ include LICENSE include CITATION include README.rst include MANIFEST.in -include requirements/*.txt include conftest.py recursive-include cmasher data/* recursive-exclude cmasher/colormaps * diff --git a/docs/requirements.in b/docs/requirements.in new file mode 100644 index 00000000..020407e1 --- /dev/null +++ b/docs/requirements.in @@ -0,0 +1,6 @@ +. +sphinx>=7.2.6 +sphinx-autobuild>=2021.3.14 +sphinx_rtd_theme>=2.0.0 +jinja2>=3.1.2 +markupsafe>=2.1.3 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..ff84b7ee --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,112 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile docs/requirements.in +alabaster==1.0.0 + # via sphinx +anyio==4.6.2.post1 + # via + # starlette + # watchfiles +babel==2.16.0 + # via sphinx +certifi==2024.8.30 + # via requests +charset-normalizer==3.4.0 + # via requests +click==8.1.7 + # via uvicorn +. + # via -r docs/requirements.in +colorama==0.4.6 + # via sphinx-autobuild +colorspacious==1.1.2 + # via cmasher +contourpy==1.3.0 + # via matplotlib +cycler==0.12.1 + # via matplotlib +docutils==0.21.2 + # via + # sphinx + # sphinx-rtd-theme +fonttools==4.54.1 + # via matplotlib +h11==0.14.0 + # via uvicorn +idna==3.10 + # via + # anyio + # requests +imagesize==1.4.1 + # via sphinx +jinja2==3.1.4 + # via + # -r docs/requirements.in + # sphinx +kiwisolver==1.4.7 + # via matplotlib +markupsafe==3.0.2 + # via + # -r docs/requirements.in + # jinja2 +matplotlib==3.9.2 + # via cmasher +numpy==2.1.2 + # via + # cmasher + # colorspacious + # contourpy + # matplotlib +packaging==24.1 + # via + # matplotlib + # sphinx +pillow==11.0.0 + # via matplotlib +pygments==2.18.0 + # via sphinx +pyparsing==3.2.0 + # via matplotlib +python-dateutil==2.9.0.post0 + # via matplotlib +requests==2.32.3 + # via sphinx +six==1.16.0 + # via python-dateutil +sniffio==1.3.1 + # via anyio +snowballstemmer==2.2.0 + # via sphinx +sphinx==8.1.3 + # via + # -r docs/requirements.in + # sphinx-autobuild + # sphinx-rtd-theme + # sphinxcontrib-jquery +sphinx-autobuild==2024.10.3 + # via -r docs/requirements.in +sphinx-rtd-theme==3.0.1 + # via -r docs/requirements.in +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jquery==4.1 + # via sphinx-rtd-theme +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +starlette==0.41.0 + # via sphinx-autobuild +urllib3==2.2.3 + # via requests +uvicorn==0.32.0 + # via sphinx-autobuild +watchfiles==0.24.0 + # via sphinx-autobuild +websockets==13.1 + # via sphinx-autobuild diff --git a/docs/source/conf.py b/docs/source/conf.py index fa4a87b7..4e81bd3f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -134,7 +134,6 @@ "sticky_navigation": False, "includehidden": False, "titles_only": False, - "display_version": False, } # Title formatting diff --git a/pyproject.toml b/pyproject.toml index 90dccd6c..92a2ae63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,13 +45,32 @@ Documentation = "https://cmasher.readthedocs.io" [project.scripts] cmr = "cmasher.cli_tools:main" +[dependency-groups] +dev = [ + "coverage[toml]>=7.6.4", + "mypy>=1.7.1", + "pytest>=4.6.0", + "pytest-mpl>=0.13.0", +] + [tool.hatch.build] exclude = [ "scripts", ] +[tool.setuptools] +package-dir = {cmasher = "cmasher"} +include-package-data = true +zip-safe = false +platforms = [ + "Windows", + "Mac OS-X", + "Linux", + "Unix", +] + [tool.pytest.ini_options] -addopts = "-v" +addopts = "-v -ra" filterwarnings = [ "error", "ignore:FigureCanvasAgg is non-interactive:UserWarning", diff --git a/requirements/dev.txt b/requirements/dev.txt deleted file mode 100644 index bae83511..00000000 --- a/requirements/dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage[toml]>=7.6.4 -pyqt5>=5.15.6 -pytest>=4.6.0 -pytest-mpl>=0.13.0 diff --git a/requirements/docs.txt b/requirements/docs.txt deleted file mode 100644 index d6476998..00000000 --- a/requirements/docs.txt +++ /dev/null @@ -1,6 +0,0 @@ --e . -sphinx==7.2.6 -sphinx-autobuild==2021.3.14 -sphinx_rtd_theme==2.0.0 -jinja2==3.1.2 -markupsafe==2.1.3 diff --git a/requirements/typecheck.txt b/requirements/typecheck.txt deleted file mode 100644 index 0aef747d..00000000 --- a/requirements/typecheck.txt +++ /dev/null @@ -1,2 +0,0 @@ -mypy==1.7.1 -pytest==7.4.3 diff --git a/src/cmasher/utils.py b/src/cmasher/utils.py index a245991c..76a7ec94 100644 --- a/src/cmasher/utils.py +++ b/src/cmasher/utils.py @@ -1547,7 +1547,7 @@ def take_cmap_colors( # Convert colors to proper format if return_fmt in ("float", "norm", "int", "8bit"): - colors = np.apply_along_axis(to_rgb, 1, colors) # type: ignore [arg-type] + colors = np.apply_along_axis(to_rgb, 1, colors) # type: ignore [call-overload] if return_fmt in ("int", "8bit"): colors = np.array(np.rint(colors * 255), dtype=int) colors = list(map(tuple, colors))