Proposal: Add --upgrade
argument for install command
#1458
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
changelog.d/
(if the patch affects the end users)Proposal
The following is a proposal to support an upgrade option with pipx's install command. A practice I use for documenting various Python-based utilities is to have an installation section which has a single command to either install or upgrade a package:
Now trying to promote the use of
pipx
overpip
, this does not seem to be possible in a single command unless using the--force
argument:Using the "force" argument does not feel right, and the intention is not to have packages be re-installed if they are already in a good/upgraded state. Alternatively, I could update documentation to have two paragraphs to identify a method to install and a method to upgrade, but I would rather promote a single command that could do both.
Summary of changes
When installing a package, both
pip install
andpipx install
allow a new package to be installed. If a target package is already installed, no changes are made. Both pip and pipx also support a forced reinstall using--force-reinstall
and--force
respectively. Another popular installation more for pip is using the--upgrade
option, which will only perform a package change if a new version is detected. Such a request is not possible in pipx.This commit adds support for an upgrade method by adding the
--upgrade
option and forwarding it to pip when a package has been detected as already installed.Test plan
Tested by provided unit tests and running:
Example output