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 28, 2024
1 parent 3a7c3e4 commit 74723f4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
31 changes: 16 additions & 15 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,7 +29,7 @@ jobs:
- '3.11'
- '3.12'
- '3.13'
test-args: [viscm>=0.10]
install-args: ['']

include:
- os: ubuntu-20.04
Expand All @@ -45,7 +45,7 @@ jobs:
python-version: '3.13'

concurrency:
group: ${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}-build
group: ${{ github.ref }}-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.install-args }}-build
cancel-in-progress: true

steps:
Expand All @@ -56,21 +56,24 @@ jobs:
cache-dependency-glob: pyproject.toml

- name: Build
shell: bash # for windows-compat
run: |
uv venv --python ${{ matrix.python-version }}
uv pip install . ${{ 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 }} .
- run: uv pip list

- name: Test package (no coverage)
if: ${{ !startsWith( matrix.os , 'ubuntu' ) }}
run: uv run ${{ matrix.install-args }} pytest --color=yes --mpl
shell: bash # for windows-compat
run: |
uv run --verbose --group dev ${{ matrix.install-args }} \
pytest --color=yes --mpl
- name: Test package (with coverage)
if: startsWith( matrix.os , 'ubuntu' )
run: |
uv run ${{ matrix.install-args }} \
uv run --verbose --group dev ${{ matrix.install-args }} \
coverage run --parallel-mode -m pytest --color=yes --mpl
- name: Upload coverage data
Expand All @@ -79,7 +82,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 }}
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
Expand Down Expand Up @@ -119,6 +122,7 @@ jobs:
name: type check w/ Python ${{ matrix.python-version }}

strategy:
fail-fast: false
matrix:
python-version:
- '3.10'
Expand All @@ -138,10 +142,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 @@ -160,8 +161,8 @@ jobs:

- name: Build
run: |
uvx --python 3.12 --with-requirements=docs/requirements.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
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
27 changes: 26 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,38 @@ Documentation = "https://cmasher.readthedocs.io"
[project.scripts]
cmr = "cmasher.cli_tools:main"

[dependency-groups]
test = [
"coverage[toml]>=7.6.4",
"pytest>=4.6.0",
"pytest-mpl>=0.13.0",
]
typecheck = [
"mypy>=1.7.1",
]
dev = [
{include-group = "test"},
{include-group = "typecheck"},
]

[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.

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 @@ -1545,7 +1545,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 74723f4

Please sign in to comment.