diff --git a/README.md b/README.md index a117a315..36521a78 100644 --- a/README.md +++ b/README.md @@ -55,9 +55,11 @@ cd example-research-software-project git init # uv venv # source .venv/bin/activate -uv pip install -e ".[dev]" +uv sync ``` +Note that `uv>=0.6.7` is required to use the `--group` option. + diff --git a/tests/data/test_package_generation/pyproject.toml b/tests/data/test_package_generation/pyproject.toml index 6a488554..bb190c47 100644 --- a/tests/data/test_package_generation/pyproject.toml +++ b/tests/data/test_package_generation/pyproject.toml @@ -5,6 +5,27 @@ requires = [ "setuptools-scm", ] +[dependency-groups] +dev = [ + "build", + "mypy", + "pre-commit", + "ruff", + "tox", + "twine", +] +docs = [ + "mkdocs", + "mkdocs-include-markdown-plugin", + "mkdocs-material", + "mkdocstrings", + "mkdocstrings-python", +] +test = [ + "pytest", + "pytest-cov", +] + [project] authors = [ {email = "eva.lu.ator@ucl.ac.uk", name = "Eva Lu Ator"}, @@ -31,23 +52,6 @@ license-files = [ "LICENSE.md", ] name = "cookiecutter-test" -optional-dependencies = {dev = [ - "build", - "mypy", - "pre-commit", - "ruff", - "tox", - "twine", -], docs = [ - "mkdocs", - "mkdocs-include-markdown-plugin", - "mkdocs-material", - "mkdocstrings", - "mkdocstrings-python", -], test = [ - "pytest", - "pytest-cov", -]} readme = "README.md" requires-python = ">=3.11" urls.homepage = "https://github.com/test-user/cookiecutter-test" @@ -126,7 +130,7 @@ env_run_base = {commands = [ "--cov", "--cov-report=xml", ], -], extras = [ +], dependency_groups = [ "test", ]} env.docs = {commands = [ @@ -135,7 +139,7 @@ env.docs = {commands = [ "build", "--strict", ], -], extras = [ +], dependency_groups = [ "docs", ]} gh.python."3.11" = ["py311"] diff --git a/tutorial.md b/tutorial.md index f4c2ee78..9d8c1858 100644 --- a/tutorial.md +++ b/tutorial.md @@ -309,10 +309,10 @@ uv venv --python 3.11.6 Once you have created and activated a virtual environment for the project, you can install the package in [editable mode](https://setuptools.pypa.io/en/latest/userguide/development_mode.html), along with both its required dependencies and optional sets of dependencies for development (`dev`), documentation (`docs`) and testing (`test`) by running ```sh -uv pip install --editable ".[dev,docs,test]" +uv sync --all-groups ``` -from the root of the project repository. +from the root of the project repository. Note that `uv>=0.6.7` is required to use the `--group` option.
Using venv as an alternative to uv @@ -343,9 +343,11 @@ python -m pip install --upgrade pip Similar to `uv`, once the environment is active, you can install the package in editable mode as well as all dependencies: ```sh -python -m pip install --editable ".[dev,docs,test]" +python -m pip install --editable . --group dev --group docs --group test ``` +Note that `pip>=25.1` is required to use the `--group` option. +
## 🧪 Running package tests locally diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 64cacb44..ff1c0861 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -5,6 +5,27 @@ requires = [ "setuptools-scm", ] +[dependency-groups] +dev = [ + "build", + "mypy", + "pre-commit", + "ruff", + "tox", + "twine", +] +docs = [ + "mkdocs", + "mkdocs-include-markdown-plugin", + "mkdocs-material", + "mkdocstrings", + "mkdocstrings-python", +] +test = [ + "pytest", + "pytest-cov", +] + [project] authors = [ {email = "{{cookiecutter.author_email}}", name = "{{cookiecutter.author_given_names}} {{cookiecutter.author_family_names}}"}, @@ -34,23 +55,6 @@ license-files = [ "LICENSE.md", ] name = "{{cookiecutter.project_slug}}" -optional-dependencies = {dev = [ - "build", - "mypy", - "pre-commit", - "ruff", - "tox", - "twine", -], docs = [ - "mkdocs", - "mkdocs-include-markdown-plugin", - "mkdocs-material", - "mkdocstrings", - "mkdocstrings-python", -], test = [ - "pytest", - "pytest-cov", -]} readme = "README.md" requires-python = ">={{cookiecutter.min_python_version}}" urls.homepage = "{{cookiecutter.__repo_url}}" @@ -132,7 +136,7 @@ env_run_base = {commands = [ "--cov", "--cov-report=xml", ], -], extras = [ +], dependency_groups = [ "test", ]} env.docs = {commands = [ @@ -141,7 +145,7 @@ env.docs = {commands = [ "build", "--strict", ], -], extras = [ +], dependency_groups = [ "docs", ]} {%- for python_version in range(