You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/config/environment/advanced.md
+65
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,71 @@ you could then run your tests consecutively in all 4 environments with:
127
127
hatch run test:cov
128
128
```
129
129
130
+
## Dependency Groups
131
+
132
+
Environments can use [PEP 735](https://peps.python.org/pep-0735/) dependency groups with the `dependency-groups` option:
133
+
134
+
```toml config-example
135
+
[dependency-groups]
136
+
test = [
137
+
"pytest>=7.0.0",
138
+
"pytest-cov>=4.1.0",
139
+
]
140
+
lint = [
141
+
"black",
142
+
"ruff",
143
+
"mypy",
144
+
]
145
+
# Groups can include other groups
146
+
dev = [
147
+
{"include-group": "test"},
148
+
{"include-group": "lint"},
149
+
"pre-commit",
150
+
]
151
+
152
+
[tool.hatch.envs.test]
153
+
dependency-groups = ["test"]
154
+
155
+
[tool.hatch.envs.lint]
156
+
dependency-groups = ["lint"]
157
+
158
+
[tool.hatch.envs.dev]
159
+
dependency-groups = ["dev"]
160
+
```
161
+
162
+
The `dependency-groups` option specifies which PEP 735 dependency groups to include in the environment's dependencies. This is particularly useful for organizing related dependencies and including them in appropriate environments.
163
+
164
+
### Combining with Other Dependencies
165
+
166
+
Dependency groups can be combined with other dependency mechanisms:
167
+
168
+
```toml config-example
169
+
[project]
170
+
name = "my-app"
171
+
version = "0.1.0"
172
+
dependencies = [
173
+
"requests>=2.28.0",
174
+
]
175
+
176
+
[dependency-groups]
177
+
test = ["pytest>=7.0.0"]
178
+
docs = ["sphinx>=7.0.0"]
179
+
180
+
[tool.hatch.envs.test]
181
+
# Include the test dependency group
182
+
dependency-groups = ["test"]
183
+
# Add environment-specific dependencies
184
+
dependencies = [
185
+
"coverage[toml]>=7.0.0",
186
+
]
187
+
# Project dependencies will be included if not skip-install and in dev-mode
188
+
```
189
+
190
+
In this example, the test environment would include:
You can modify options based on the conditions of different sources like [matrix variables](#matrix-variable-overrides) with the `overrides` table, using [dotted key](https://toml.io/en/v1.0.0#table) syntax for each declaration:
Copy file name to clipboardExpand all lines: docs/config/environment/overview.md
+22
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,28 @@ features = [
103
103
!!! note
104
104
Features/optional dependencies are also known as `extras` in other tools.
105
105
106
+
### Dependency Groups
107
+
108
+
You can include [PEP 735](https://peps.python.org/pep-0735/) dependency groups in your environments using the `dependency-groups` option:
109
+
110
+
```toml config-example
111
+
[dependency-groups]
112
+
test = [
113
+
"pytest>=7.0.0",
114
+
"pytest-cov>=4.1.0",
115
+
]
116
+
117
+
[tool.hatch.envs.test]
118
+
dependency-groups = [
119
+
"test",
120
+
]
121
+
```
122
+
123
+
Dependency groups provide a standardized way to organize related dependencies and can be shared across different build systems. See [advanced usage](advanced.md#dependency-groups) for more details on dependency group features like including other groups.
124
+
125
+
!!! note
126
+
Unlike features which affect how the project itself is installed, dependency groups are separate dependencies that are installed alongside the project.
127
+
106
128
### Dev mode
107
129
108
130
By default, environments will always reflect the current state of your project on disk, for example, by installing it in editable mode in a Python environment. Set `dev-mode` to `false` to disable this behavior and have your project installed only upon creation of a new environment. From then on, you need to manage your project installation manually.
0 commit comments