Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,13 @@ pub struct BuildArgs {
#[arg(long)]
pub wheel: bool,

#[arg(long, overrides_with("no_build_logs"), hide = true)]
pub build_logs: bool,

/// Hide logs from the build backend.
#[arg(long, overrides_with("build_logs"), hide = true)]
pub no_build_logs: bool,

/// Constrain build dependencies using the given requirements files when building
/// distributions.
///
Expand Down
11 changes: 10 additions & 1 deletion crates/uv/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub(crate) async fn build(
output_dir: Option<PathBuf>,
sdist: bool,
wheel: bool,
build_logs: bool,
build_constraints: Vec<RequirementsSource>,
hash_checking: Option<HashCheckingMode>,
python: Option<String>,
Expand All @@ -58,6 +59,7 @@ pub(crate) async fn build(
output_dir.as_deref(),
sdist,
wheel,
build_logs,
&build_constraints,
hash_checking,
python.as_deref(),
Expand Down Expand Up @@ -109,6 +111,7 @@ async fn build_impl(
output_dir: Option<&Path>,
sdist: bool,
wheel: bool,
build_logs: bool,
build_constraints: &[RequirementsSource],
hash_checking: Option<HashCheckingMode>,
python_request: Option<&str>,
Expand Down Expand Up @@ -369,7 +372,13 @@ async fn build_impl(
let dist = None;

let build_output = match printer {
Printer::Default | Printer::NoProgress | Printer::Verbose => BuildOutput::Stderr,
Printer::Default | Printer::NoProgress | Printer::Verbose => {
if build_logs {
BuildOutput::Stderr
} else {
BuildOutput::Quiet
}
}
Printer::Quiet => BuildOutput::Quiet,
};

Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.out_dir,
args.sdist,
args.wheel,
args.build_logs,
build_constraints,
args.hash_checking,
args.python,
Expand Down
4 changes: 4 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ pub(crate) struct BuildSettings {
pub(crate) out_dir: Option<PathBuf>,
pub(crate) sdist: bool,
pub(crate) wheel: bool,
pub(crate) build_logs: bool,
pub(crate) build_constraint: Vec<PathBuf>,
pub(crate) hash_checking: Option<HashCheckingMode>,
pub(crate) python: Option<String>,
Expand All @@ -1687,6 +1688,8 @@ impl BuildSettings {
no_require_hashes,
verify_hashes,
no_verify_hashes,
build_logs,
no_build_logs,
python,
build,
refresh,
Expand All @@ -1699,6 +1702,7 @@ impl BuildSettings {
out_dir,
sdist,
wheel,
build_logs: flag(build_logs, no_build_logs).unwrap_or(true),
build_constraint: build_constraint
.into_iter()
.filter_map(Maybe::into_option)
Expand Down
38 changes: 38 additions & 0 deletions crates/uv/tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1521,3 +1521,41 @@ fn build_quiet() -> Result<()> {

Ok(())
}

#[test]
fn build_no_build_logs() -> Result<()> {
let context = TestContext::new("3.12");

let project = context.temp_dir.child("project");

let pyproject_toml = project.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["anyio==3.7.0"]

[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
"#,
)?;

project.child("src").child("__init__.py").touch()?;
project.child("README").touch()?;

uv_snapshot!(&context.filters(), context.build().arg("project").arg("--no-build-logs"), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Building source distribution...
Building wheel from source distribution...
Successfully built project/dist/project-0.1.0.tar.gz and project/dist/project-0.1.0-py3-none-any.whl
"###);

Ok(())
}