Skip to content

Commit fd37b80

Browse files
committed
chore(deps): switch to dependency groups
The `[project.optional-dependencies]` header is used for _public_ dependency groups, but it was also a convenient way to keep track of dev dependencies. These were prefixed with `devel-` to make clear their purpose. Dependency groups are a recent addition which allows for dev dependencies to be specified without making it public in the same way that the optional dependencies were. Signed-off-by: JP-Ellis <[email protected]>
1 parent 6665663 commit fd37b80

File tree

3 files changed

+99
-106
lines changed

3 files changed

+99
-106
lines changed

pact-python-cli/pyproject.toml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@ requires-python = ">=3.9"
4848
pact-stub-service = "pact_cli:_exec"
4949
pactflow = "pact_cli:_exec"
5050

51-
[project.optional-dependencies]
52-
# Linting and formatting tools use a more narrow specification to ensure
53-
# developper consistency. All other dependencies are as above.
54-
devel = [
55-
"pact-python-cli[devel-test]",
56-
"pact-python-cli[devel-types]",
57-
"ruff==0.12.8",
58-
]
59-
devel-test = ["pytest-cov~=6.0", "pytest~=8.0"]
60-
devel-types = ["mypy==1.17.1"]
51+
[dependency-groups]
52+
# Linting and formatting tools use a more narrow specification to ensure
53+
# developper consistency. All other dependencies are as above.
54+
dev = ["ruff==0.12.8", { include-group = "test" }, { include-group = "types" }]
55+
test = ["pytest-cov~=6.0", "pytest~=8.0"]
56+
types = ["mypy==1.17.1"]
6157

6258
################################################################################
6359
## Build System
@@ -111,8 +107,8 @@ requires = ["hatch-vcs", "hatchling", "packaging"]
111107
"requests",
112108
"setuptools ; python_version >= '3.12'",
113109
]
114-
features = ["devel"]
115110
installer = "uv"
111+
pre-install-commands = ["uv pip install --group dev -e ."]
116112

117113
[tool.hatch.envs.default.scripts]
118114
all = ["format", "lint", "test", "typecheck"]
@@ -126,8 +122,8 @@ requires = ["hatch-vcs", "hatchling", "packaging"]
126122
# Test environment for running unit tests. This automatically tests against all
127123
# supported Python versions.
128124
[tool.hatch.envs.test]
129-
features = ["devel-test"]
130-
installer = "uv"
125+
installer = "uv"
126+
pre-install-commands = ["uv pip install --group test -e ."]
131127

132128
[[tool.hatch.envs.test.matrix]]
133129
python = ["3.10", "3.11", "3.12", "3.13", "3.9"]

pact-python-ffi/pyproject.toml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ dependencies = ["cffi~=1.0"]
4141
"Homepage" = "https://pact.io"
4242
"Repository" = "https://github.com/pact-foundation/pact-python"
4343

44-
[project.optional-dependencies]
45-
# Linting and formatting tools use a more narrow specification to ensure
46-
# developper consistency. All other dependencies are as above.
47-
devel = [
48-
"pact-python-ffi[devel-test]",
49-
"pact-python-ffi[devel-types]",
50-
"ruff==0.12.8",
51-
]
52-
devel-test = ["pytest-cov~=6.0", "pytest~=8.0"]
53-
devel-types = ["mypy==1.17.1", "typing-extensions~=4.0"]
44+
[dependency-groups]
45+
dev = ["ruff==0.12.8", { include-group = "test" }, { include-group = "types" }]
46+
test = ["pytest-cov~=6.0", "pytest~=8.0"]
47+
types = ["mypy==1.17.1", "typing-extensions~=4.0"]
5448

5549
################################################################################
5650
## Build System
@@ -98,9 +92,9 @@ requires = ["hatch-vcs", "hatchling", "packaging", "cffi"]
9892
# Install dev dependencies in the default environment to simplify the developer
9993
# workflow.
10094
[tool.hatch.envs.default]
101-
extra-dependencies = ["hatch-vcs", "hatchling", "packaging", "cffi"]
102-
features = ["devel"]
103-
installer = "uv"
95+
extra-dependencies = ["hatch-vcs", "hatchling", "packaging", "cffi"]
96+
installer = "uv"
97+
pre-install-commands = ["uv pip install --group dev -e ."]
10498

10599
# Update paths to ensure the shared library can be found
106100
# TODO: See if this can be overridden on a per-platform basis
@@ -120,8 +114,8 @@ requires = ["hatch-vcs", "hatchling", "packaging", "cffi"]
120114
# Test environment for running unit tests. This automatically tests against all
121115
# supported Python versions.
122116
[tool.hatch.envs.test]
123-
features = ["devel-test"]
124-
installer = "uv"
117+
installer = "uv"
118+
pre-install-commands = ["uv pip install --group test -e ."]
125119

126120
# Update paths to ensure the shared library can be found
127121
# TODO: See if this can be overridden on a per-platform basis

pyproject.toml

Lines changed: 81 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -70,75 +70,76 @@ dependencies = [
7070
"six~=1.0",
7171
]
7272

73-
# Linting and formatting tools use a more narrow specification to ensure
74-
# developper consistency. All other dependencies are as above.
75-
devel = [
76-
"pact-python-cli[devel]",
77-
"pact-python-ffi[devel]",
78-
"pact-python[devel-docs]",
79-
"pact-python[devel-example]",
80-
"pact-python[devel-test]",
81-
"pact-python[devel-types]",
82-
"ruff==0.12.8",
83-
]
84-
devel-docs = [
85-
"mkdocs-github-admonitions-plugin~=0.0",
86-
"mkdocs-literate-nav~=0.6",
87-
"mkdocs-material[imaging]~=9.4",
88-
"mkdocs-section-index~=0.3",
89-
"mkdocs_gen_files~=0.5",
90-
"mkdocstrings[python]~=0.23",
91-
"mkdocs~=1.5",
92-
"pathspec~=0.0",
93-
]
94-
devel-example = [
95-
"fastapi~=0.0",
96-
"flask[async]~=3.0",
97-
"grpcio~=1.0",
98-
"pact-python[devel-test]",
99-
"protobuf~=6.0",
100-
"pydantic~=2.0",
101-
"pytest-cov~=6.0",
102-
"pytest~=8.0",
103-
"testcontainers~=4.0",
104-
"uvicorn[standard]~=0.0",
105-
]
106-
devel-test = [
107-
"aiohttp~=3.0",
108-
"flask~=3.0",
109-
"pact-python-cli",
110-
"pytest-asyncio~=1.0",
111-
"pytest-bdd~=8.0",
112-
"pytest-cov~=6.0",
113-
"pytest~=8.0",
114-
"requests~=2.0",
115-
"testcontainers~=4.0",
116-
]
117-
devel-types = [
118-
"mypy==1.17.1",
119-
"types-cffi~=1.0",
120-
"types-grpcio~=1.0",
121-
"types-protobuf~=6.0",
122-
"types-requests~=2.0",
123-
]
73+
[dependency-groups]
74+
# Linting and formatting tools use a more narrow specification to ensure
75+
# developper consistency. All other dependencies are as above.
76+
dev = [
77+
"ruff==0.12.8",
78+
{ include-group = "docs" },
79+
{ include-group = "example" },
80+
{ include-group = "test" },
81+
{ include-group = "types" },
82+
{ include-group = "example-v2" },
83+
{ include-group = "test-v2" },
84+
]
12485

125-
# Dependencies for v2 example and test environments
126-
devel-example-v2 = [
127-
"fastapi~=0.0",
128-
"flask[async]~=3.0",
129-
"pytest-cov~=6.0",
130-
"pytest~=8.0",
131-
"testcontainers~=4.0",
132-
"uvicorn[standard]~=0.0",
133-
]
134-
devel-test-v2 = [
135-
"fastapi~=0.0",
136-
"httpx~=0.0",
137-
"mock~=5.0",
138-
"pytest-cov~=6.0",
139-
"pytest~=8.0",
140-
"uvicorn[standard]~=0.0",
141-
]
86+
docs = [
87+
"mkdocs-github-admonitions-plugin~=0.0",
88+
"mkdocs-literate-nav~=0.6",
89+
"mkdocs-material[recommended,git,imaging]~=9.0",
90+
"mkdocs-section-index~=0.3",
91+
"mkdocs_gen_files~=0.5",
92+
"mkdocstrings[python]~=0.23",
93+
"mkdocs~=1.5",
94+
"pathspec~=0.0",
95+
]
96+
example = [
97+
"fastapi~=0.0",
98+
"flask[async]~=3.0",
99+
"grpcio~=1.0",
100+
"protobuf~=6.0",
101+
"pydantic~=2.0",
102+
"pytest-cov~=6.0",
103+
"pytest~=8.0",
104+
"testcontainers~=4.0",
105+
"uvicorn[standard]~=0.0",
106+
]
107+
test = [
108+
"aiohttp~=3.0",
109+
"flask~=3.0",
110+
"pact-python-cli",
111+
"pytest-asyncio~=1.0",
112+
"pytest-bdd~=8.0",
113+
"pytest-cov~=6.0",
114+
"pytest~=8.0",
115+
"requests~=2.0",
116+
"testcontainers~=4.0",
117+
]
118+
types = [
119+
"mypy==1.17.1",
120+
"types-cffi~=1.0",
121+
"types-grpcio~=1.0",
122+
"types-protobuf~=6.0",
123+
"types-requests~=2.0",
124+
]
125+
126+
# Dependencies for v2 example and test environments
127+
example-v2 = [
128+
"fastapi~=0.0",
129+
"flask[async]~=3.0",
130+
"pytest-cov~=6.0",
131+
"pytest~=8.0",
132+
"testcontainers~=4.0",
133+
"uvicorn[standard]~=0.0",
134+
]
135+
test-v2 = [
136+
"fastapi~=0.0",
137+
"httpx~=0.0",
138+
"mock~=5.0",
139+
"pytest-cov~=6.0",
140+
"pytest~=8.0",
141+
"uvicorn[standard]~=0.0",
142+
]
142143

143144
[build-system]
144145
build-backend = "hatchling.build"
@@ -184,11 +185,15 @@ requires = ["hatch-vcs", "hatchling"]
184185
# workflow.
185186
[tool.hatch.envs.default]
186187
extra-dependencies = ["hatchling", "hatch-vcs"]
187-
features = ["devel"]
188188
installer = "uv"
189189
# This is require to get around an incompatibility between hatch and uv
190190
# See: https://github.com/pypa/hatch/issues/1639
191-
pre-install-commands = ["uv pip install -e .[devel]"]
191+
# See: https://github.com/pypa/hatch/issues/1852
192+
pre-install-commands = [
193+
"uv pip install --group dev -e .",
194+
"uv pip install --group dev -e ./pact-python-ffi",
195+
"uv pip install --group dev -e ./pact-python-cli",
196+
] #
192197

193198
# Update paths to ensure the shared library can be found
194199
# TODO: See if this can be overridden on a per-platform basis
@@ -211,19 +216,17 @@ requires = ["hatch-vcs", "hatchling"]
211216

212217
# Test environment for running unit tests.
213218
[tool.hatch.envs.test]
214-
features = ["devel-test"]
215219
installer = "uv"
216-
pre-install-commands = ["uv pip install -e ."]
220+
pre-install-commands = ["uv pip install --group test -e ."]
217221

218222
[[tool.hatch.envs.test.matrix]]
219223
python = ["3.10", "3.11", "3.12", "3.13", "3.9"]
220224

221225
# Test environment for running unit tests. This automatically tests against all
222226
# supported Python versions.
223227
[tool.hatch.envs.example]
224-
features = ["devel-example"]
225228
installer = "uv"
226-
pre-install-commands = ["uv pip install -e ."]
229+
pre-install-commands = ["uv pip install --group example -e ."]
227230

228231
[tool.hatch.envs.example.scripts]
229232
all = ["example"]
@@ -232,9 +235,9 @@ requires = ["hatch-vcs", "hatchling"]
232235
python = ["3.10", "3.11", "3.12", "3.13", "3.9"]
233236

234237
[tool.hatch.envs.v2-test]
235-
features = ["v2", "devel-test-v2"]
238+
features = ["v2"]
236239
installer = "uv"
237-
pre-install-commands = ["uv pip install -e ."]
240+
pre-install-commands = ["uv pip install --group test-v2 -e ."]
238241

239242
[tool.hatch.envs.v2-test.scripts]
240243
all = ["test"]
@@ -244,9 +247,9 @@ requires = ["hatch-vcs", "hatchling"]
244247
python = ["3.10", "3.11", "3.12", "3.13", "3.9"]
245248

246249
[tool.hatch.envs.v2-example]
247-
features = ["v2", "devel-example-v2"]
250+
features = ["v2"]
248251
installer = "uv"
249-
pre-install-commands = ["uv pip install -e ."]
252+
pre-install-commands = ["uv pip install --group example-v2 -e ."]
250253

251254
[tool.hatch.envs.v2-example.scripts]
252255
all = ["example"]

0 commit comments

Comments
 (0)