Skip to content

Commit

Permalink
Add uv version to debug output (#4259)
Browse files Browse the repository at this point in the history
## Summary

I think this is a useful piece of connective tissue that will let us
avoid back-and-forths when folks include traces.

## Test Plan

```
❯ cargo run pip list --verbose
DEBUG uv 0.2.11 (44041bc 2024-06-11)
DEBUG Searching for Python interpreter in virtual environments
DEBUG Found CPython 3.12.3 at `/Users/crmarsh/workspace/puffin/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.3 environment at .venv/bin/python3
```
  • Loading branch information
charliermarsh authored Jun 12, 2024
1 parent 8a8e1af commit 034b479
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/uv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use anyhow::Result;
use clap::error::{ContextKind, ContextValue};
use clap::{CommandFactory, Parser};
use owo_colors::OwoColorize;
use tracing::instrument;
use tracing::{debug, instrument};

use cli::{ToolCommand, ToolNamespace, ToolchainCommand, ToolchainNamespace};
use uv_cache::Cache;
Expand Down Expand Up @@ -174,6 +174,8 @@ async fn run() -> Result<ExitStatus> {
)
}))?;

debug!("uv {}", version::version());

// Resolve the cache settings.
let cache = CacheSettings::resolve(cli.cache_args, workspace.as_ref());
let cache = Cache::from_settings(cache.no_cache, cache.cache_dir)?;
Expand Down
20 changes: 18 additions & 2 deletions crates/uv/tests/cache_prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ fn prune_no_op() -> Result<()> {
.assert()
.success();

uv_snapshot!(context.filters(), prune_command(&context).arg("--verbose"), @r###"
let filters: Vec<_> = context
.filters()
.into_iter()
.chain([(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)")])
.collect();

uv_snapshot!(filters, prune_command(&context).arg("--verbose"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
Pruning cache at: [CACHE_DIR]/
No unused entries found
"###);
Expand All @@ -99,12 +106,19 @@ fn prune_stale_directory() -> Result<()> {
let simple = context.cache_dir.child("simple-v4");
simple.create_dir_all()?;

uv_snapshot!(context.filters(), prune_command(&context).arg("--verbose"), @r###"
let filters: Vec<_> = context
.filters()
.into_iter()
.chain([(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)")])
.collect();

uv_snapshot!(filters, prune_command(&context).arg("--verbose"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling cache entry: [CACHE_DIR]/simple-v4
Removed 1 directory
Expand Down Expand Up @@ -135,6 +149,7 @@ fn prune_stale_symlink() -> Result<()> {
.filters()
.into_iter()
.chain([
(r"uv \d+\.\d+\.\d+ \(.*\)", r"uv [VERSION] ([COMMIT] DATE)"),
// The cache entry does not have a stable key, so we filter it out
(
r"\[CACHE_DIR\](\\|\/)(.+)(\\|\/).*",
Expand All @@ -149,6 +164,7 @@ fn prune_stale_symlink() -> Result<()> {
----- stdout -----
----- stderr -----
DEBUG uv [VERSION] ([COMMIT] DATE)
Pruning cache at: [CACHE_DIR]/
DEBUG Removing dangling cache entry: [CACHE_DIR]/archive-v0/[ENTRY]
Removed 44 files ([SIZE])
Expand Down

0 comments on commit 034b479

Please sign in to comment.