Reframe use of --isolated in tool run (#5470)

## Summary

This PR gets rid of the global `--isolated` flag (which serves a bunch
of independent responsibilities right now) on `uv tool run` in favor of
a dedicated `--isolated` flag, which tells uv to avoid re-using an
existing tool environment for this invocation. We'll add the same thing
to `uv run`, to avoid using the base project environment.

This will become a bit clearer in #5466, when we deprecate the
`--isolated` flag on the preview APIs.
This commit is contained in:
Charlie Marsh 2024-07-30 15:09:53 -04:00 committed by GitHub
parent 8545ae2312
commit ff3bcbb639
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View file

@ -2291,6 +2291,10 @@ pub struct ToolRunArgs {
#[arg(long, value_parser = parse_maybe_file_path)]
pub with_requirements: Vec<Maybe<PathBuf>>,
/// Run the tool in an isolated virtual environment, ignoring any already-installed tools.
#[arg(long)]
pub isolated: bool,
#[command(flatten)]
pub installer: ResolverInstallerArgs,

View file

@ -654,7 +654,7 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
args.python,
args.settings,
invocation_source,
globals.isolated,
args.isolated || globals.isolated,
globals.preview,
globals.python_preference,
globals.python_fetch,

View file

@ -261,6 +261,7 @@ pub(crate) struct ToolRunSettings {
pub(crate) from: Option<String>,
pub(crate) with: Vec<String>,
pub(crate) with_requirements: Vec<PathBuf>,
pub(crate) isolated: bool,
pub(crate) show_resolution: bool,
pub(crate) python: Option<String>,
pub(crate) refresh: Refresh,
@ -276,6 +277,7 @@ impl ToolRunSettings {
from,
with,
with_requirements,
isolated,
show_resolution,
installer,
build,
@ -291,6 +293,7 @@ impl ToolRunSettings {
.into_iter()
.filter_map(Maybe::into_option)
.collect(),
isolated,
show_resolution,
python,
refresh: Refresh::from(refresh),