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

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented May 20, 2024

We usually infer the package the tool is pulled from to be the same name as the tool itself, but that's not always the case. This allows users to provide a custom package.

@zanieb zanieb added the preview Experimental behavior label May 20, 2024
// 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>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to some bike-shedding here.

pipx says

--spec SPEC

The package name or specific installation source passed to pip. Runs pip install -U SPEC. For
example --spec mypackage==2.0.0 or --spec git+https://github.com/user/repo.git@branch

which I find very unintuitive

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. package isn't bad but it might be confusing with -p in the workspace API. I find spec okay but don't feel strongly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like -p being short for --python?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I was assuming -p would be short for package in the workspace API, as it is in cargo (cargo test -p uv, etc.).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh haha it's short for --python right now. We might need to reconsider that?

I'll think about this some more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--from? e.g. uv tool run --from foo -- bar or uv tool run --from git+https://github.com/user/repo.git@branch -- bar

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question, but how does it differ from --with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use --with (as in #3678), we will still infer the package that provides the tool from the command name so --with is additive while this flag replaces the inferred requirement.

I considered having the first --with package replace the inferred requirement but that seems confusing.

Copy link
Member Author

@zanieb zanieb May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is especially important for installation where we won't install entry points from additional dependencies, just the tool package (and I'd expect the uv tool run semantics to match)

@zanieb zanieb changed the title Allow users to specify a custom package spec to uv tool run Allow users to specify a custom source package to uv tool run May 21, 2024
@zanieb zanieb merged commit d66d326 into main May 22, 2024
45 checks passed
@zanieb zanieb deleted the zb/tool-run-spec branch May 22, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Experimental behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants