Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build config settings to core #715

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions src/poetry/core/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/poetry/core/json/schemas/poetry-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions src/poetry/core/packages/directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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__(
Expand All @@ -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)
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/poetry/core/packages/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -132,6 +135,8 @@ def __init__(

self.develop = develop

self.config_settings = config_settings

self._yanked = yanked

@property
Expand Down
8 changes: 8 additions & 0 deletions src/poetry/core/packages/vcs_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

if TYPE_CHECKING:
from collections.abc import Iterable
from typing import Mapping
from typing import Sequence


class VCSDependency(Dependency):
Expand All @@ -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!
Expand All @@ -38,6 +41,7 @@ def __init__(
self._rev = rev
self._directory = directory
self._develop = develop
self._config_settings = config_settings

super().__init__(
name,
Expand Down Expand Up @@ -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 ""
Expand Down