Skip to content

Commit 8adda39

Browse files
committed
Add Requirement Construction
1 parent 4343318 commit 8adda39

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

cppython/core/resolution.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55
from typing import Any, cast
66

7+
from packaging.requirements import InvalidRequirement, Requirement
78
from pydantic import BaseModel, DirectoryPath, ValidationError
89

910
from cppython.core.exception import ConfigException
@@ -149,6 +150,15 @@ def resolve_cppython(
149150

150151
modified_scm_name = plugin_build_data.scm_name
151152

153+
# Construct dependencies from the local configuration only
154+
dependencies: list[Requirement] = []
155+
if local_configuration.dependencies:
156+
for dependency in local_configuration.dependencies:
157+
try:
158+
dependencies.append(Requirement(dependency))
159+
except InvalidRequirement as error:
160+
raise ConfigException(f"Invalid requirement '{dependency}' in dependencies: {error}", []) from error
161+
152162
cppython_data = CPPythonData(
153163
configuration_path=modified_configuration_path,
154164
install_path=modified_install_path,
@@ -158,7 +168,7 @@ def resolve_cppython(
158168
provider_name=modified_provider_name,
159169
generator_name=modified_generator_name,
160170
scm_name=modified_scm_name,
161-
dependencies=[],
171+
dependencies=dependencies,
162172
)
163173
return cppython_data
164174

@@ -185,7 +195,7 @@ def resolve_cppython_plugin(cppython_data: CPPythonData, plugin_type: type[Plugi
185195
provider_name=cppython_data.provider_name,
186196
generator_name=cppython_data.generator_name,
187197
scm_name=cppython_data.scm_name,
188-
dependencies=[],
198+
dependencies=cppython_data.dependencies,
189199
)
190200

191201
return cast(CPPythonPluginData, plugin_data)

cppython/core/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import Annotated, Any, NewType, Protocol, runtime_checkable
66

7-
from packaging.version import Version
7+
from packaging.requirements import Requirement
88
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
99
from pydantic.types import DirectoryPath
1010

@@ -116,7 +116,7 @@ class CPPythonData(CPPythonModel, extra='forbid'):
116116
provider_name: TypeName
117117
generator_name: TypeName
118118
scm_name: TypeName
119-
dependencies: list[Version]
119+
dependencies: list[Requirement]
120120

121121
@field_validator('configuration_path', 'install_path', 'tool_path', 'build_path')
122122
@classmethod

0 commit comments

Comments
 (0)