From 3f839373d63855773dd0f7a61fc285e8f897e54b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 24 Feb 2024 21:56:23 -0500 Subject: [PATCH] Don't write pip compile output to stdout with -q --- crates/uv/src/commands/pip_compile.rs | 14 +++++++++----- crates/uv/src/main.rs | 1 + requirements.in | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 requirements.in diff --git a/crates/uv/src/commands/pip_compile.rs b/crates/uv/src/commands/pip_compile.rs index a20c5bde5ae8..5136be096bf6 100644 --- a/crates/uv/src/commands/pip_compile.rs +++ b/crates/uv/src/commands/pip_compile.rs @@ -65,6 +65,7 @@ pub(crate) async fn pip_compile( python_version: Option, exclude_newer: Option>, annotation_style: AnnotationStyle, + quiet: bool, cache: Cache, mut printer: Printer, ) -> Result { @@ -336,7 +337,7 @@ pub(crate) async fn pip_compile( } // Write the resolved dependencies to the output channel. - let mut writer = OutputWriter::new(output_file)?; + let mut writer = OutputWriter::new(!quiet || output_file.is_none(), output_file)?; if include_header { writeln!( @@ -482,14 +483,14 @@ fn cmd(include_index_url: bool, include_find_links: bool) -> String { /// A multi-casting writer that writes to both the standard output and an output file, if present. struct OutputWriter { - stdout: AutoStream, + stdout: Option>, output_file: Option>, } impl OutputWriter { /// Create a new output writer. - fn new(output_file: Option<&Path>) -> Result { - let stdout = AutoStream::::auto(stdout()); + fn new(include_stdout: bool, output_file: Option<&Path>) -> Result { + let stdout = include_stdout.then(|| AutoStream::::auto(stdout())); let output_file = output_file .map(|output_file| { let output_file = fs_err::File::create(output_file)?; @@ -510,7 +511,10 @@ impl OutputWriter { if let Some(output_file) = &mut self.output_file { write!(output_file, "{args}")?; } - write!(self.stdout, "{args}")?; + + if let Some(stdout) = &mut self.stdout { + write!(stdout, "{args}")?; + } Ok(()) } diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index 3d5c86ddb354..ab8384f03e2f 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -932,6 +932,7 @@ async fn run() -> Result { args.python_version, args.exclude_newer, args.annotation_style, + cli.quiet, cache, printer, ) diff --git a/requirements.in b/requirements.in deleted file mode 100644 index d572c51bc716..000000000000 --- a/requirements.in +++ /dev/null @@ -1,2 +0,0 @@ -apache-airflow[otel] -opentelemetry-exporter-prometheus<0.44