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

Add initial implementation of uv tool run #3657

Merged
merged 1 commit into from
May 21, 2024
Merged

Add initial implementation of uv tool run #3657

merged 1 commit into from
May 21, 2024

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented May 19, 2024

This is mostly a shorter version of uv run that infers a requirement name from the command. The main goal here is to do the smallest amount of work necessary to get #3560 started.

Closes #3613

e.g.

$ uv tool run -- ruff check
warning: `uv tool run` is experimental and may change without warning.
Resolved 1 package in 34ms
Installed 1 package in 2ms
 + ruff==0.4.4
error: Failed to parse example.py:1:5: Expected an expression
example.py:1:5: E999 SyntaxError: Expected an expression
Found 1 error.

@zanieb zanieb added the preview Experimental behavior label May 19, 2024
@zanieb zanieb force-pushed the zb/tool-run branch 2 times, most recently from 92dd1dd to 68e4a18 Compare May 19, 2024 14:31
uv_virtualenv::Prompt::None,
false,
false,
)?;
Copy link
Member

Choose a reason for hiding this comment

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

Ultimately, will these be installed in some sort of global directory that's also exposed on PATH, either by adding at install time or via some kind of ensurepath?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see this in #3560 now. If the tool is already installed in the user environment, it will be used, but uv tool run on its own will not install the tool. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah uv tool run will not install a tool. It could cache the environment and will support detecting user-installed and project-level tools but we don't have those yet here. I've already started a branch for uv tool install — it's just much more complex as a starting point.

zanieb added a commit that referenced this pull request May 20, 2024
Prompted by
#3657 (comment)

There's still some level of discomfort here, as the `tool` module needs
needs to import the `project` module to manage an environment. We should
probably move most of the basic operations in the `project` module root
into some sort of shared module for behind the scenes operations?

Regardless, this change should simplify that future move.
@zanieb zanieb marked this pull request as ready for review May 21, 2024 15:23
@zanieb zanieb force-pushed the zb/tool-run branch 2 times, most recently from 32ae0db to fdcab26 Compare May 21, 2024 17:28
# Conflicts:
#	crates/uv/src/commands/mod.rs
#	crates/uv/src/commands/project/run.rs

# Conflicts:
#	crates/uv/src/commands/project/mod.rs
@zanieb zanieb enabled auto-merge (squash) May 21, 2024 19:25
@zanieb zanieb merged commit d313d9b into main May 21, 2024
45 checks passed
@zanieb zanieb deleted the zb/tool-run branch May 21, 2024 19:51
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.

uv-tool: Implement uv tool run
2 participants