Skip to content

Commit

Permalink
Add --refresh to uv venv (#10834)
Browse files Browse the repository at this point in the history
## Summary

I was surprised that this didn't exist.
  • Loading branch information
charliermarsh authored Jan 22, 2025
1 parent d952a97 commit a7166ff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,9 @@ pub struct VenvArgs {
#[arg(long, value_enum, env = EnvVars::UV_LINK_MODE)]
pub link_mode: Option<uv_install_wheel::linker::LinkMode>,

#[command(flatten)]
pub refresh: RefreshArgs,

#[command(flatten)]
pub compat_args: compat::VenvCompatArgs,
}
Expand Down
6 changes: 5 additions & 1 deletion crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
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(|| {
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -2228,6 +2229,7 @@ impl VenvSettings {
exclude_newer,
no_project,
link_mode,
refresh,
compat_args: _,
} = args;

Expand All @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -8084,6 +8084,10 @@ uv venv [OPTIONS] [PATH]
</ul>
</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>

<p>A relocatable virtual environment can be moved around and redistributed without invalidating its associated entrypoint and activation scripts.</p>
Expand Down

0 comments on commit a7166ff

Please sign in to comment.