Build backend: Add --list option (#9610)

Add the `uv build --list`, a "subcommand" to list the files that would
be included when building a distribution. It does not build the
distribution, except when a source dist is required for source dist ->
wheel. This is an important debugging tool for the include and exclude
options: Did i actually include the files I wanted, or am i shipping a
broken distribution? Are there any temporary files I still need to
exclude?

Cargo offers this as `cargo package --list`.

`--list` is preview-exclusive, since it requires the fast path, which I
also put into preview.

Examples:


![image](https://github.com/user-attachments/assets/55e3f169-3051-4217-987d-0cb01ae5050e)


![image](https://github.com/user-attachments/assets/1da75245-358d-4bee-9199-f720089f0a70)


![image](https://github.com/user-attachments/assets/4d97a893-552e-43a1-9c22-78fc67f1e9f5)

I'll fix the error handling in a follow-up.

Tagging as enhancement because it changes the stable output slightly
(two lines instead of one).

CC @charliermarsh for uv-wide consistency in the stdout/stderr handling.
This commit is contained in:
konsti 2024-12-04 09:52:27 +01:00 committed by GitHub
parent d7b74f964e
commit 7d82cbff01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 570 additions and 177 deletions

View file

@ -2175,6 +2175,18 @@ pub struct BuildArgs {
#[arg(long)]
pub wheel: bool,
/// When using the uv build backend, list the files that would be included when building.
///
/// Skips building the actual distribution, except when the source distribution is needed to
/// build the wheel. The file list is collected directly without a PEP 517 environment. It only
/// works with the uv build backend, there is no PEP 517 file list build hook.
///
/// This option can be combined with `--sdist` and `--wheel` for inspecting different build
/// paths.
// Hidden while in preview.
#[arg(long, hide = true)]
pub list: bool,
#[arg(long, overrides_with("no_build_logs"), hide = true)]
pub build_logs: bool,
@ -2187,7 +2199,7 @@ pub struct BuildArgs {
/// By default, uv won't create a PEP 517 build environment for packages using the uv build
/// backend, but use a fast path that calls into the build backend directly. This option forces
/// always using PEP 517.
#[arg(long)]
#[arg(long, conflicts_with = "list")]
pub force_pep517: bool,
/// Constrain build dependencies using the given requirements files when building