From f6bc105d58e31f3e71c5592471e4c4cff8f2b992 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 11:47:37 +0100 Subject: [PATCH 1/8] chore: update cookiecutter install and typing setup --- docs/source/index.md | 10 +++++----- justfile | 10 +++++----- pyproject.toml | 2 +- .../src/{{cookiecutter.project_slug}}/__init__.py | 3 +-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/source/index.md b/docs/source/index.md index 2dfa30e..41b1223 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -62,15 +62,15 @@ A: This is called the src layout and the advantages are discussed in this Although the article discusses the src layout in terms of Python packages, it is also beneficial to structure a project the same way. Next to the reasons discussed there, it is possible to use a single Python environment for multiple projects without messing -with your PYTHONPATH (via `pip install -e .` or `conda develop .`) each time and still -import modules. +with your PYTHONPATH (for example, via editable installs) each time and still import +modules. Q: My project is a Python package, but it does not seem to have a version. Where is it? A: The cookiecutter uses [setuptools_scm](https://github.com/pypa/setuptools_scm/) to -manage the version number. When you install your created project as a Python package -with `pip install -e .`, setuptools_scm tries to infer the version number from the tags -created on the repo. +manage the version number. When you install your created project as a Python package in +editable mode, setuptools_scm tries to infer the version number from the tags created on +the repo. For example, if you have switched to a commit associated with the tag `v0.2.0`, setuptools_scm will create a `src//_version.py` with a variable containing diff --git a/justfile b/justfile index e9bd3a1..7beff40 100644 --- a/justfile +++ b/justfile @@ -4,15 +4,15 @@ install: # Run tests test: - uv run --extra test pytest + uv run --group test pytest # Run tests with coverage test-cov: - uv run --extra test pytest --cov=./ --cov-report=xml + uv run --group test pytest --cov=./ --cov-report=xml # Run type checking typing: - uv run --extra typing --extra test ty check hooks/ tests/ + uv run --group typing --group test --isolated ty check hooks/ tests/ # Run linting and formatting lint: @@ -23,5 +23,5 @@ check: lint typing test # Build docs and run doctests docs: - uv run --extra docs --extra test sphinx-build -n -T -b html -d docs/build/doctrees docs/source docs/build/html - uv run --extra docs --extra test sphinx-build -n -T -b doctest -d docs/build/doctrees docs/source docs/build/html + uv run --group docs --group test sphinx-build -n -T -b html -d docs/build/doctrees docs/source docs/build/html + uv run --group docs --group test sphinx-build -n -T -b doctest -d docs/build/doctrees docs/source docs/build/html diff --git a/pyproject.toml b/pyproject.toml index 18c56b0..7ab1ce9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ dependencies = ["cookiecutter"] name = "Tobias Raabe" email = "raabe@posteo.de" -[project.optional-dependencies] +[dependency-groups] docs = [ "furo", "ipython", diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py index 75190c8..bc1f9e7 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/__init__.py @@ -1,8 +1,7 @@ """Contains the main namespace of {{ cookiecutter.project_slug }}.""" # Import the version from _version.py which is dynamically created by setuptools-scm -# when the project is installed with ``pip install -e .``. Do not put it into version -# control! +# when the project is installed in editable mode. Do not put it into version control! try: from ._version import version as __version__ # ty: ignore[unresolved-import] except ImportError: From b77517312ef657436138f228df313ddd2747bede Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 12:46:28 +0100 Subject: [PATCH 2/8] fix: make docs build without installed package --- docs/source/conf.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6bc1e6a..d4acb9a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -5,7 +5,10 @@ """ +from importlib.metadata import PackageNotFoundError from importlib.metadata import version +from pathlib import Path +import tomllib # -- Project information ----------------------------------------------------- @@ -16,7 +19,12 @@ copyright = f"2021, {author}" # noqa: A001 # The version, including alpha/beta/rc tags, but not commit hash and datestamps -release = version("cookiecutter-pytask-project") +try: + release = version("cookiecutter-pytask-project") +except PackageNotFoundError: + pyproject_path = Path(__file__).resolve().parents[2] / "pyproject.toml" + with pyproject_path.open("rb") as f: + release = tomllib.load(f)["project"]["version"] # The short X.Y version. version = ".".join(release.split(".")[:2]) @@ -28,6 +36,7 @@ extensions = [ "IPython.sphinxext.ipython_console_highlighting", "IPython.sphinxext.ipython_directive", + "sphinx.ext.doctest", "sphinx.ext.autodoc", "sphinx.ext.autosummary", "sphinx.ext.extlinks", From 43749639bacc9ee0833176e47d3f0092a7e11f94 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 12:49:16 +0100 Subject: [PATCH 3/8] chore: bump ty minimum to 0.0.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7ab1ce9..db8cfe9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ docs = [ "sphinxext-opengraph", ] test = ["pytest", "pytest-cookies", "pytest-cov"] -typing = ["ty>=0.0.7"] +typing = ["ty>=0.0.8"] [project.readme] file = "README.md" From 31c4dcc59bdc5a20ac6e4a57125f338de533d084 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 12:52:52 +0100 Subject: [PATCH 4/8] fix: build docs with installed package --- docs/source/conf.py | 10 +--------- justfile | 1 + pyproject.toml | 10 ++++++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index d4acb9a..dc73897 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -5,10 +5,7 @@ """ -from importlib.metadata import PackageNotFoundError from importlib.metadata import version -from pathlib import Path -import tomllib # -- Project information ----------------------------------------------------- @@ -19,12 +16,7 @@ copyright = f"2021, {author}" # noqa: A001 # The version, including alpha/beta/rc tags, but not commit hash and datestamps -try: - release = version("cookiecutter-pytask-project") -except PackageNotFoundError: - pyproject_path = Path(__file__).resolve().parents[2] / "pyproject.toml" - with pyproject_path.open("rb") as f: - release = tomllib.load(f)["project"]["version"] +release = version("cookiecutter-pytask-project") # The short X.Y version. version = ".".join(release.split(".")[:2]) diff --git a/justfile b/justfile index 7beff40..23b2f2e 100644 --- a/justfile +++ b/justfile @@ -23,5 +23,6 @@ check: lint typing test # Build docs and run doctests docs: + uv sync --group docs --group test uv run --group docs --group test sphinx-build -n -T -b html -d docs/build/doctrees docs/source docs/build/html uv run --group docs --group test sphinx-build -n -T -b doctest -d docs/build/doctrees docs/source docs/build/html diff --git a/pyproject.toml b/pyproject.toml index db8cfe9..b539bd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,16 @@ classifiers = [ requires-python = ">=3.10" dependencies = ["cookiecutter"] +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +only-include = ["cookiecutter.json", "hooks", "{{cookiecutter.project_slug}}"] + +[tool.hatch.build.targets.sdist] +only-include = ["cookiecutter.json", "hooks", "{{cookiecutter.project_slug}}"] + [[project.authors]] name = "Tobias Raabe" email = "raabe@posteo.de" From 49d22eb66000e4bd435217e9415bb5393554645c Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 12:54:14 +0100 Subject: [PATCH 5/8] chore: add weekly dependabot for uv --- .github/dependabot.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 718572b..6483b1d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,6 @@ version: 2 - updates: - - package-ecosystem: "github-actions" + - package-ecosystem: "uv" directory: "/" schedule: interval: "weekly" From 50e2ce292fe725b13644e25b331e68f6e830e7a8 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 13:06:44 +0100 Subject: [PATCH 6/8] chore: add github-actions dependabot updates --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6483b1d..c766b7e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,5 +1,9 @@ version: 2 updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" - package-ecosystem: "uv" directory: "/" schedule: From 6dad71640ee5df3d9b0baaf338fe588bfe6fe3f2 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 15:42:00 +0100 Subject: [PATCH 7/8] chore: group github-actions dependabot updates --- .github/dependabot.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c766b7e..be4ca53 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,14 @@ version: 2 + updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" + groups: + github-actions: + patterns: + - "*" - package-ecosystem: "uv" directory: "/" schedule: From 907c3646e9d454a81535120eca347b743bd3a511 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 31 Dec 2025 16:15:53 +0100 Subject: [PATCH 8/8] fix: use uv for rtd docs --- .readthedocs.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 1478786..633e182 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,17 +1,18 @@ version: 2 build: - os: ubuntu-22.04 + os: ubuntu-24.04 tools: - python: "3.10" + python: "3.12" + jobs: + create_environment: + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest + - UV_NO_EDITABLE=1 UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --group docs + install: + - "true" sphinx: configuration: docs/source/conf.py fail_on_warning: true - -python: - install: - - method: pip - path: . - extra_requirements: - - docs