Skip to content

Commit

Permalink
MNT: migrate requirement files to PEP 735 dependency groups
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 27, 2024
1 parent 5f7d5fb commit bc03322
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 51 deletions.
10 changes: 0 additions & 10 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
59 changes: 35 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -62,33 +72,36 @@ 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

- name: Test package (no coverage)
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
# combining reports from multiple platforms is tricky (or impossible ?)
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
Expand Down Expand Up @@ -128,6 +141,7 @@ jobs:
name: type check w/ Python ${{ matrix.python-version }}

strategy:
fail-fast: false
matrix:
python-version:
- '3.10'
Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ sphinx:

python:
install:
- requirements: requirements/docs.txt
- requirements: docs/requirements.txt
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
6 changes: 6 additions & 0 deletions docs/requirements.in
Original file line number Diff line number Diff line change
@@ -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
112 changes: 112 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
"sticky_navigation": False,
"includehidden": False,
"titles_only": False,
"display_version": False,
}

# Title formatting
Expand Down
21 changes: 20 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions requirements/dev.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements/docs.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/typecheck.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/cmasher/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bc03322

Please sign in to comment.