Skip to content

Commit a759612

Browse files
Show package list with pip freeze --quiet (#16491)
## Summary Closes #16178.
1 parent 61c67be commit a759612

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

crates/uv/src/commands/pip/freeze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub(crate) fn pip_freeze(
8383
}
8484
})
8585
.dedup()
86-
.try_for_each(|dist| writeln!(printer.stdout(), "{dist}"))?;
86+
.try_for_each(|dist| writeln!(printer.stdout_important(), "{dist}"))?;
8787

8888
// Validate that the environment is consistent.
8989
if strict {

crates/uv/src/commands/pip/list.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::cmp::max;
22
use std::fmt::Write;
33

4-
use anstream::println;
54
use anyhow::Result;
65
use futures::StreamExt;
76
use itertools::Itertools;
@@ -181,7 +180,7 @@ pub(crate) async fn pip_list(
181180
})
182181
.collect_vec();
183182
let output = serde_json::to_string(&rows)?;
184-
println!("{output}");
183+
writeln!(printer.stdout_important(), "{output}")?;
185184
}
186185
ListFormat::Columns if results.is_empty() => {}
187186
ListFormat::Columns => {
@@ -255,13 +254,18 @@ pub(crate) async fn pip_list(
255254
}
256255

257256
for elems in MultiZip(columns.iter().map(Column::fmt).collect_vec()) {
258-
println!("{}", elems.join(" ").trim_end());
257+
writeln!(printer.stdout_important(), "{}", elems.join(" ").trim_end())?;
259258
}
260259
}
261260
ListFormat::Freeze if results.is_empty() => {}
262261
ListFormat::Freeze => {
263262
for dist in &results {
264-
println!("{}=={}", dist.name().bold(), dist.version());
263+
writeln!(
264+
printer.stdout_important(),
265+
"{}=={}",
266+
dist.name().bold(),
267+
dist.version()
268+
)?;
265269
}
266270
}
267271
}

crates/uv/tests/it/pip_freeze.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,32 @@ fn freeze_nonexistent_path() {
453453
----- stderr -----
454454
");
455455
}
456+
457+
#[test]
458+
fn freeze_with_quiet_flag() -> Result<()> {
459+
let context = TestContext::new("3.12");
460+
461+
let requirements_txt = context.temp_dir.child("requirements.txt");
462+
requirements_txt.write_str("MarkupSafe==2.1.3\ntomli==2.0.1")?;
463+
464+
// Run `pip sync`.
465+
context
466+
.pip_sync()
467+
.arg(requirements_txt.path())
468+
.assert()
469+
.success();
470+
471+
// Run `pip freeze` with `--quiet` flag.
472+
uv_snapshot!(context.pip_freeze().arg("--quiet"), @r###"
473+
success: true
474+
exit_code: 0
475+
----- stdout -----
476+
markupsafe==2.1.3
477+
tomli==2.0.1
478+
479+
----- stderr -----
480+
"###
481+
);
482+
483+
Ok(())
484+
}

0 commit comments

Comments
 (0)