diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 4b428e03..ccf85f9e 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -12,9 +12,12 @@ build: python: install: - - requirements: requirements/docs.txt - - method: pip - path: . + # Install the project plus the `docs` dependency + # group from pyproject.toml using `uv sync` + - method: uv + command: sync + groups: + - docs sphinx: configuration: docs/conf.py diff --git a/MANIFEST.in b/MANIFEST.in index 37d01270..619e566f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -39,7 +39,6 @@ recursive-include .cursor *.json *.md recursive-include .github *.yml *.yaml recursive-include cicd_utils README.md *.py *.sh recursive-include misc *.py *.ipynb *.txt *.png -recursive-include requirements *.txt recursive-include skills *.md recursive-include tests *.py recursive-include tests/e2e/artifacts *.json diff --git a/Makefile b/Makefile index fff82b13..186def35 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ $(VENV_PATH): | _check-sys ## create a virtual environment .PHONY: install install: $(VENV_PATH) ## install all local development dependencies @echo "==> Installing local development requirements..." - @uv pip install $(_UV_OFFLINE_ARG) --upgrade -r requirements/local-dev.txt + @uv pip install $(_UV_OFFLINE_ARG) --upgrade --editable . --group local-dev @if [ $(OFFLINE) -eq 0 ]; then \ echo "==> Installing pre-commit hooks..."; \ $(VENV_BIN)/pre-commit install --install-hooks; \ diff --git a/docs/reference/changelog.md b/docs/reference/changelog.md index a55ce186..b3b69031 100644 --- a/docs/reference/changelog.md +++ b/docs/reference/changelog.md @@ -13,6 +13,10 @@ Unreleased changes - Add a section on theming with Plotly templates to the getting started guide ({gh-pr}`389`) +### Developer Experience + +- Migrate all development dependencies from `requirements/*.txt` files to PEP 735 dependency groups in `pyproject.toml` ({gh-pr}`388`) + ### CI/CD - Review the coverage configuration in light of `covdefaults`, adopting its `assert_never` exclusion and `skip_covered` report setting, and raising all package coverage gates to 100% ({gh-pr}`390`) diff --git a/pyproject.toml b/pyproject.toml index 75c5acbc..8030b2ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,104 @@ Documentation = "https://ridgeplot.readthedocs.io/en/stable/" "Issue Tracker" = "https://github.com/tpvasconcelos/ridgeplot/issues" Changelog = "https://ridgeplot.readthedocs.io/en/stable/reference/changelog.html" +# Development dependencies (PEP 735 dependency groups) +# These are not included in the built distributions and can be +# installed with e.g. `uv pip install --group local-dev` +[dependency-groups] +cicd_utils = [ + # ./cicd_utils/ridgeplot_examples/_base.py + "minify-html", + # TODO: unpin after 1.0.0 (https://github.com/plotly/Kaleido/issues/226) + # NOTE: 0.2.1.post1 is excluded because it only ships a + # manylinux2014_armv7l wheel, which breaks universal + # (multi-platform) resolution with `uv sync`/`uv lock` + "kaleido<0.4,!=0.2.1.post1", + # ./cicd_utils/cicd/scripts/extract_latest_release_notes.py + "markdown-it-py", + "mdit-py-plugins", + "mdformat", + "mdformat-footnote", +] +tests = [ + # pytest and plugins + # (pytest>=9 is needed for the `strict` config option set in pytest.ini) + "pytest>=9", + "pytest-icdiff", + "pytest-socket", + # Coverage + "diff-cover", + "pytest-cov", + # `cicd_utils` requirements also need to be + # installed in order to test these utilities + { include-group = "cicd_utils" }, +] +docs = [ + # Depends on `cicd_utils` + { include-group = "cicd_utils" }, + # Sphinx dependencies + "furo", + "jinja2", + "myst-parser>=0.19.0", + "sphinx", + "sphinx-autobuild", + "sphinx-autodoc-typehints", + "sphinx-copybutton", + "sphinx-inline-tabs", + "sphinx-notfound-page", + "sphinx-paramlinks", + "sphinx-remove-toctrees", + "sphinx-sitemap", + "sphinx-togglebutton", + "sphinx-toolbox", + "sphinx_design", + "sphinx_thebe", + "sphinxcontrib-apidoc", + "sphinxext-opengraph", + # matplotlib is used to generate social cards + "matplotlib", + # Cleanup generated files + "pre_commit_hooks", +] +typing = [ + # pyright + "pyright", + # Third-party stubs + "types-python-dateutil", + "types-pytz", + "types-PyYAML", + "types-requests", + "types-tqdm", + "pandas-stubs", + # These seem to bring more problems than they solve for now... 👇 + # "plotly-stubs", + # pyright also needs to inherit other environment dependencies in + # order to correctly infer types for code in tests, docs, etc. + { include-group = "cicd_utils" }, + { include-group = "docs" }, + { include-group = "tests" }, +] +local-dev = [ + # build dependencies + "setuptools>=64", + "setuptools-scm>=8", + # Tox + "tox", + # pre-commit + "pre-commit", + # Releases are still a manual process that + # requires the use of bumpversion locally + "bumpversion", + # Various useful utilities for local development + "ipython", + "pipdeptree", + "ptpython", + # And everything else... + { include-group = "cicd_utils" }, + { include-group = "docs" }, + { include-group = "typing" }, + { include-group = "tests" }, +] + # TODO: Update config based on: # https://setuptools.pypa.io/en/latest/userguide/datafiles.html#subdirectory-for-data-files #[tool.setuptools.package-data] diff --git a/requirements/cicd_utils.txt b/requirements/cicd_utils.txt deleted file mode 100644 index 6cd107d9..00000000 --- a/requirements/cicd_utils.txt +++ /dev/null @@ -1,10 +0,0 @@ -# ./cicd_utils/ridgeplot_examples/_base.py -minify-html -# TODO: unpin after 1.0.0 (https://github.com/plotly/Kaleido/issues/226) -kaleido<0.4 - -# ./cicd_utils/cicd/scripts/extract_latest_release_notes.py -markdown-it-py -mdit-py-plugins -mdformat -mdformat-footnote diff --git a/requirements/docs.txt b/requirements/docs.txt deleted file mode 100644 index aac42d7b..00000000 --- a/requirements/docs.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Documentation requirements - -# Depends on `cicd_utils` --r cicd_utils.txt - -# Sphinx dependencies -furo -jinja2 -myst-parser>=0.19.0 -sphinx -sphinx-autobuild -sphinx-autodoc-typehints -sphinx-copybutton -sphinx-inline-tabs -sphinx-notfound-page -sphinx-paramlinks -sphinx-remove-toctrees -sphinx-sitemap -sphinx-togglebutton -sphinx-toolbox -sphinx_design -sphinx_thebe -sphinxcontrib-apidoc -sphinxext-opengraph - -# matplotlib is used to generate social cards -matplotlib - -# Cleanup generated files -pre_commit_hooks diff --git a/requirements/local-dev.txt b/requirements/local-dev.txt deleted file mode 100644 index 5f7bce80..00000000 --- a/requirements/local-dev.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Install python package in editable mode --e file:. - -# build dependencies -setuptools>=64 -setuptools-scm>=8 - -# Tox -tox - -# pre-commit -pre-commit - -# Releases are still a manual process that -# requires the use of bumpversion locally -bumpversion - -# Various useful utilities for local development -ipython -pipdeptree -ptpython - -# And everything else... --r cicd_utils.txt --r docs.txt --r typing.txt --r tests.txt diff --git a/requirements/tests.txt b/requirements/tests.txt deleted file mode 100644 index 686fc433..00000000 --- a/requirements/tests.txt +++ /dev/null @@ -1,13 +0,0 @@ -# pytest and plugins -# (pytest>=9 is needed for the `strict` config option set in pytest.ini) -pytest>=9 -pytest-icdiff -pytest-socket - -# Coverage -diff-cover -pytest-cov - -# `cicd_utils` requirements also need to be -# installed in order to test these utilities --r cicd_utils.txt diff --git a/requirements/typing.txt b/requirements/typing.txt deleted file mode 100644 index eb8e2e12..00000000 --- a/requirements/typing.txt +++ /dev/null @@ -1,18 +0,0 @@ -# pyright -pyright - -# Third-party stubs -types-python-dateutil -types-pytz -types-PyYAML -types-requests -types-tqdm -pandas-stubs -# These seem to bring more problems than they solve for now... 👇 -# plotly-stubs - -# pyright also needs to inherit other environment dependencies in -# order to correctly infer types for code in tests, docs, etc. --r cicd_utils.txt --r docs.txt --r tests.txt diff --git a/tox.ini b/tox.ini index c5c06e9a..653afadb 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,9 @@ labels = upgrade-requirements = pre-commit-autoupgrade isolated_build = true requires = - tox>=4 - tox-uv + # tox>=4.22 is required for `dependency_groups` support + tox>=4.22 + tox-uv>=1.17 [testenv] description = run the pytest tests under {basepython} @@ -27,7 +28,18 @@ passenv = GITHUB_* PYTEST_* parallel_show_output = true -deps = -r requirements/tests.txt +# Install the `tests` dependency group (from pyproject.toml), but only in +# the envs that run tests or coverage. The `pytest,tests,coverage:` prefix +# is tox's factor-conditional syntax (also used in `commands` below): the +# value after the colon only applies to envs matching one of these factors, +# i.e. `pytest`, `tests-{unit,e2e,cicd_utils}`, and `coverage-combine`. +# Without this guard, envs that inherit from this section but don't override +# this key (e.g. `build-dists` and `pre-commit-*`) would also install the +# test dependencies. NOTE: the `tests` factor (left of the colon) and the +# `tests` dependency group (right of the colon) are different things that +# just happen to share a name. +dependency_groups = + pytest,tests,coverage: tests allowlist_externals = rm, mv commands = rm -rf build/ @@ -71,7 +83,7 @@ commands = [testenv:typing] description = run type checks -deps = -r requirements/typing.txt +dependency_groups = typing commands = pyright --skipunannotated @@ -80,7 +92,7 @@ description = generate Sphinx (live/static) HTML documentation setenv = {[testenv]setenv} PYTHONPATH={env:PYTHONPATH}{:}{toxinidir}/cicd_utils -deps = -r requirements/docs.txt +dependency_groups = docs allowlist_externals = make commands = make clean-docs @@ -91,7 +103,7 @@ commands = [testenv:release-notes] description = extract release notes from docs/reference/changelog.md skip_install = true -deps = -r requirements/cicd_utils.txt +dependency_groups = cicd_utils commands = python cicd_utils/cicd/scripts/extract_latest_release_notes.py [testenv:build-dists]