Skip to content

Commit c6940c9

Browse files
committed
Dependency Groups Schema
Doesn't implement installation sets
1 parent 0aca2f9 commit c6940c9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

cppython/core/resolution.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ def resolve_cppython(
166166
except InvalidRequirement as error:
167167
invalid_requirements.append(f"Invalid requirement '{dependency}': {error}")
168168

169+
# Construct dependency groups from the local configuration
170+
dependency_groups: dict[str, list[Requirement]] = {}
171+
if local_configuration.dependency_groups:
172+
for group_name, group_dependencies in local_configuration.dependency_groups.items():
173+
resolved_group: list[Requirement] = []
174+
for dependency in group_dependencies:
175+
try:
176+
resolved_group.append(Requirement(dependency))
177+
except InvalidRequirement as error:
178+
invalid_requirements.append(f"Invalid requirement '{dependency}' in group '{group_name}': {error}")
179+
dependency_groups[group_name] = resolved_group
180+
169181
if invalid_requirements:
170182
raise ConfigException('\n'.join(invalid_requirements), [])
171183

@@ -179,6 +191,7 @@ def resolve_cppython(
179191
generator_name=modified_generator_name,
180192
scm_name=modified_scm_name,
181193
dependencies=dependencies,
194+
dependency_groups=dependency_groups,
182195
provider_data=provider_data,
183196
generator_data=generator_data,
184197
)
@@ -208,6 +221,7 @@ def resolve_cppython_plugin(cppython_data: CPPythonData, plugin_type: type[Plugi
208221
generator_name=cppython_data.generator_name,
209222
scm_name=cppython_data.scm_name,
210223
dependencies=cppython_data.dependencies,
224+
dependency_groups=cppython_data.dependency_groups,
211225
provider_data=cppython_data.provider_data,
212226
generator_data=cppython_data.generator_data,
213227
)

cppython/core/schema.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class CPPythonData(CPPythonModel, extra='forbid'):
117117
generator_name: TypeName
118118
scm_name: TypeName
119119
dependencies: list[Requirement]
120+
dependency_groups: dict[str, list[Requirement]]
120121

121122
provider_data: Annotated[dict[str, Any], Field(description='Resolved provider configuration data')]
122123
generator_data: Annotated[dict[str, Any], Field(description='Resolved generator configuration data')]
@@ -329,6 +330,15 @@ class CPPythonLocalConfiguration(CPPythonModel, extra='forbid'):
329330
),
330331
] = None
331332

333+
dependency_groups: Annotated[
334+
dict[str, list[str]] | None,
335+
Field(
336+
alias='dependency-groups',
337+
description='Named groups of dependencies. Key is the group name, value is a list of pip compatible'
338+
' requirements strings. Similar to PEP 735 dependency groups.',
339+
),
340+
] = None
341+
332342

333343
class ToolData(CPPythonModel):
334344
"""Tool entry of pyproject.toml"""

0 commit comments

Comments
 (0)