BUG: pipx upgrade doesn't understand extra dependencies
Describe the bug
This works correctly
pipx install "mycli[extras]"
but this doesn't
pipx install "mycli[extras]"
pipx upgrade "mycli[extras]"
and it fails with
Package is not installed. Expected to find /path/to/pipx/venvs/mycli[isolated], but it does not exist.
How to reproduce For reproduction, I suggest
pipx install "coverage[toml]"
pipx upgrade "coverage[toml]"
Expected behavior
I'm not 100% sure what should happen actually, but the current error message seems broken (of course a directory with [ and ] in its name wasn't found).
I think the upgrade should go through wether or not the extra targets match the ones I used (or didn't use) the first time I installed the CLI (here coverage).
I'd be happy to contribute a patch, but I'd appreciate some guidance regarding what the expected behaviour should be.
You can simply run pipx upgrade mycli and you don't need to pass extra dependencies since it's installed. But I think we can improve the error message to make it more clearly.
Does pipx upgrade mycli upgrade dependencies that are only pulled in by the extra? I’m under the impression it only tries to upgrade the specified package (i.e. mycli here); if so we would actually need to add some additional logic for the extra-ed case.
Does pipx upgrade mycli upgrade dependencies that are only pulled in by the extra?
Not really, unless --pip-args='--upgrade-strategy eager' is passed. This is probably related to #254.
Even if we change the strategy, dependencies in the extra would still not be upgraded (because from pip’s perspective those packages are unrelated unless you pass in the extra). So for now pipx upgrade does not have a difference in behaviour whether you pass in the extra or not, but would if we change the default upgrade strategy. I’d say the current behaviour is OK (barring a better error message), but we should probably change the strategy (or have a flag to control it), which would requite us to also fix how extras are passed to upgrade.
PR welcome.
[...] which would requite us to also fix how extras are passed to
upgrade.
This might've been fixed since? It looks like if I pipx install nox[uv] then pipx upgrade nox correctly issues pip --no-input install --upgrade nox[uv]. Therefore, the only change required is to pass --upgrade-strategy=eager.
What should pipx do if the main app's version didn't change? Should it still upgrade dependencies?
(IMO it should. This will let users benefit from bugfixes and security updates to the app's dependency tree. It will also help with the more exotic case of nox[uv] where uv has a much faster release cycle than Nox.)