@@ -27,14 +27,30 @@ are part of an implicit `main` group. Those dependencies are required by your pr
27
27
Beside the ` main ` dependencies, you might have dependencies that are only needed to test your project
28
28
or to build the documentation.
29
29
30
- To declare a new dependency group, use a ` tool.poetry.group.<group> ` section
31
- where ` <group> ` is the name of your dependency group (for instance, ` test ` ):
30
+ To declare a new dependency group, use a ` dependency-groups ` section according to PEP 735 or
31
+ a ` tool.poetry.group.<group> ` section where ` <group> ` is the name of your dependency group (for instance, ` test ` ):
32
32
33
+ {{< tabs tabTotal="2" tabID1="group-pep735" tabID2="group-poetry" tabName1="[ dependency-groups] " tabName2="[ tool.poetry] ">}}
34
+
35
+ {{< tab tabID="group-pep735" >}}
36
+ ``` toml
37
+ [dependency-groups ]
38
+ test = [
39
+ " pytest (>=6.0.0,<7.0.0)" ,
40
+ " pytest-mock" ,
41
+ ]
42
+ ```
43
+ {{< /tab >}}
44
+
45
+ {{< tab tabID="group-poetry" >}}
33
46
``` toml
34
47
[tool .poetry .group .test .dependencies ]
35
48
pytest = " ^6.0.0"
36
49
pytest-mock = " *"
37
50
```
51
+ {{< /tab >}}
52
+ {{< /tabs >}}
53
+
38
54
39
55
{{% note %}}
40
56
All dependencies ** must be compatible with each other** across groups since they will
@@ -60,13 +76,32 @@ A dependency group can be declared as optional. This makes sense when you have
60
76
a group of dependencies that are only required in a particular environment or for
61
77
a specific purpose.
62
78
79
+ {{< tabs tabTotal="2" tabID1="group-optional-pep735" tabID2="group-optional-poetry" tabName1="[ dependency-groups] " tabName2="[ tool.poetry] ">}}
80
+
81
+ {{< tab tabID="group-optional-pep735" >}}
82
+ ``` toml
83
+ [dependency-groups ]
84
+ docs = [
85
+ " mkdocs" ,
86
+ ]
87
+
88
+ [tool .poetry .group .docs ]
89
+ optional = true
90
+ ```
91
+ {{< /tab >}}
92
+
93
+ {{< tab tabID="group-optional-poetry" >}}
63
94
``` toml
64
95
[tool .poetry .group .docs ]
65
96
optional = true
66
97
67
98
[tool .poetry .group .docs .dependencies ]
68
99
mkdocs = " *"
69
100
```
101
+ {{< /tab >}}
102
+ {{< /tabs >}}
103
+
104
+
70
105
71
106
Optional groups can be installed in addition to the ** default** dependencies by using the ` --with `
72
107
option of the [ ` install ` ] ({{< relref "cli#install" >}}) command.
0 commit comments