@@ -5,10 +5,12 @@ standard [PEP 621 format](https://packaging.python.org/en/latest/specifications/
5
5
dependencies in ` pyproject.toml ` , not all of them do. Even those that do often provide additional ways to define
6
6
dependencies that are not standardized.
7
7
8
- _ deptry_ can extract dependencies from most of the package managers that support PEP
9
- 621 (e.g. [ uv] ( https://docs.astral.sh/uv/ ) , [ PDM] ( https://pdm-project.org/en/latest/ ) ), including tool-specific
10
- extensions, but also from package managers that do not (or used to not) support PEP
11
- 621 (e.g. [ Poetry] ( https://python-poetry.org/ ) , [ pip] ( https://pip.pypa.io/en/stable/reference/requirements-file-format/ ) ).
8
+ _ deptry_ can extract dependencies for any dependency manager that supports standard PEP 621, while also extracting them
9
+ from locations that are specific to some dependency managers that support this standard, but provide additional ways of
10
+ defining dependencies (e.g., [ uv] ( https://docs.astral.sh/uv/ ) , [ Poetry] ( https://python-poetry.org/ ) ).
11
+
12
+ _ deptry_ can also extract dependencies from dependency managers that do not support PEP 621 at
13
+ all (e.g., [ pip] ( https://pip.pypa.io/en/stable/reference/requirements-file-format/ ) ).
12
14
13
15
## PEP 621
14
16
@@ -22,7 +24,7 @@ By default, _deptry_ extracts, from `pyproject.toml`:
22
24
- groups under ` [project.optional-dependencies] ` section
23
25
- development dependencies from groups under ` [dependency-groups] ` section
24
26
25
- For instance, with this ` pyproject.toml ` :
27
+ For instance, given this ` pyproject.toml ` :
26
28
27
29
``` toml title="pyproject.toml"
28
30
[project ]
@@ -57,7 +59,8 @@ the following dependencies will be extracted:
57
59
58
60
### uv
59
61
60
- Additionally to PEP 621 dependencies, _ deptry_ will
62
+ If a ` [tool.uv.dev-dependencies] ` section is found, _ deptry_ will assume that uv is used as a dependency manager, and
63
+ will, additionally to PEP 621 dependencies,
61
64
extract [ uv development dependencies] ( https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies ) from
62
65
` dev-dependencies ` entry under ` [tool.uv] ` section, for instance:
63
66
@@ -70,9 +73,84 @@ dev-dependencies = [
70
73
]
71
74
```
72
75
76
+ ### Poetry
77
+
78
+ Until [ version 2.0] ( https://python-poetry.org/blog/announcing-poetry-2.0.0/ ) , Poetry did not support PEP 621 syntax to
79
+ define project dependencies, instead relying on a specific syntax.
80
+
81
+ Because Poetry now supports PEP 621, it is now treated as an extension of PEP 621 manager, allowing _ deptry_ to retrieve
82
+ dependencies defined under ` [project.dependencies] ` and ` [project.optional-dependencies] ` , while still allowing
83
+ retrieving:
84
+
85
+ - regular dependencies from ` [tool.poetry.dependencies] ` (which is still supported in Poetry 2.0)
86
+ - development dependencies from ` [tool.poetry.group.<group>.dependencies] ` and ` [tool.poetry.dev-dependencies] `
87
+
88
+ #### Regular dependencies
89
+
90
+ Which regular dependencies are extracted depend on how you define your dependencies with Poetry, as _ deptry_ will
91
+ closely
92
+ match [ Poetry's behavior] ( https://python-poetry.org/docs/dependency-specification/#projectdependencies-and-toolpoetrydependencies ) .
93
+
94
+ If ` [project.dependencies] ` is not set, or is empty, regular dependencies will be extracted from
95
+ ` [tool.poetry.dependencies] ` . For instance, in this case:
96
+
97
+ ``` toml title="pyproject.toml"
98
+ [project ]
99
+ name = " foo"
100
+
101
+ [tool .poetry .dependencies ]
102
+ httpx = " 0.28.1"
103
+ ```
104
+
105
+ ` httpx ` will be extracted as a regular dependency.
106
+
107
+ If ` [project.dependencies] ` contains at least one dependency, then dependencies will ** NOT** be extracted from
108
+ ` [tool.poetry.dependencies] ` , as in that case, Poetry will only consider that data in this section enriches dependencies
109
+ already defined in ` [project.dependencies] ` (for instance, to set a specific source), and not defining new dependencies.
110
+
111
+ For instance, in this case:
112
+
113
+ ``` toml title="pyproject.toml"
114
+ [project ]
115
+ name = " foo"
116
+ dependencies = [" httpx" ]
117
+
118
+ [tool .poetry .dependencies ]
119
+ httpx = { git = " https://github.com/encode/httpx" , tag = " 0.28.1" }
120
+ urllib3 = " 2.3.0"
121
+ ```
122
+
123
+ although ` [tool.poetry.dependencies] ` contains both ` httpx ` and ` urllib3 ` , only ` httpx ` will be extracted as a regular
124
+ dependency, as ` [project.dependencies] ` contains at least one dependency, so Poetry itself will not consider ` urllib3 `
125
+ to be a dependency of the project.
126
+
127
+ #### Development dependencies
128
+
129
+ In Poetry, [ development dependencies] ( https://python-poetry.org/docs/managing-dependencies/#dependency-groups ) can be
130
+ defined under either (or both):
131
+
132
+ - ` [tool.poetry.group.<group>.dependencies] ` sections
133
+ - ` [tool.poetry.dev-dependencies] ` section (which is considered legacy)
134
+
135
+ _ deptry_ will extract dependencies from all those sections, for instance:
136
+
137
+ ``` toml title="pyproject.toml"
138
+ [tool .poetry .dev-dependencies ]
139
+ mypy = " 1.14.1"
140
+ ruff = " 0.8.6"
141
+
142
+ [tool .poetry .group .docs .dependencies ]
143
+ mkdocs = " 1.6.1"
144
+
145
+ [tool .poetry .group .test .dependencies ]
146
+ pytest = " 8.3.3"
147
+ pytest-cov = " 5.0.0"
148
+ ```
149
+
73
150
### PDM
74
151
75
- Additionally to PEP 621 dependencies, _ deptry_ will
152
+ If a ` [tool.pdm.dev-dependencies] ` section is found, _ deptry_ will assume that PDM is used as a dependency manager, and
153
+ will, additionally to PEP 621 dependencies,
76
154
extract [ PDM development dependencies] ( https://pdm-project.org/en/latest/usage/dependency/#add-development-only-dependencies )
77
155
from ` [tool.pdm.dev-dependencies] ` section, for instance:
78
156
@@ -115,43 +193,6 @@ In this example, regular dependencies will be extracted from both `requirements.
115
193
using [`--pep621-dev-dependency-groups`](usage.md#pep-621-dev-dependency-groups) argument (or its
116
194
`pep_621_dev_dependency_groups` equivalent in `pyproject.toml`).
117
195
118
- ## Poetry
119
-
120
- _ deptry_ supports
121
- extracting [ dependencies defined using Poetry] ( https://python-poetry.org/docs/pyproject/#dependencies-and-dependency-groups ) ,
122
- and uses the presence of a ` [tool.poetry.dependencies] ` section in ` pyproject.toml ` to determine that the project uses
123
- Poetry.
124
-
125
- In a ` pyproject.toml ` file where Poetry is used, _ deptry_ will extract:
126
-
127
- - regular dependencies from entries under ` [tool.poetry.dependencies] ` section
128
- - development dependencies from entries under each ` [tool.poetry.group.<group>.dependencies] ` section (or the
129
- legacy ` [tool.poetry.dev-dependencies] ` section)
130
-
131
- For instance, given the following ` pyproject.toml ` file:
132
-
133
- ``` toml title="pyproject.toml"
134
- [tool .poetry .dependencies ]
135
- python = " ^3.10"
136
- orjson = " ^3.0.0"
137
- click = { version = " ^8.0.0" , optional = true }
138
-
139
- [tool .poetry .extras ]
140
- cli = [" click" ]
141
-
142
- [tool .poetry .group .docs .dependencies ]
143
- mkdocs = " 1.6.1"
144
-
145
- [tool .poetry .group .test .dependencies ]
146
- pytest = " 8.3.3"
147
- pytest-cov = " 5.0.0"
148
- ```
149
-
150
- the following dependencies will be extracted:
151
-
152
- - regular dependencies: ` orjson ` , ` click `
153
- - development dependencies: ` mkdocs ` , ` pytest ` , ` pytest-cov `
154
-
155
196
## ` requirements.txt ` (pip, pip-tools)
156
197
157
198
_ deptry_ supports extracting [ dependencies using
0 commit comments