Skip to content

Commit

Permalink
Use top-level --isolated for uv run (#3431)
Browse files Browse the repository at this point in the history
## Summary

We already have a global `--isolated`, which means "ignore any on-disk
configuration". I think we should reuse this for the "ignore the
workspace" setting in `uv run`, rather than `--no-workspace`.

I've also merged the existing `--isolated` and `--no-workspace`
behaviors in `uv run` into a single flag. We may not need separate flags
for this, since the current intent seems to be "ignore the workspace
environment"? Though we could always re-add later.

Closes #3421.
  • Loading branch information
charliermarsh committed May 7, 2024
1 parent 7fe9f0a commit e8b423d
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 19 deletions.
9 changes: 0 additions & 9 deletions crates/uv/src/cli.rs
Expand Up @@ -1827,10 +1827,6 @@ pub(crate) struct RunArgs {
#[arg(allow_hyphen_values = true)]
pub(crate) args: Vec<OsString>,

/// Always use a new virtual environment for execution.
#[arg(long)]
pub(crate) isolated: bool,

/// Run with the given packages installed.
#[arg(long)]
pub(crate) with: Vec<String>,
Expand All @@ -1854,11 +1850,6 @@ pub(crate) struct RunArgs {
group = "discovery"
)]
pub(crate) python: Option<String>,

/// Run without the current workspace installed.
#[arg(long)]
pub(crate) no_workspace: bool,
// TODO(zanieb): Consider alternative names like `--no-project` or `--without-project`
}

#[derive(Args)]
Expand Down
3 changes: 1 addition & 2 deletions crates/uv/src/commands/run.rs
Expand Up @@ -49,7 +49,6 @@ pub(crate) async fn run(
mut requirements: Vec<RequirementsSource>,
python: Option<String>,
isolated: bool,
no_workspace: bool,
preview: PreviewMode,
cache: &Cache,
printer: Printer,
Expand Down Expand Up @@ -80,7 +79,7 @@ pub(crate) async fn run(
// cannot be applied to transitive dependencies.
let overrides = requirements.clone();

if !no_workspace {
if !isolated {
if let Some(workspace_requirements) = find_workspace_requirements()? {
requirements.extend(workspace_requirements);
}
Expand Down
3 changes: 1 addition & 2 deletions crates/uv/src/main.rs
Expand Up @@ -521,8 +521,7 @@ async fn run() -> Result<ExitStatus> {
args.args,
requirements,
args.python,
args.isolated,
args.no_workspace,
cli.isolated,
globals.preview,
&cache,
printer,
Expand Down
6 changes: 0 additions & 6 deletions crates/uv/src/settings.rs
Expand Up @@ -85,9 +85,7 @@ pub(crate) struct RunSettings {
// CLI-only settings.
pub(crate) target: Option<String>,
pub(crate) args: Vec<OsString>,
pub(crate) isolated: bool,
pub(crate) with: Vec<String>,
pub(crate) no_workspace: bool,
pub(crate) python: Option<String>,
}

Expand All @@ -98,19 +96,15 @@ impl RunSettings {
let RunArgs {
target,
args,
isolated,
with,
no_workspace,
python,
} = args;

Self {
// CLI-only settings.
target,
args,
isolated,
with,
no_workspace,
python,
}
}
Expand Down

0 comments on commit e8b423d

Please sign in to comment.