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

Proposal: Add --upgrade argument for install command #1458

Closed
wants to merge 1 commit into from

Conversation

jdknight
Copy link

  • I have added a news fragment under 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:

pip install -U example

Now trying to promote the use of pipx over pip, this does not seem to be possible in a single command unless using the --force argument:

pipx install --force example

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 and pipx 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:

pipx install black==22.8.0
pipx install black
pipx install --upgrade black
Example output
(venv) [jdknight@devel venv]$ pipx install black==22.8.0
  installed package black 22.8.0, installed using Python 3.12.4
  These apps are now globally available
    - black
    - blackd
done!
(venv) [jdknight@devel venv]$ pipx install black
'black' already seems to be installed. Not modifying existing installation in '.../.local/share/pipx/venvs/black'. Pass '--force' to
force installation.
(venv) [jdknight@devel venv]$ pipx install --upgrade black
  installed package black 24.4.2, installed using Python 3.12.4
  These apps are now globally available
    - black
    - blackd
done!

When installing a package, both `pip install` and `pipx 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.

Signed-off-by: James Knight <[email protected]>
@jdknight jdknight force-pushed the add-install-upgrade-option branch from d8c7a1e to 59cdf74 Compare June 23, 2024 23:51
@chrysle
Copy link
Contributor

chrysle commented Jun 24, 2024

Thanks, but this has already been proposed once (#953) and we agreed elsewhere on an --install option to the --upgrade command.

@jdknight jdknight closed this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants