From ecb4382a581af93b437687e7ac2430c73973d323 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Fri, 24 Apr 2026 14:37:48 -0600 Subject: [PATCH] build: adopt PEP 735 dependency groups for dev/test/doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aligns cell-annotator with cookiecutter-scverse v0.7.0 by moving development-only dependencies from `[project.optional-dependencies]` to `[dependency-groups]` (PEP 735). Provider layers stay as `optional-dependencies` since end users install them via `pip install cell-annotator[openai]` etc. Layout: - `[dependency-groups]`: - `dev` = pre-commit, twine - `test` = Python test packages (pytest, coverage, flaky, pytest-cov) - `doc` = Sphinx stack - `[project.optional-dependencies]`: - provider layers (openai, anthropic, gemini, all-providers, colors, gpu, tutorials) — unchanged - `test` thinned to a pointer at `cell-annotator[all-providers]` + `cell-annotator[colors]`, so `pip install cell-annotator[test]` still pulls the provider extras the suite exercises. Python test packages are no longer duplicated here. - `[tool.hatch.envs.*]`: - switched `features = [...]` to `dependency-groups = [...]` for the default, docs, and hatch-test envs. - hatch-test also keeps `features = [ "test" ]` so the provider extras flow in via the thin pointer above. Docs: - `docs/contributing.md` — pip recipe updated to use `pip install --group dev --group test --group doc -e ".[test]"` (pip 25.1+). uv recipe updated to `uv sync --all-extras --all-groups`. Validation: - `uv sync --all-extras --all-groups` resolves cleanly. - `uv run --group test --extra test pytest` → 188 passed. - `hatch env show -i` lists the hatch-test matrix correctly. - `sphinx-build -M html docs docs/_build` succeeds with no warnings. Part of #73. --- docs/contributing.md | 13 ++++++-- pyproject.toml | 70 +++++++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index 89c5c86..96f3d1f 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -106,9 +106,12 @@ only because an outdated sphinx plugin pins an older version. To initalize a virtual environment in the `.venv` directory of your project, simply run ```bash -uv sync --all-extras +uv sync --all-extras --all-groups ``` +`--all-extras` pulls in the provider layers (openai, anthropic, gemini, …); +`--all-groups` pulls in the `dev`, `test`, and `doc` PEP 735 dependency groups. + The `.venv` directory is typically automatically discovered by IDEs such as VS Code. :::: @@ -122,11 +125,17 @@ we describe how you can manage environments manually using `pip`: ```bash python3 -m venv .venv source .venv/bin/activate -pip install -e ".[dev,test,doc]" +pip install --group dev --group test --group doc -e ".[test]" ``` The `.venv` directory is typically automatically discovered by IDEs such as VS Code. +Note: `pip install --group` requires pip >= 25.1 ([PEP 735][]). +The `-e ".[test]"` extra pulls in the provider layers the test suite +exercises; `--group` pulls in the dev / test / doc Python packages. + +[PEP 735]: https://peps.python.org/pep-0735/ + :::: ::::: diff --git a/pyproject.toml b/pyproject.toml index 5c20224..307eb40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,27 +45,6 @@ optional-dependencies.anthropic = [ optional-dependencies.colors = [ "colorspacious>=1.1", ] -# Development dependencies -optional-dependencies.dev = [ - "pre-commit", - "twine>=4.0.2", -] -optional-dependencies.doc = [ - "docutils>=0.8,!=0.18.*,!=0.19.*", - "ipykernel", - "ipython", - "myst-nb>=1.1", - "pandas", - # Until pybtex >0.24.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/ - "setuptools", - "sphinx>=8.1", - "sphinx-autodoc-typehints", - "sphinx-book-theme>=1", - "sphinx-copybutton", - "sphinx-tabs", - "sphinxcontrib-bibtex>=1", - "sphinxext-opengraph", -] optional-dependencies.gemini = [ "google-genai>=1.27", ] @@ -76,13 +55,12 @@ optional-dependencies.gpu = [ optional-dependencies.openai = [ "openai>=1.90", ] +# Thin pointer so `pip install cell-annotator[test]` pulls in the provider extras +# that the test suite exercises. Python test dependencies live in +# [dependency-groups] test below and are pulled in by hatch / `uv sync --group test`. optional-dependencies.test = [ - "cell-annotator[all-providers]", # tests use all providers - "cell-annotator[colors]", # tests use color validation - "coverage>=7.10", - "flaky", - "pytest", - "pytest-cov", # For VS Code's coverage functionality + "cell-annotator[all-providers]", + "cell-annotator[colors]", ] optional-dependencies.tutorials = [ "squidpy>=1.6", @@ -92,15 +70,47 @@ urls.Documentation = "https://cell-annotator.readthedocs.io/" urls.Homepage = "https://cell-annotator.readthedocs.io/" urls.Source = "https://github.com/quadbio/cell-annotator" +[dependency-groups] +dev = [ + "pre-commit", + "twine>=4.0.2", +] +test = [ + "coverage>=7.10", + "flaky", + "pytest", + "pytest-cov", # For VS Code's coverage functionality +] +doc = [ + "docutils>=0.8,!=0.18.*,!=0.19.*", + "ipykernel", + "ipython", + "myst-nb>=1.1", + "pandas", + # Until pybtex >0.24.0 releases: https://bitbucket.org/pybtex-devs/pybtex/issues/169/ + "setuptools", + "sphinx>=8.1", + "sphinx-autodoc-typehints", + "sphinx-book-theme>=1", + "sphinx-copybutton", + "sphinx-tabs", + "sphinxcontrib-bibtex>=1", + "sphinxext-opengraph", +] + [tool.hatch] envs.default.installer = "uv" -envs.default.features = [ "dev" ] -envs.docs.features = [ "doc" ] +envs.default.dependency-groups = [ "dev" ] +envs.docs.dependency-groups = [ "doc" ] envs.docs.dev-mode = true envs.docs.scripts.build = "sphinx-build -M html docs docs/_build {args}" envs.docs.scripts.open = "python -m webbrowser -t docs/_build/html/index.html" envs.docs.scripts.clean = "git clean -fdX -- {args:docs}" -envs.hatch-test.features = [ "dev", "test" ] +# hatch-test needs both: +# - dependency-groups: Python test packages (pytest, coverage, flaky, ...) +# - features: provider extras via optional-dependencies.test thin pointer +envs.hatch-test.dependency-groups = [ "dev", "test" ] +envs.hatch-test.features = [ "test" ] envs.hatch-test.matrix = [ # Test the lowest and highest supported Python versions with normal deps { deps = [ "stable" ], python = [ "3.11", "3.13" ] },