Add `--refresh` to `uv venv` (#10834)

## Summary

I was surprised that this didn't exist.
This commit is contained in:
Charlie Marsh 2025-01-21 19:35:33 -05:00 committed by GitHub
parent d952a97f1c
commit a7166fff8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View File

@ -2472,6 +2472,9 @@ pub struct VenvArgs {
#[arg(long, value_enum, env = EnvVars::UV_LINK_MODE)] #[arg(long, value_enum, env = EnvVars::UV_LINK_MODE)]
pub link_mode: Option<uv_install_wheel::linker::LinkMode>, pub link_mode: Option<uv_install_wheel::linker::LinkMode>,
#[command(flatten)]
pub refresh: RefreshArgs,
#[command(flatten)] #[command(flatten)]
pub compat_args: compat::VenvCompatArgs, pub compat_args: compat::VenvCompatArgs,
} }

View File

@ -819,7 +819,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
show_settings!(args); show_settings!(args);
// Initialize the cache. // 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. // Since we use ".venv" as the default name, we use "." as the default prompt.
let prompt = args.prompt.or_else(|| { let prompt = args.prompt.or_else(|| {

View File

@ -2206,6 +2206,7 @@ pub(crate) struct VenvSettings {
pub(crate) system_site_packages: bool, pub(crate) system_site_packages: bool,
pub(crate) relocatable: bool, pub(crate) relocatable: bool,
pub(crate) no_project: bool, pub(crate) no_project: bool,
pub(crate) refresh: Refresh,
pub(crate) settings: PipSettings, pub(crate) settings: PipSettings,
} }
@ -2228,6 +2229,7 @@ impl VenvSettings {
exclude_newer, exclude_newer,
no_project, no_project,
link_mode, link_mode,
refresh,
compat_args: _, compat_args: _,
} = args; } = args;
@ -2239,6 +2241,7 @@ impl VenvSettings {
system_site_packages, system_site_packages,
no_project, no_project,
relocatable, relocatable,
refresh: Refresh::from(refresh),
settings: PipSettings::combine( settings: PipSettings::combine(
PipOptions { PipOptions {
python: python.and_then(Maybe::into_option), python: python.and_then(Maybe::into_option),

View File

@ -8084,6 +8084,10 @@ uv venv [OPTIONS] [PATH]
</ul> </ul>
</dd><dt><code>--quiet</code>, <code>-q</code></dt><dd><p>Do not print any output</p> </dd><dt><code>--quiet</code>, <code>-q</code></dt><dd><p>Do not print any output</p>
</dd><dt><code>--refresh</code></dt><dd><p>Refresh all cached data</p>
</dd><dt><code>--refresh-package</code> <i>refresh-package</i></dt><dd><p>Refresh cached data for a specific package</p>
</dd><dt><code>--relocatable</code></dt><dd><p>Make the virtual environment relocatable.</p> </dd><dt><code>--relocatable</code></dt><dd><p>Make the virtual environment relocatable.</p>
<p>A relocatable virtual environment can be moved around and redistributed without invalidating its associated entrypoint and activation scripts.</p> <p>A relocatable virtual environment can be moved around and redistributed without invalidating its associated entrypoint and activation scripts.</p>