Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to specify a custom source package to uv tool run #3677

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/uv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1945,6 +1945,12 @@ pub(crate) struct ToolRunArgs {
#[arg(allow_hyphen_values = true)]
pub(crate) args: Vec<OsString>,

/// Use the given package to provide the command.
///
/// By default, the package name is assumed to match the command name.
#[arg(long)]
pub(crate) from: 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>,
from: 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(
from.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 @@ -607,6 +607,7 @@ async fn run() -> Result<ExitStatus> {
args.target,
args.args,
args.python,
args.from,
globals.isolated,
globals.preview,
&cache,
Expand Down
Loading