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

[WIP] Add a --suffix option to uv tool install #7095

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

teofr
Copy link

@teofr teofr commented Sep 5, 2024

Summary

Ongoing attempt to close #6365

So far:

  • Added the CLI argument and general setting
  • Modified the tools enviroments and receipts to work with a suffix
    • Right now the design stores tools in the directory {name}{suffix}
  • Made the uv tool install command thread and process suffixes

TODO:

  • Add support for upgrade, uninstall
  • Normalize suffixes (right now they're taken verbatim and not according the rules specified in the RFC RFC: Tool management #3560)
  • Modify the representation of ToolName after discussions
  • Improve testing
    • Colliding tools (Packagea A and A_B can collide if A is installed with suffix _B)
    • Preliminary discussions point towards requiring uniqueness of {package name}{suffix} as an id, we need to test that

Test Plan

For now, tests that the same package can be installed with different suffixes

#[derive(Debug, Clone)]
pub struct ToolName {
pub name: PackageName,
pub suffix: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

This may be a problematic structure for uv tool upgrade etc., e.g., if the user specifies a tool name via the command line we won't know what's the package name and what's a suffix until sometime later?

Copy link
Author

Choose a reason for hiding this comment

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

Agree, thanks for pointing it out

let environment_path = self.tool_dir(name);

debug!(
"Deleting environment for tool `{name}` at {}",
"Deleting environment for tool `{}` at {}",
name.name,
Copy link
Member

Choose a reason for hiding this comment

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

We'll generally probably want to see the both the name and suffix that we're performing operations on.

Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit curious why you did this instead of implementing Display for ToolName

Copy link
Author

Choose a reason for hiding this comment

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

Yes, didn't change to showing the whole tool name to simplify for now.
Of course, I complicated myself by not implementing Display, I blame my late little use of Rust, will change to that

Copy link
Author

Choose a reason for hiding this comment

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

I added a TODO for changing how ToolNames are displayed, since it needs discussion

Comment on lines 113 to 115
if let Some(suffix) = suffix {
file_name.push(suffix);
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this handle file extensions on Windows?

Copy link
Author

Choose a reason for hiding this comment

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

Added the suffix between the stem and the extension, thanks for noticing

More thought and testing is needed for this bit (as in, what happens with tools that have a . in their name)

Comment on lines +248 to +249
[tool]
requirements = [{ name = "black" }]
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to write the tool package name somewhere now?

Copy link
Author

Choose a reason for hiding this comment

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

That's a good question, I think it depends a bit on what's the point of the receipt

If the goal is to differentiate package installations, I think not, since a package should behave exactly the same if it was installed with a given suffix or not. (ie, could we want to have a cache of package installations? if so, are the receipts the keys of the cache?)

However, if the receipt is just general information used by uv then yes, specially since upgrading a package may add entry points, and we may need to use the suffix there.

I lean towards adding it

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I presumed we would need the package name during future operations, e.g. during uv tool upgrade to retrieve the entry points for the package as you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a --suffix option to uv tool install
2 participants