Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dependency groups #32

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions {{cookiecutter.package_name}}/.readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ build:

python:
install:
- method: pip
path: .
extra_requirements:
- docs
# partial override of build commands was added in https://github.com/readthedocs/readthedocs.org/pull/11710
# you can include extras with .[] notation
- pip install --dependency-groups=docs .
45 changes: 44 additions & 1 deletion {{cookiecutter.package_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ dependencies = [
{% endif %}
]

[project.optional-dependencies]
# see https://peps.python.org/pep-0735/ and https://docs.astral.sh/uv/concepts/dependencies/#dependency-groups
[dependency-groups]
tests = [
"pytest",
"coverage",
Expand All @@ -74,6 +75,48 @@ docs = [
# If you uncomment this, don't forget to do the same in docs/conf.py
# texext
]
lint = [
"ruff",
]
typing = [
"mypy",
"pydantic",
]
doc8 = [
{ include-group = "docs" },
"doc8",
]
rstfmt = [
{ include-group = "docs" },
"rstfmt",
]
doctests = [
"xdoctest",
"pygments",
]
pyroma = [
"pyroma",
"pygments",
]
bump = [
"bump-my-version",
]
build = [
"uv",
"setuptools",
]
release = [
{ include-group = "build" },
"twine",
]
manifest = [
"check-manifest",
]


# see https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-optional-dependencies
# [project.optional-dependencies]


# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#urls
[project.urls]
Expand Down
84 changes: 37 additions & 47 deletions {{cookiecutter.package_name}}/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ commands =
coverage run -p -m pytest --durations=20 {posargs:tests}
coverage combine
coverage xml
extras =
# See the [project.optional-dependencies] entry in pyproject.toml for "tests"
# See the [dependency-groups] entry in pyproject.toml for "tests"
dependency-groups =
tests

[testenv:coverage-clean]
Expand All @@ -52,9 +52,8 @@ commands = coverage erase
description = Test that documentation examples run properly.
commands =
xdoctest -m src
deps =
xdoctest
pygments
dependency-groups =
doctests

[testenv:treon]
description = Test that notebooks can run to completion
Expand All @@ -65,64 +64,58 @@ deps =

[testenv:format]
description = Format the code in a deterministic way using ruff. Note that ruff check should come before ruff format when using --fix (ref: https://github.com/astral-sh/ruff-pre-commit/blob/main/README.md)
deps =
ruff
dependency-groups =
lint
skip_install = true
commands =
ruff check --fix
ruff format

[testenv:format-docs]
description = Run documentation linters.
# note that this doesn't work with sphinx-click
# or any other extension that adds extra directives
deps =
description = Run documentation linters.
# See the [dependency-groups] entry in pyproject.toml for "rstfmt"
dependency-groups =
rstfmt
extras =
# See the [project.optional-dependencies] entry in pyproject.toml for "docs"
docs
skip_install = true
commands =
rstfmt docs/source/

[testenv:manifest]
deps = check-manifest
dependency-groups =
manifest
skip_install = true
commands = check-manifest
description = Check that the MANIFEST.in is written properly and give feedback on how to fix it.

[testenv:lint]
description = Check code quality using ruff and other tools.

skip_install = true
deps =
ruff
dependency-groups =
lint
commands =
ruff check
ruff format --check

[testenv:pyroma]
deps =
pygments
dependency-groups =
pyroma
skip_install = true
commands = pyroma --min=10 .
description = Run the pyroma tool to check the package friendliness of the project.

[testenv:mypy]
description = Run the mypy tool to check static typing on the project.
deps =
mypy
pydantic
dependency-groups =
typing
skip_install = true
commands = mypy --install-types --non-interactive --ignore-missing-imports --strict src/

[testenv:doc8]
skip_install = true
deps =
dependency-groups =
doc8
extras =
docs
commands =
doc8 docs/source/
description = Run the doc8 tool to check the style of the RST files in the project docs.
Expand All @@ -137,8 +130,8 @@ commands =

[testenv:docs]
description = Build the documentation locally, allowing warnings.
extras =
# See the [project.optional-dependencies] entry in pyproject.toml for "docs"
dependency-groups =
# See the [dependency-groups] entry in pyproject.toml for "docs"
docs
# You might need to add additional extras if your documentation covers it
commands =
Expand All @@ -147,8 +140,8 @@ commands =
[testenv:docs-test]
description = Test building the documentation in an isolated environment. Warnings are considered as errors via -W.
changedir = docs
extras =
{[testenv:docs]extras}
dependency-groups =
{[testenv:docs]dependency-groups}
commands =
mkdir -p {envtmpdir}
cp -r source {envtmpdir}/source
Expand Down Expand Up @@ -178,22 +171,21 @@ description = Bump the version number
commands = bump-my-version bump {posargs}
skip_install = true
passenv = HOME
deps =
bump-my-version
dependency-groups =
bump

[testenv:bumpversion-release]
description = Remove the -dev tag from the version
commands = bump-my-version bump release --tag
skip_install = true
passenv = HOME
deps =
bump-my-version
dependency-groups =
bump

[testenv:build]
skip_install = true
deps =
uv
setuptools
dependency-groups =
build
commands =
uv build --sdist --wheel --no-build-isolation

Expand Down Expand Up @@ -230,9 +222,8 @@ skip_install = true
passenv =
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:build]deps}
twine >= 1.5.0
dependency-groups =
release
commands =
{[testenv:build]commands}
twine check dist/*
Expand All @@ -247,9 +238,9 @@ passenv =
HOME
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:release]deps}
bump-my-version
dependency-groups =
bump
release
commands =
{[testenv:bumpversion-release]commands}
{[testenv:release]commands}
Expand Down Expand Up @@ -293,9 +284,8 @@ skip_install = true
passenv =
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:build]deps}
twine >= 1.5.0
dependency-groups =
release
commands =
{[testenv:build]commands}
twine check dist/*
Expand All @@ -310,9 +300,9 @@ passenv =
HOME
TWINE_USERNAME
TWINE_PASSWORD
deps =
{[testenv:testrelease]deps}
bump-my-version
dependency-groups =
bump
release
commands =
{[testenv:bumpversion-release]commands}
{[testenv:testrelease]commands}
Expand Down