diff --git a/src/poetry/core/factory.py b/src/poetry/core/factory.py index a0c84a85b..f76576634 100644 --- a/src/poetry/core/factory.py +++ b/src/poetry/core/factory.py @@ -280,6 +280,7 @@ def create_dependency( groups=groups, optional=optional, develop=constraint.get("develop", False), + config_settings=constraint.get("config-settings", {}), extras=constraint.get("extras", []), ) elif "file" in constraint: @@ -322,6 +323,7 @@ def create_dependency( optional=optional, base=root_dir, develop=constraint.get("develop", False), + config_settings=constraint.get("config-settings", {}), extras=constraint.get("extras", []), ) elif "url" in constraint: diff --git a/src/poetry/core/json/schemas/poetry-schema.json b/src/poetry/core/json/schemas/poetry-schema.json index b534e3b68..ee2ae1a48 100644 --- a/src/poetry/core/json/schemas/poetry-schema.json +++ b/src/poetry/core/json/schemas/poetry-schema.json @@ -439,6 +439,10 @@ "develop": { "type": "boolean", "description": "Whether to install the dependency in development mode." + }, + "config-settings": { + "type": "object", + "description": "Config-settings passed to the builder when installing." } } }, diff --git a/src/poetry/core/packages/directory_dependency.py b/src/poetry/core/packages/directory_dependency.py index ffa45c2c8..ff74adb68 100644 --- a/src/poetry/core/packages/directory_dependency.py +++ b/src/poetry/core/packages/directory_dependency.py @@ -12,6 +12,8 @@ if TYPE_CHECKING: from collections.abc import Iterable from pathlib import Path + from typing import Mapping + from typing import Sequence class DirectoryDependency(PathDependency): @@ -23,6 +25,7 @@ def __init__( optional: bool = False, base: Path | None = None, develop: bool = False, + config_settings: Mapping[str, str | Sequence[str]] | None = None, extras: Iterable[str] | None = None, ) -> None: super().__init__( @@ -37,6 +40,7 @@ def __init__( # Attributes must be immutable for clone() to be safe! # (For performance reasons, clone only creates a copy instead of a deep copy). self._develop = develop + self._config_settings = config_settings # cache this function to avoid multiple IO reads and parsing self.supports_poetry = functools.lru_cache(maxsize=1)(self._supports_poetry) @@ -45,6 +49,10 @@ def __init__( def develop(self) -> bool: return self._develop + @property + def config_settings(self) -> Mapping[str, str | Sequence[str]] | None: + return self._config_settings + def _validate(self) -> str: message = super()._validate() if message: diff --git a/src/poetry/core/packages/package.py b/src/poetry/core/packages/package.py index 3342388e6..65d645f1c 100644 --- a/src/poetry/core/packages/package.py +++ b/src/poetry/core/packages/package.py @@ -24,6 +24,8 @@ from collections.abc import Iterable from collections.abc import Iterator from pathlib import Path + from typing import Mapping + from typing import Sequence from packaging.utils import NormalizedName @@ -69,6 +71,7 @@ def __init__( source_subdirectory: str | None = None, features: Iterable[str] | None = None, develop: bool = False, + config_settings: Mapping[str, str | Sequence[str]] | None = None, yanked: str | bool = False, ) -> None: """ @@ -132,6 +135,8 @@ def __init__( self.develop = develop + self.config_settings = config_settings + self._yanked = yanked @property diff --git a/src/poetry/core/packages/vcs_dependency.py b/src/poetry/core/packages/vcs_dependency.py index 38a4e9680..409e7e391 100644 --- a/src/poetry/core/packages/vcs_dependency.py +++ b/src/poetry/core/packages/vcs_dependency.py @@ -7,6 +7,8 @@ if TYPE_CHECKING: from collections.abc import Iterable + from typing import Mapping + from typing import Sequence class VCSDependency(Dependency): @@ -27,6 +29,7 @@ def __init__( groups: Iterable[str] | None = None, optional: bool = False, develop: bool = False, + config_settings: Mapping[str, str | Sequence[str]] | None = None, extras: Iterable[str] | None = None, ) -> None: # Attributes must be immutable for clone() to be safe! @@ -38,6 +41,7 @@ def __init__( self._rev = rev self._directory = directory self._develop = develop + self._config_settings = config_settings super().__init__( name, @@ -83,6 +87,10 @@ def directory(self) -> str | None: def develop(self) -> bool: return self._develop + @property + def config_settings(self) -> Mapping[str, str | Sequence[str]] | None: + return self._config_settings + @property def reference(self) -> str: reference = self._branch or self._tag or self._rev or ""