fix: support -q for build/uv (#2737)
This commit is contained in:
@@ -36,13 +36,13 @@ class BuildFrontendConfig:
|
||||
return {"name": self.name, "args": repr(self.args)}
|
||||
|
||||
|
||||
def _get_verbosity_flags(level: int, frontend: BuildFrontendName) -> list[str]:
|
||||
def _get_verbosity_flags(level: int, frontend: BuildFrontendName, *, py38: bool) -> list[str]:
|
||||
if level < 0:
|
||||
if frontend == "pip":
|
||||
return ["-" + -level * "q"]
|
||||
|
||||
msg = f"build_verbosity {level} is not supported for {frontend} frontend. Ignoring."
|
||||
log.warning(msg)
|
||||
if frontend.startswith("build") and py38:
|
||||
msg = f"build_verbosity {level} is not supported for {frontend} frontend. Ignoring."
|
||||
log.warning(msg)
|
||||
return []
|
||||
return ["-" + -level * "q"]
|
||||
|
||||
if level > 0:
|
||||
if frontend == "pip":
|
||||
@@ -75,10 +75,10 @@ def parse_config_settings(config_settings_str: str) -> dict[str, str | list[str]
|
||||
|
||||
|
||||
def get_build_frontend_extra_flags(
|
||||
build_frontend: BuildFrontendConfig, verbosity_level: int, config_settings: str
|
||||
build_frontend: BuildFrontendConfig, verbosity_level: int, config_settings: str, *, py38: bool
|
||||
) -> list[str]:
|
||||
return [
|
||||
*_split_config_settings(config_settings),
|
||||
*build_frontend.args,
|
||||
*_get_verbosity_flags(verbosity_level, build_frontend.name),
|
||||
*_get_verbosity_flags(verbosity_level, build_frontend.name, py38=py38),
|
||||
]
|
||||
|
||||
@@ -457,6 +457,7 @@ def build_wheel(state: BuildState) -> Path:
|
||||
state.options.build_frontend,
|
||||
state.options.build_verbosity,
|
||||
state.options.config_settings,
|
||||
py38=False,
|
||||
),
|
||||
env=state.android_env,
|
||||
)
|
||||
@@ -474,6 +475,7 @@ def build_wheel(state: BuildState) -> Path:
|
||||
state.options.build_frontend,
|
||||
state.options.build_verbosity,
|
||||
state.options.config_settings,
|
||||
py38=False,
|
||||
),
|
||||
env=state.android_env,
|
||||
)
|
||||
|
||||
@@ -487,7 +487,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
built_wheel_dir.mkdir()
|
||||
|
||||
extra_flags = get_build_frontend_extra_flags(
|
||||
build_frontend, build_options.build_verbosity, build_options.config_settings
|
||||
build_frontend,
|
||||
build_options.build_verbosity,
|
||||
build_options.config_settings,
|
||||
py38=False,
|
||||
)
|
||||
|
||||
match build_frontend.name:
|
||||
|
||||
@@ -274,7 +274,10 @@ def build_in_container(
|
||||
container.call(["mkdir", "-p", built_wheel_dir])
|
||||
|
||||
extra_flags = get_build_frontend_extra_flags(
|
||||
build_frontend, build_options.build_verbosity, build_options.config_settings
|
||||
build_frontend,
|
||||
build_options.build_verbosity,
|
||||
build_options.config_settings,
|
||||
py38=config.identifier[1:].startswith("p38"),
|
||||
)
|
||||
|
||||
match build_frontend.name:
|
||||
|
||||
@@ -472,7 +472,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
built_wheel_dir.mkdir()
|
||||
|
||||
extra_flags = get_build_frontend_extra_flags(
|
||||
build_frontend, build_options.build_verbosity, build_options.config_settings
|
||||
build_frontend,
|
||||
build_options.build_verbosity,
|
||||
build_options.config_settings,
|
||||
py38=config.identifier[1:].startswith("p38"),
|
||||
)
|
||||
|
||||
build_env = env.copy()
|
||||
|
||||
@@ -416,7 +416,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
log.step("Building wheel...")
|
||||
|
||||
extra_flags = get_build_frontend_extra_flags(
|
||||
build_frontend, build_options.build_verbosity, build_options.config_settings
|
||||
build_frontend,
|
||||
build_options.build_verbosity,
|
||||
build_options.config_settings,
|
||||
py38=False,
|
||||
)
|
||||
|
||||
call(
|
||||
|
||||
@@ -450,7 +450,10 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
built_wheel_dir.mkdir()
|
||||
|
||||
extra_flags = get_build_frontend_extra_flags(
|
||||
build_frontend, build_options.build_verbosity, build_options.config_settings
|
||||
build_frontend,
|
||||
build_options.build_verbosity,
|
||||
build_options.config_settings,
|
||||
py38=config.identifier[1:].startswith("p38"),
|
||||
)
|
||||
|
||||
if (
|
||||
|
||||
+10
-8
@@ -1762,14 +1762,16 @@ will not produce more logging about the build itself. Other levels only affect
|
||||
the build frontend output, which is usually things like resolving and
|
||||
downloading dependencies. The settings are:
|
||||
|
||||
| | build | pip | desc |
|
||||
|-------------|-------|--------|----------------------------------|
|
||||
| -2 | N/A | `-qq` | even more quiet, where supported |
|
||||
| -1 | N/A | `-q` | quiet mode, where supported |
|
||||
| 0 (default) | | | default for build tool |
|
||||
| 1 | | `-v` | print backend output |
|
||||
| 2 | `-v` | `-vv` | print log messages e.g. resolving info |
|
||||
| 3 | `-vv` | `-vvv` | print even more debug info |
|
||||
| | build | pip | uv | desc |
|
||||
|-------------|-------|--------|-------|----------------------------------|
|
||||
| -2 | `-qq`[^1] | `-qq` | `-qq` | even more quiet, where supported |
|
||||
| -1 | `-q`[^1] | `-q` | `-q` | quiet mode, where supported |
|
||||
| 0 (default) | | | | default for build tool |
|
||||
| 1 | | `-v` | | print backend output |
|
||||
| 2 | `-v` | `-vv` | `-v` | print log messages e.g. resolving info |
|
||||
| 3 | `-vv` | `-vvv` | `-vv` | print even more debug info |
|
||||
|
||||
[^1]: Not supported on Python 3.8, will be ignored with a warning.
|
||||
|
||||
Settings that are not supported for a specific frontend will log a warning.
|
||||
The default build frontend is `build`, which does show build backend output by
|
||||
|
||||
@@ -594,11 +594,15 @@ def test_deprecated_image(
|
||||
("pip", 3, ["-Ca", "-Cb", "-1", "-vvv"]),
|
||||
("pip", 2, ["-Ca", "-Cb", "-1", "-vv"]),
|
||||
("pip", -1, ["-Ca", "-Cb", "-1", "-q"]),
|
||||
("uv", -1, ["-Ca", "-Cb", "-1", "-q"]),
|
||||
("build", -1, ["-Ca", "-Cb", "-1", "-q"]),
|
||||
("build[uv]", -1, ["-Ca", "-Cb", "-1", "-q"]),
|
||||
("build", 0, ["-Ca", "-Cb", "-1"]),
|
||||
("build", 1, ["-Ca", "-Cb", "-1"]),
|
||||
("build", 2, ["-Ca", "-Cb", "-1", "-v"]),
|
||||
("build", 3, ["-Ca", "-Cb", "-1", "-vv"]),
|
||||
("build[uv]", 3, ["-Ca", "-Cb", "-1", "-vv"]),
|
||||
("uv", 3, ["-Ca", "-Cb", "-1", "-vv"]),
|
||||
],
|
||||
)
|
||||
def test_get_build_frontend_extra_flags(
|
||||
@@ -611,7 +615,7 @@ def test_get_build_frontend_extra_flags(
|
||||
monkeypatch.setattr(Logger, "warning", mock_warning)
|
||||
build_frontend = BuildFrontendConfig(frontend, ["-1"])
|
||||
args = get_build_frontend_extra_flags(
|
||||
build_frontend=build_frontend, verbosity_level=verbosity, config_settings="a b"
|
||||
build_frontend=build_frontend, verbosity_level=verbosity, config_settings="a b", py38=False
|
||||
)
|
||||
|
||||
assert args == result
|
||||
@@ -626,7 +630,7 @@ def test_get_build_frontend_extra_flags_warning(
|
||||
monkeypatch.setattr(Logger, "warning", mock_warning)
|
||||
build_frontend = BuildFrontendConfig(frontend, ["-1"])
|
||||
args = get_build_frontend_extra_flags(
|
||||
build_frontend=build_frontend, verbosity_level=-1, config_settings="a b"
|
||||
build_frontend=build_frontend, verbosity_level=-1, config_settings="a b", py38=True
|
||||
)
|
||||
assert args == ["-Ca", "-Cb", "-1"]
|
||||
mock_warning.assert_called_once()
|
||||
|
||||
Reference in New Issue
Block a user