Skip to content

Commit dc6ff94

Browse files
committed
feat(cli): add --config-settings to build command
1 parent 213a5f4 commit dc6ff94

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/poetry/console/commands/build.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BuildCommand(EnvCommand):
3636
option(
3737
"local-version",
3838
"l",
39-
"Add or replace a local version label to the build.",
39+
"Add or replace a local version label to the build. (<warning>Deprecated</warning>)",
4040
flag=False,
4141
),
4242
option(
@@ -46,6 +46,12 @@ class BuildCommand(EnvCommand):
4646
default="dist",
4747
flag=False,
4848
),
49+
option(
50+
"config-settings",
51+
description="Provide config settings that should be passed to backend in <key>=<value> format.",
52+
flag=False,
53+
multiple=True,
54+
),
4955
]
5056

5157
loggers: ClassVar[list[str]] = [
@@ -71,8 +77,23 @@ def _config_settings(self) -> dict[str, str]:
7177
config_settings = {}
7278

7379
if local_version_label := self.option("local-version"):
80+
self.line_error(
81+
f"<warning>`<fg=yellow;options=bold>--local-version</>` is deprecated."
82+
f" Use `<fg=yellow;options=bold>--config-settings local-version={local_version_label}</>`"
83+
f" instead.</warning>"
84+
)
7485
config_settings["local-version"] = local_version_label
7586

87+
for config_setting in self.option("config-settings"):
88+
if "=" not in config_setting:
89+
raise ValueError(
90+
f"Invalid config setting format: {config_setting}. "
91+
"Config settings must be in the format 'key=value'"
92+
)
93+
94+
key, _, value = config_setting.partition("=")
95+
config_settings[key] = value
96+
7697
return config_settings
7798

7899
def _build(

0 commit comments

Comments
 (0)