From effa6330718443712f682f65e8fd7455c2a68e12 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 21 Jan 2025 19:05:15 -0500 Subject: [PATCH] Add --refresh to uv venv --- crates/uv-cli/src/lib.rs | 3 +++ crates/uv/src/lib.rs | 6 +++++- crates/uv/src/settings.rs | 3 +++ docs/reference/cli.md | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 2594b047b01e..167c920e3536 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -2472,6 +2472,9 @@ pub struct VenvArgs { #[arg(long, value_enum, env = EnvVars::UV_LINK_MODE)] pub link_mode: Option, + #[command(flatten)] + pub refresh: RefreshArgs, + #[command(flatten)] pub compat_args: compat::VenvCompatArgs, } diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 0734e3deca75..3af174ca7d29 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -819,7 +819,11 @@ async fn run(mut cli: Cli) -> Result { show_settings!(args); // Initialize the cache. - let cache = cache.init()?; + let cache = cache.init()?.with_refresh( + args.refresh + .combine(Refresh::from(args.settings.reinstall.clone())) + .combine(Refresh::from(args.settings.upgrade.clone())), + ); // Since we use ".venv" as the default name, we use "." as the default prompt. let prompt = args.prompt.or_else(|| { diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 2637fff91e8d..1e59e0f94ab5 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -2206,6 +2206,7 @@ pub(crate) struct VenvSettings { pub(crate) system_site_packages: bool, pub(crate) relocatable: bool, pub(crate) no_project: bool, + pub(crate) refresh: Refresh, pub(crate) settings: PipSettings, } @@ -2228,6 +2229,7 @@ impl VenvSettings { exclude_newer, no_project, link_mode, + refresh, compat_args: _, } = args; @@ -2239,6 +2241,7 @@ impl VenvSettings { system_site_packages, no_project, relocatable, + refresh: Refresh::from(refresh), settings: PipSettings::combine( PipOptions { python: python.and_then(Maybe::into_option), diff --git a/docs/reference/cli.md b/docs/reference/cli.md index aa5439446480..19d6add46bd4 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -8084,6 +8084,10 @@ uv venv [OPTIONS] [PATH]
--quiet, -q

Do not print any output

+
--refresh

Refresh all cached data

+ +
--refresh-package refresh-package

Refresh cached data for a specific package

+
--relocatable

Make the virtual environment relocatable.

A relocatable virtual environment can be moved around and redistributed without invalidating its associated entrypoint and activation scripts.