Skip to content

Using tool.uv.dependency-groups with a uv.toml #14308

@mikeweltevrede

Description

@mikeweltevrede

Summary

When using the below pyproject.toml, running uv sync --all-groups fails (as expected) due to

Because the requested Python version (>=3.9, <4.0) does not satisfy Python>=3.11 and sphinx==8.2.3 depends on Python>=3.11, we can conclude that sphinx==8.2.3 cannot be used. And because test-dependency-groups:docs depends on sphinx==8.2.3 and your project requires test-dependency-groups:docs, we can conclude that your project's requirements are unsatisfiable.

# pyproject.toml
[project]
name = "test-dependency-groups"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = "<4.0,>=3.9"
dependencies = [
    "requests==2.27.1; python_version == '3.9'",
    "requests==2.28.1; python_version == '3.10'",
    "requests==2.31.0; python_version == '3.11'",
    "requests==2.32.2; python_version == '3.12'",
    "requests; python_version > '3.12'",
]

[dependency-groups]
docs = [
    "sphinx==8.2.3",
]

I wanted to solve this by using tool.uv.dependency-groups as introduced in #13735. Indeed it works if I add it to the pyproject.toml like so, uv is indeed able to compile:

# pyproject.toml
[tool.uv.dependency-groups]
docs = {requires-python = ">=3.11"}

However, there are two cases that do not work as expected:

Error case 1: including tool.uv.dependency-groups in pyproject.toml while uv.toml exists

We have a uv.toml file for separation of concerns. When we include tool.uv.dependency-groups in pyproject.toml as the docs say and create an empty uv.toml file, and sync:

warning: Found both a uv.toml file and a [tool.uv] section in an adjacent pyproject.toml. The [tool.uv] section will be ignored in favor of the uv.toml file.

This still compiles successfully even though the tool.uv.dependency-groups section is not there. The warning message seems to indicate it would be ignored though, so I would expect this to fail like the first pyproject.toml without [tool.uv.dependency-groups].

Error case 2: including dependency-groups in uv.toml

We have a uv.toml file for separation of concerns. We include dependency-groups in uv.toml like so (and leave pyproject.toml as the base version):

# uv.toml
[dependency-groups]
docs = {requires-python = ">=3.11"}

I would expect this to succeed like the first pyproject.toml with [tool.uv.dependency-groups]. However, it fails with the same error message I mentioned first.

Conclusion

  1. The warning raised when including tool.uv.dependency-groups in pyproject.toml while uv.toml exists does not actually seem to be correct.
  2. The error raised when including dependency-groups in uv.toml is not expected.

Platform

Darwin 24.5.0 arm64

Version

uv 0.7.15 (4ed9c57 2025-06-25)

Python version

Python 3.12.10

Metadata

Metadata

Assignees

Labels

questionAsking for clarification or support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions