Allow workspace requirements to be ignored during uv run (#3108)

This commit is contained in:
Zanie Blue
2024-04-19 09:52:04 -05:00
committed by GitHub
parent 01a7b7a088
commit 9bcc1943cc
3 changed files with 11 additions and 3 deletions
+5
View File
@@ -1641,6 +1641,11 @@ pub(crate) struct RunArgs {
/// Run with the given packages installed.
#[arg(long)]
pub(crate) with: Vec<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)]
+5 -3
View File
@@ -43,6 +43,7 @@ pub(crate) async fn run(
args: Vec<String>,
mut requirements: Vec<RequirementsSource>,
isolated: bool,
no_workspace: bool,
cache: &Cache,
printer: Printer,
) -> Result<ExitStatus> {
@@ -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.
+1
View File
@@ -599,6 +599,7 @@ async fn run() -> Result<ExitStatus> {
args.args,
requirements,
args.isolated,
args.no_workspace,
&cache,
printer,
)