@@ -36,142 +36,120 @@ and a similar table which defines ``test`` and ``coverage`` groups::
36
36
The ``[dependency-groups] `` Table
37
37
---------------------------------
38
38
39
- This PEP defines a new section ( table) in ``pyproject.toml `` files named
39
+ Dependency Groups are defined as a table in ``pyproject.toml `` named
40
40
``dependency-groups ``. The ``dependency-groups `` table contains an arbitrary
41
41
number of user-defined keys, each of which has, as its value, a list of
42
- requirements (defined below). These keys must be
43
- `valid non-normalized names <https://packaging.python.org/en/latest/specifications/name-normalization/#valid-non-normalized-names >`__,
44
- and must be
45
- `normalized <https://packaging.python.org/en/latest/specifications/name-normalization/#normalization >`__
46
- before comparisons.
42
+ requirements.
47
43
48
- Tools SHOULD prefer to present the original, non-normalized name to users by
49
- default. If duplicate names, after normalization, are encountered, tools SHOULD
50
- emit an error.
44
+ ``[dependency-groups] `` keys, sometimes also called "group names", must be
45
+ :ref: `valid non-normalized names <name-format >`. Tools which handle Dependency
46
+ Groups MUST :ref: `normalize <name-normalization >` these names before
47
+ comparisons.
51
48
52
- Requirement lists under ``dependency-groups `` may contain strings, tables
53
- ("dicts" in Python), or a mix of strings and tables.
49
+ Tools SHOULD prefer to present the original, non-normalized name to users, and
50
+ if duplicate names are detected after normalization, tools SHOULD emit an
51
+ error.
54
52
55
- Strings in requirement lists must be valid
56
- `Dependency Specifiers <https://packaging.python.org/en/latest/specifications/dependency-specifiers/ >`__,
57
- as defined in :pep: `508 `.
58
-
59
- Tables in requirement lists must be valid Dependency Object Specifiers.
60
-
61
- Dependency Object Specifiers
62
- ----------------------------
63
-
64
- Dependency Object Specifiers are tables which define zero or more dependencies.
65
-
66
- This PEP standardizes only one type of Dependency Object Specifier, a
67
- "Dependency Group Include". Other types may be added in future standards.
53
+ Requirement lists, the values in ``[dependency-groups] ``, may contain strings,
54
+ tables (``dict `` in Python), or a mix of strings and tables. Strings must be
55
+ valid :ref: `dependency specifiers <dependency-specifiers >`, and tables must be
56
+ valid Dependency Group Includes.
68
57
69
58
Dependency Group Include
70
- ''''''''''''''''''''''''
71
-
72
- A Dependency Group Include includes the dependencies of another Dependency
73
- Group in the current Dependency Group.
59
+ ------------------------
74
60
75
- An include is defined as a table with exactly one key, `` "include-group" ``,
76
- whose value is a string, the name of another Dependency Group .
61
+ A Dependency Group Include includes another Dependency Group in the current
62
+ group .
77
63
78
- For example , ``{ include-group = "test"} `` is an include which expands to the
79
- contents of the `` test `` Dependency Group.
64
+ An include is a table with exactly one key , ``" include-group" ``, whose value is
65
+ a string, the name of another Dependency Group.
80
66
81
67
Includes are defined to be exactly equivalent to the contents of the named
82
68
Dependency Group, inserted into the current group at the location of the include.
83
69
For example, if ``foo = ["a", "b"] `` is one group, and
84
70
``bar = ["c", {include-group = "foo"}, "d"] `` is another, then ``bar `` should
85
71
evaluate to ``["c", "a", "b", "d"] `` when Dependency Group Includes are expanded.
86
72
87
- Dependency Group Includes may specify the same package multiple times. Tools
88
- SHOULD NOT deduplicate or otherwise alter the list contents produced by the
73
+ Dependency Group Includes may specify the same package multiple times.
74
+ Tools SHOULD NOT deduplicate or otherwise alter the list contents produced by the
89
75
include. For example, given the following table:
90
76
91
- .. code :: toml
77
+ .. code-block :: toml
92
78
93
79
[dependency-groups]
94
80
group-a = ["foo"]
95
81
group-b = ["foo>1.0"]
96
82
group-c = ["foo<1.0"]
97
- all = ["foo", {include-group = "group-a"}, {include-group = "group-b"}, {include-group = "group-c"}]
83
+ all = [
84
+ "foo",
85
+ {include-group = "group-a"},
86
+ {include-group = "group-b"},
87
+ {include-group = "group-c"},
88
+ ]
98
89
99
90
The resolved value of ``all `` SHOULD be ``["foo", "foo", "foo>1.0", "foo<1.0"] ``.
100
91
Tools should handle such a list exactly as they would handle any other case in
101
92
which they are asked to process the same requirement multiple times with
102
93
different version constraints.
103
94
104
- Dependency Group Includes may include lists containing Dependency Group
105
- Includes, in which case those includes should be expanded as well. Dependency
106
- Group Includes MUST NOT include cycles, and tools SHOULD report an error if
107
- they detect a cycle.
95
+ Dependency Group Includes may include groups containing Dependency Group Includes,
96
+ in which case those includes should be expanded as well. Dependency Group Includes
97
+ MUST NOT include cycles, and tools SHOULD report an error if they detect a cycle.
108
98
109
99
Package Building
110
100
----------------
111
101
112
102
Build backends MUST NOT include Dependency Group data in built distributions as
113
- package metadata. This means that PKG-INFO in sdists and METADATA in wheels
114
- do not include any referencable fields containing Dependency Groups.
115
-
116
- It is valid to use Dependency Groups in the evaluation of dynamic metadata, and
117
- ``pyproject.toml `` files included in sdists will naturally still contain the
118
- ``[dependency-groups] `` table. However, the table contents are not part of a
119
- published package's interfaces.
120
-
121
- Installing Dependency Groups
122
- ----------------------------
123
-
124
- Tools which support Dependency Groups are expected to provide new options and
125
- interfaces to allow users to install from Dependency Groups.
126
-
127
- No syntax is defined for expressing the Dependency Group of a package, for two
128
- reasons:
103
+ package metadata. This means that sdist ``PKG-INFO `` and wheel ``METADATA ``
104
+ files should not include referenceable fields containing Dependency Groups.
129
105
130
- * it would not be valid to refer to the Dependency Groups of a third-party
131
- package from PyPI (because the data is defined to be unpublished)
106
+ It is, however, valid to use Dependency Groups in the evaluation of dynamic
107
+ metadata, and ``pyproject.toml `` files included in sdists will still contain
108
+ ``[dependency-groups] ``. However, the table's contents are not part of a built
109
+ package's interfaces.
132
110
133
- * there is not guaranteed to be a current package for Dependency Groups -- part
134
- of their purpose is to support non-package projects
111
+ Installing Dependency Groups & Extras
112
+ -------------------------------------
135
113
136
- For example, a possible pip interface for installing Dependency Groups
137
- would be:
114
+ There is no syntax or specification-defined interface for installing or
115
+ referring to Dependency Groups. Tools are expected to provide dedicated
116
+ interfaces for this purpose.
138
117
139
- .. code :: shell
140
-
141
- pip install --dependency-groups=test,typing
142
-
143
- Note that this is only an example. This PEP does not declare any requirements
144
- for how tools support the installation of Dependency Groups.
145
-
146
- Overlapping Install UX with Extras
147
- ''''''''''''''''''''''''''''''''''
148
-
149
- Tools MAY choose to provide the same interfaces for installing Dependency
150
- Groups as they do for installing extras.
151
-
152
- Note that this specification does not forbid having an extra whose name matches
153
- a Dependency Group.
154
-
155
- Users are advised to avoid creating Dependency Groups whose names match extras.
156
- Tools MAY treat such matching as an error.
118
+ Tools MAY choose to provide the same or similar interfaces for interacting
119
+ with Dependency Groups as they do for managing extras. Tools authors are
120
+ advised that the specification does not forbid having an extra whose name
121
+ matches a Dependency Group. Separately, users are advised to avoid creating
122
+ Dependency Groups whose names match extras, and tools MAY treat such matching
123
+ as an error.
157
124
158
125
Validation and Compatibility
159
126
----------------------------
160
127
161
128
Tools supporting Dependency Groups may want to validate data before using it.
162
- However, tools implementing such validation behavior should be careful to allow
163
- for future expansions to this spec , so that they do not unnecessarily emit
164
- errors or warnings in the presence of new syntax .
129
+ When implementing such validation, authors should be aware of the possibility
130
+ of future extensions to the specification , so that they do not unnecessarily
131
+ emit errors or warnings.
165
132
166
133
Tools SHOULD error when evaluating or processing unrecognized data in
167
134
Dependency Groups.
168
135
169
- Tools SHOULD NOT eagerly validate the list contents of **all ** Dependency
170
- Groups.
136
+ Tools SHOULD NOT eagerly validate the contents of *all * Dependency Groups
137
+ unless they have a need to do so.
138
+
139
+ This means that in the presence of the following data, most tools should allow
140
+ the ``foo `` group to be used and only error if the ``bar `` group is used:
141
+
142
+ .. code-block :: toml
143
+
144
+ [dependency-groups]
145
+ foo = ["pyparsing"]
146
+ bar = [{set-phasers-to = "stun"}]
147
+
148
+ .. note ::
171
149
172
- This means that in the presence of the following data, most tools will allow
173
- the `` foo `` group to be used, and will only error when the `` bar `` group is
174
- used:
150
+ There are several known cases of tools which have good cause to be
151
+ stricter. Linters and validators are an example, as their purpose is to
152
+ validate the contents of all Dependency Groups.
175
153
176
154
Reference Implementation
177
155
========================
0 commit comments