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

Respect tool upgrades in uv tool install #4736

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

For now the semantics are such that if the requested requirements from the command line don't match the receipt (or if any --reinstall or --upgrade is requested), we proceed with an install, passing the --reinstall and --upgrade to the underlying Python environment.

This may lead to some unintuitive behaviors, but it's simplest for now. For example:

  • uv tool install black<24 followed by uv tool install black --upgrade will install the latest version of black, removing the <24 constraint.
  • uv tool install black --with black-plugin followed by uv tool install black will remove black-plugin.

Closes #4659.

@charliermarsh charliermarsh changed the title Respect tool upgrades in uv tool install Respect tool upgrades in uv tool install Jul 2, 2024
@charliermarsh charliermarsh requested a review from zanieb July 2, 2024 19:15

----- stderr -----
warning: `uv tool install` is experimental and may change without warning.
Installed: black, blackd
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a behavior change but I personally think it's ok to copy over the entrypoints even on a no-op. I could probably figure out a way to avoid this as an optimization though.

Copy link
Member

Choose a reason for hiding this comment

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

I agree it's "okay" but it feels a little weird to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's safer and simpler to copy them over every time, avoids any weird issues around trying to detect if the package changed in the environment or the entrypoints getting out-of-sync with the environment.

let environment = installed_tools.environment(
&name,
// Do not remove the existing environment if we're reinstalling a subset of packages
!matches!(settings.reinstall, Reinstall::Packages(_)),
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems ok to me to only remove this when --force is provided?

Copy link
Member Author

Choose a reason for hiding this comment

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

In other words: can't we defer to our underlying virtualenv update machinery to manage this by reinstalling packages as required?

Copy link
Member

Choose a reason for hiding this comment

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

That seems okay, yeah.

@charliermarsh
Copy link
Member Author

Don't understand the dreaded Windows failures yet but I'll look at them once approved.

interpreter,
cache,
)?;
let environment = installed_tools.environment(&name, force, interpreter, cache)?;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think force needs to imply deletion of the environment though? This seems a little weird. I think we should only remove the existing environment if the requested Python interpreter is different.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can do that… I feel like force is sorta useful too personally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Force would be like: completely ignore whatever already exists.

Copy link
Member

Choose a reason for hiding this comment

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

Hm. It feels weird to mix the purpose for me. I agree removing the environment sounds useful but in what case would someone actually need to do that?

Copy link
Member

Choose a reason for hiding this comment

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

(it seems safe to discuss and address this separately from this pull request)

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess if the environment was broken and the receipt was out-of-sync, even uninstall wouldn't remove it...? Maybe I'll change uninstall to handle that edge case, then remove this.

Copy link
Member

Choose a reason for hiding this comment

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

If the environment is broken then --force totally could / should remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe: if there's no receipt, and the environment exists, we remove it? :)

@zanieb zanieb added the preview Experimental behavior label Jul 2, 2024
@charliermarsh charliermarsh merged commit 32dc9be into main Jul 2, 2024
47 checks passed
@charliermarsh charliermarsh deleted the charlie/tool-upgrade branch July 2, 2024 20:46
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 install should respect upgrades
2 participants