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

fix: support wider range of verbosity settings on other build backends #2339

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

henryiii
Copy link
Contributor

@henryiii henryiii commented Mar 28, 2025

See #2338.

This makes the verbosity setting a bit more useful on other backends. This tries to map the current pip meanings to other backends. The key changes are:

  • <0 will support uv (feat: option to build directly with uv #2322), build continues to produce a warning. This is a feature that's been requested before for build, btw.
  • 1 continues to do nothing on non-pip backends
  • 2+ now passes multiple -v to non-pip backends, since both build and uv support adding extra resolving info (similar to pip's -vv) if passing -v.

@mayeut
Copy link
Member

mayeut commented Mar 29, 2025

Should we be trying to get something consistent between frontends ? i.e. 0 maps to -v with pip

@joerick
Copy link
Contributor

joerick commented Mar 30, 2025

Should we be trying to get something consistent between frontends ? i.e. 0 maps to -v with pip

If we want to keep this option, I like this idea. Previously I was in favour of a light-touch approach to adding arguments to pip wheel. But printing the build backend output by default makes a lot of sense in a CI scenario, and with build the default now, we're just making the option consistent between frontends.

so that would be

build pip uv desc
-2 not supported -q not supported quiet mode
-1 not supported -q reduce output, where supported
0 (default) -v print backend output (default)
1 -v -vv -v print log messages e.g. resolving info
2 -vv -vvv -vv print even more debug info

I think it would be nice to warn on unsupported settings i.e. (not supported, above) or outside -2...2.

The other approach, of course, is to avoid this mess, deprecate the build-verbosity option and refer users to build-frontend with the args: param. I'd be open to either, I think.

@henryiii
Copy link
Contributor Author

henryiii commented Mar 30, 2025

That is very similar to what I had, but with one difference: 0 is "native", which doesn't add any flags, keeping to the native behavior of the tool, and allows a user to use the args: if they prefer. If you set verbosity=1, that tells all backends to produce verbose output consistently.

build pip uv desc
-2 not supported -q not supported quiet mode
-1 not supported -q reduce output, 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

I prefer the default not adding flags (especially since we have a mechanism for users to add flags themselves). I expect most users won't change the default (which now produces build output because it uses build by default), or they'll want build output so they'll set verbose=1, which will produce build output on all backends. Plus this is backwards compatible, the values keep their meanings. Otherwise, 1 becomes too verbose, and a lot of projects have 1 set.

Since this is such an important feature, I like having the flag for it (probably not enough to have added it if we didn't already have it, but certainly happy to keep it). I have a verbose setting for scikit-build-core even though it's possible to manually pass through the verbosity flag go CMake, and it's been popular.

Co-authored-by: Matthieu Darbois <[email protected]>
@burgholzer
Copy link
Contributor

Just fyi:
Since 0.6.11, uv also supports -qq. See astral-sh/uv#12300

@joerick
Copy link
Contributor

joerick commented Mar 31, 2025

Yeah, seeing it in a table, I agree with you @henryiii. It's better to have a default that matches the build-frontend's default.

Plus this is backwards compatible, the values keep their meanings. Otherwise, 1 becomes too verbose, and a lot of projects have 1 set.

Also a good point.

docs/options.md Outdated
Comment on lines 1767 to 1771
* `-1`: Hide as much build output as possible; passes `-q` to the build frontend. Not supported by `build`/`build[uv]`.
* `0`: The default. On pip, this hides the build output if the build succeeds, other build frontends produce output from the build backend.
* `1`: Produces build backend output. On `pip`, this passes `-v`. Other frontends do this by default.
* `2`: Produces extra output from resolving packages too. On `pip`, this passes `-vv`, other build frontends use `-v`.
* `3`: Even more resolving output from pip with `-vvv`, other build frontends continue to just pass `-v`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider replacing this with the table from your comment - I think the table does a better job of conveying the meaning, especially with uv soon to be added to the mix.

Suggested change
* `-1`: Hide as much build output as possible; passes `-q` to the build frontend. Not supported by `build`/`build[uv]`.
* `0`: The default. On pip, this hides the build output if the build succeeds, other build frontends produce output from the build backend.
* `1`: Produces build backend output. On `pip`, this passes `-v`. Other frontends do this by default.
* `2`: Produces extra output from resolving packages too. On `pip`, this passes `-vv`, other build frontends use `-v`.
* `3`: Even more resolving output from pip with `-vvv`, other build frontends continue to just pass `-v`.
| | Description | build | pip | uv |
|-------------|----------------------------------------|-------|-------|------|
| -2 | quiet mode | N/A | `-q` | N/A |
| -1 | reduce output, where supported | N/A | ` ` | `-q` |
| 0 (default) | default for build tool | ` ` | ` ` | ` ` |
| 1 | print backend output | ` ` | `-v` | ` ` |
| 2 | print log messages e.g. resolving info | `-v` | `-vv` | `-v` |
| 3 | print even more debug info | `-vv` | `-vvv` | `-vv` |

elif not 0 <= level < 2:
elif level > 1:
return ["-v"]
elif level < 0:
msg = f"build_verbosity {level} is not supported for {frontend} frontend. Ignoring."
log.warning(msg)
return []
Copy link
Contributor

@joerick joerick Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are a few changes required here to match the table in your comment. e.g. -1 on pip doesn't do anything. It might be worth changing this to a map, with only a few supported settings per frontend, warning otherwise; up to you.

@henryiii
Copy link
Contributor Author

Okay, new version. Added the table, and modified it a tiny bit after observing pip wheel . -q and uv build -q look identical, with no output normally. So that's now -1 in the table.

Signed-off-by: Henry Schreiner <[email protected]>
@henryiii henryiii force-pushed the henryiii/fix/verbositylevel branch from cd633eb to e2a3160 Compare March 31, 2025 14:47
@henryiii
Copy link
Contributor Author

Also, -vv works on build, even though I don't think it does anything different, I'm only warning and skipping if it is explicitly not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants