uv icon indicating copy to clipboard operation
uv copied to clipboard

`uv pip install -U somepkg` should only update the specified package, unless additional upgrades are necessary

Open ThiefMaster opened this issue 1 year ago • 3 comments

Classic pip did the same until a few years ago where they changed the default to --upgrade-strategy only-if-needed for which uv currently does not have an equivalent. The only way to get this behavior is uv pip install -P somepkg somepkg which is a bit ugly since I need to specify the package name twice.

I think this behavior would be more desirable than "upgrade everything" because:

  • In most proper production deployments you have lock files anyway and will not use uv pip install -U at all
  • If you have some extra packages in such an environment, you do NOT want updating that package to also update some random dependency (that's actually specified in another package's lock file)
  • In a development environment, I guess it's a matter of preference

My suggestion would be to:

  • Change the default to match --upgrade-strategy only-if-needed (or at least implement this option)
  • Display a notice if any (direct?) dependencies of the specified package could also be updated (maybe only if this does not conflict with version pins of already-installed packages?)

ThiefMaster avatar Jul 03 '24 15:07 ThiefMaster

Sounds like you're just looking for --upgrade-package? Why is it a big deal to specify the name twice? Isn't it harder for users to do uv pip install <package> --upgrade --upgrade-strategy eager to update their environment? I've been bitten by this surprising behavior in pip several times in CI.

zanieb avatar Jul 03 '24 16:07 zanieb

I'm not particularly opposed to --upgrade applying to all of the "given packages" if we can find a nice way to specify upgrading the environment. I guess --upgrade-strategy isn't bad.

zanieb avatar Jul 03 '24 16:07 zanieb

Related https://github.com/astral-sh/uv/issues/7176

zanieb avatar Oct 21 '24 21:10 zanieb

Also related: #10097

jph00 avatar Dec 28 '24 22:12 jph00