Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cibuildwheel/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def _get_verbosity_flags(level: int, frontend: BuildFrontendName) -> list[str]:
return ["-" + level * "v"]
if level < 0:
return ["-" + -level * "q"]
elif not 0 <= level < 2:
elif level > 1:
return ["-v"]
elif level < 0:
if frontend not in {"build", "build[uv]"}:
return ["-q"]
msg = f"build_verbosity {level} is not supported for {frontend} frontend. Ignoring."
log.warning(msg)
return []
Expand Down
11 changes: 9 additions & 2 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1760,9 +1760,16 @@ export CIBW_DEBUG_TRACEBACK=TRUE
```

### `CIBW_BUILD_VERBOSITY` {: #build-verbosity}
> Increase/decrease the output of pip wheel
> Increase/decrease the output of the build

The setting vary a bit between build backends.

* `-1`: Hide as much build output as possible; passes `-q` to the build backend. Not supported by `build`/`build[uv]`.
* `0`: The default. On pip, this hides the build output if the build succeeds, other build backends produce output from the build backend.
* `1`: Produces build backend output. On `pip`, this passes `-v`. Other backends do this by default.
* `2`: Produces extra output from resolving packages too. On `pip`, this passes `-vv`, other build backends use `-v`.
* `3`: Even more resolving output from pip with `-vvv`, other build backends continue to just pass `-v`.

A number from 1 to 3 to increase the level of verbosity (corresponding to invoking pip with `-v`, `-vv`, and `-vvv`), between -1 and -3 (`-q`, `-qq`, and `-qqq`), or just 0 (default verbosity). These flags are useful while debugging a build when the output of the actual build invoked by `pip wheel` is required. Has no effect on the `build` backend, which produces verbose output by default.

Platform-specific environment variables are also available:<br/>
`CIBW_BUILD_VERBOSITY_MACOS` | `CIBW_BUILD_VERBOSITY_WINDOWS` | `CIBW_BUILD_VERBOSITY_LINUX` | `CIBW_BUILD_VERBOSITY_IOS` | `CIBW_BUILD_VERBOSITY_PYODIDE`
Expand Down
48 changes: 48 additions & 0 deletions unit_test/options_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import os
import platform as platform_module
import textwrap
import unittest.mock
from pathlib import Path
from typing import Literal

import pytest

from cibuildwheel import errors
from cibuildwheel.bashlex_eval import local_environment_executor
from cibuildwheel.frontend import BuildFrontendConfig, get_build_frontend_extra_flags
from cibuildwheel.logger import Logger
from cibuildwheel.options import (
CommandLineArguments,
Options,
Expand Down Expand Up @@ -570,3 +574,47 @@ def test_deprecated_image(
assert f"{resolved_image!r}" in captured.err
else:
assert "Deprecated image" not in captured.err


@pytest.mark.parametrize(
("frontend", "verbosity", "result"),
[
("pip", 3, ["-Ca", "-Cb", "-1", "-vvv"]),
("pip", 2, ["-Ca", "-Cb", "-1", "-vv"]),
("pip", -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", "-v"]),
("build[uv]", 3, ["-Ca", "-Cb", "-1", "-v"]),
],
)
def test_get_build_frontend_extra_flags(
frontend: Literal["pip", "build", "build[uv]"],
verbosity: int,
result: list[str],
monkeypatch: pytest.MonkeyPatch,
) -> None:
mock_warning = unittest.mock.MagicMock()
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"
)

assert args == result
mock_warning.assert_not_called()


@pytest.mark.parametrize("frontend", ["build", "build[uv]"])
def test_get_build_frontend_extra_flags_warning(
frontend: Literal["build", "build[uv]"], monkeypatch: pytest.MonkeyPatch
) -> None:
mock_warning = unittest.mock.MagicMock()
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"
)
assert args == ["-Ca", "-Cb", "-1"]
mock_warning.assert_called_once()
Loading