diff --git a/crates/uv/src/cli.rs b/crates/uv/src/cli.rs index 3d103b86a..1987445b1 100644 --- a/crates/uv/src/cli.rs +++ b/crates/uv/src/cli.rs @@ -1641,6 +1641,11 @@ pub(crate) struct RunArgs { /// Run with the given packages installed. #[arg(long)] pub(crate) with: Vec, + + /// 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)] diff --git a/crates/uv/src/commands/run.rs b/crates/uv/src/commands/run.rs index ed6f40562..3c4e43b9c 100644 --- a/crates/uv/src/commands/run.rs +++ b/crates/uv/src/commands/run.rs @@ -43,6 +43,7 @@ pub(crate) async fn run( args: Vec, mut requirements: Vec, isolated: bool, + no_workspace: bool, cache: &Cache, printer: Printer, ) -> Result { @@ -52,9 +53,10 @@ pub(crate) async fn run( // cannot be applied to transitive dependencies. let overrides = requirements.clone(); - // TODO(zanieb): Provide an opt-out for this behavior - if let Some(workspace_requirements) = find_workspace_requirements()? { - requirements.extend(workspace_requirements); + if !no_workspace { + if let Some(workspace_requirements) = find_workspace_requirements()? { + requirements.extend(workspace_requirements); + } } // Detect the current Python interpreter. diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index b562a5735..bfc373ef7 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -599,6 +599,7 @@ async fn run() -> Result { args.args, requirements, args.isolated, + args.no_workspace, &cache, printer, )