Skip to content

Commit

Permalink
Default to python when uv run does not recieve a command
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Apr 17, 2024
1 parent a7c53f1 commit db9246f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/uv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ pub(crate) struct VenvArgs {
#[allow(clippy::struct_excessive_bools)]
pub(crate) struct RunArgs {
/// The command to run.
pub(crate) command: String,
pub(crate) target: Option<String>,

/// The arguments to the command.
#[arg(allow_hyphen_values = true)]
Expand Down
7 changes: 5 additions & 2 deletions crates/uv/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy, InFlight};
/// Run a command.
#[allow(clippy::unnecessary_wraps, clippy::too_many_arguments)]
pub(crate) async fn run(
command: String,
target: Option<String>,
args: Vec<String>,
mut requirements: Vec<RequirementsSource>,
isolated: bool,
no_workspace: bool,
cache: &Cache,
printer: Printer,
) -> Result<ExitStatus> {
let command = target.unwrap_or("python".to_string());

// Copy the requirements into a set of overrides; we'll use this to prioritize
// requested requirements over those discovered in the project.
// We must retain these requirements as direct dependencies too, as overrides
Expand Down Expand Up @@ -88,7 +90,8 @@ pub(crate) async fn run(
// Spawn and wait for completion
// Standard input, output, and error streams are all inherited
// TODO(zanieb): Throw a nicer error message if the command is not found
debug!("Running `{command} {}`", args.join(" "));
let space = if args.is_empty() { "" } else { " " };
debug!("Running `{command}{space}{}`", args.join(" "));
let mut handle = process.spawn()?;
let status = handle.wait().await?;

Expand Down
2 changes: 1 addition & 1 deletion crates/uv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ async fn run() -> Result<ExitStatus> {
.collect::<Vec<_>>();

commands::run(
args.command,
args.target,
args.args,
requirements,
args.isolated,
Expand Down

0 comments on commit db9246f

Please sign in to comment.