pipx icon indicating copy to clipboard operation
pipx copied to clipboard

pipx upgrade with a specificier

Open uranusjr opened this issue 5 years ago • 9 comments

How would this feature be useful?

Since 0.15 pipx got rid of the --spec argument, but now I can’t upgrade a package to a difference spec. Previously I could

pipx install virtualenv

# Some time later…
pipx upgrade virtualenv --spec "virtualenv>=30.0b2"
pipx upgrade virtualenv --spec "git+https://github.com/pypa/virtualenv.git"

Describe the solution you'd like

Either add back the --spec argument for upgrade, or allow e.g.

# Current fails with "Package cannot be a url"
pipx upgrade "git+https://github.com/pypa/virtualenv.git"

# Current fails with "FileNotFoundError"
pipx upgrade "virtualenv>=30.0b2"

uranusjr avatar Feb 06 '20 13:02 uranusjr

Just to check, will the workaround work: pipx uninstall followed by pipx install ? Or is there a reason (besides extra typing) that that's worse?

itsayellow avatar Feb 06 '20 19:02 itsayellow

Another idea, #256 could replace this functionality.

itsayellow avatar Feb 06 '20 19:02 itsayellow

I’d assume upgrade to keep injected packages. reinstall makes sense as well.

uranusjr avatar Feb 07 '20 01:02 uranusjr

Ah yes, preserving injected packages, that makes sense with upgrade.

In general I think we need to look at the options for upgrade (and reinstall if it is created separate from reinstall-all). It would be nice to have the options for these commands only supersede the existing metadata if they are present, and otherwise the existing metadata in the venv would be used. I don't think that's currently how they're set up.

itsayellow avatar Feb 07 '20 06:02 itsayellow

Just to check, will the workaround work: pipx uninstall followed by pipx install ? Or is there a reason (besides extra typing) that that's worse?

If one is trying to automate, i.e. have a script that ensures a specific rev of something is installed, then it is a bit of work to find the right pipx_metadata.json file and find the right field and see if the uninstall/install sequence is needed.

morrison12 avatar May 05 '20 03:05 morrison12

I wonder if this would be worth a different pipx subcommand, like possibly modify.

itsayellow avatar May 29 '20 22:05 itsayellow

While uninstall and install in principle do the job, it might take quite some time if you have many large dependencies. I would prefer to reuse as much as possible from the existing installation.

pohlt avatar Jun 17 '21 07:06 pohlt

I use the following as a workaround to downgrade/upgrade as required, e.g.:

$ pipx inject poetry poetry==1.2.2

ngnpope avatar Jan 20 '23 12:01 ngnpope

I would be also expecting that the same spec as in pip is supported.

The fact that we use pip to install packages is an implementation detail, so I don't want --upgrade flag. But happy to fix original issue.

sumkincpp avatar Jul 07 '23 13:07 sumkincpp