Skip to content

Commit

Permalink
Allow users to specify a custom package spec to uv tool run
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed May 20, 2024
1 parent 68e4a18 commit affc0d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions crates/uv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,11 @@ pub(crate) struct ToolRunArgs {
#[arg(allow_hyphen_values = true)]
pub(crate) args: Vec<OsString>,

// TODO(zanieb): Consider using `Vec<String>` instead, treating the first as the target package
/// Use the given package specification instead of inferring it from the target command.
#[arg(long)]
pub(crate) package: Option<String>,

/// The Python interpreter to use to build the run environment.
#[arg(
long,
Expand Down
8 changes: 5 additions & 3 deletions crates/uv/src/commands/tool/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) async fn run(
target: String,
args: Vec<OsString>,
python: Option<String>,
package: Option<String>,
_isolated: bool,
preview: PreviewMode,
cache: &Cache,
Expand All @@ -32,9 +33,10 @@ pub(crate) async fn run(
warn_user!("`uv tool run` is experimental and may change without warning.");
}

// TODO(zanieb): Allow users to pass an explicit package name different than the target
// as well as additional requirements
let requirements = [RequirementsSource::from_package(target.clone())];
// TODO(zanieb): Allow users to pass additional requirements
let requirements = [RequirementsSource::from_package(
package.unwrap_or_else(|| target.clone()),
)];

// TODO(zanieb): When implementing project-level tools, discover the project and check if it has the tool
// TOOD(zanieb): Determine if we sould layer on top of the project environment if it is present
Expand Down
1 change: 1 addition & 0 deletions crates/uv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ async fn run() -> Result<ExitStatus> {
args.target,
args.args,
args.python,
args.package,
globals.isolated,
globals.preview,
&cache,
Expand Down

0 comments on commit affc0d7

Please sign in to comment.