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 58e3045 commit 041498e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 33 deletions.
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 . ${{ 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=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
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.

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 041498e

Please sign in to comment.