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

Introduce pipx pin and pipx unpin commands #1291

Merged
merged 28 commits into from
May 24, 2024
Merged

Conversation

dukecat0
Copy link
Member

@dukecat0 dukecat0 commented Mar 17, 2024

  • I have added a news fragment under changelog.d/ (if the patch affects the end users)

Summary of changes

Introduce pipx pin and pipx unpin commands, which can be used to pin or unpin the version
of an installed package, so it will not be upgraded by pipx upgrade or pipx upgrade-all.

Closes #891
Closes #802

Test plan

Tested by running

nox -s tests-3.12

@dukecat0 dukecat0 marked this pull request as ready for review March 17, 2024 08:44
Copy link
Contributor

@chrysle chrysle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! I wonder whether it would be a valid use case to extend this behaviour to work with injected packages, too?

Another idea: Provide protection from removal for a pipx-installed package by pipx pin via an option.

src/pipx/commands/pin.py Outdated Show resolved Hide resolved
src/pipx/commands/pin.py Outdated Show resolved Hide resolved
@dukecat0
Copy link
Member Author

I wonder whether it would be a valid use case to extend this behaviour to work with injected packages, too?

That sounds like a good idea! Probably I will add a new option for it.

Another idea: Provide protection from removal for a pipx-installed package by pipx pin via an option.

Not sure if it's a common usage, but we can add it in the future if there are requests about this.

@dukecat0
Copy link
Member Author

I wonder whether it would be a valid use case to extend this behaviour to work with injected packages, too?

I am implementing the logic of --injected-packages-only and it will only pin injected packages only instead of main package. (As running pipx pin <package> should prevent both main package and injected packages from upgrading during pipx upgrade-all --include-injected.)

@chrysle
Copy link
Contributor

chrysle commented Mar 23, 2024

I am implementing the logic of --injected-packages-only and it will only pin injected packages only instead of main package.

Sounds good. You don't think one should be able to select which injected package to work with?

@dukecat0
Copy link
Member Author

Yes, forgot to mention it in the above comment. 😅 I will mark this PR as draft first.

@dukecat0 dukecat0 marked this pull request as draft March 23, 2024 09:26
@dukecat0 dukecat0 marked this pull request as ready for review May 21, 2024 10:37
@dukecat0 dukecat0 marked this pull request as draft May 21, 2024 10:38
@dukecat0 dukecat0 marked this pull request as ready for review May 21, 2024 10:57
@dukecat0 dukecat0 requested review from uranusjr and chrysle May 21, 2024 11:10
src/pipx/commands/pin.py Outdated Show resolved Hide resolved
src/pipx/commands/pin.py Show resolved Hide resolved
src/pipx/main.py Outdated Show resolved Hide resolved
src/pipx/main.py Outdated Show resolved Hide resolved
src/pipx/commands/pin.py Outdated Show resolved Hide resolved
src/pipx/commands/upgrade.py Outdated Show resolved Hide resolved
src/pipx/main.py Outdated Show resolved Hide resolved
tests/test_pin.py Outdated Show resolved Hide resolved
@dukecat0 dukecat0 requested a review from chrysle May 22, 2024 01:28
@dukecat0
Copy link
Member Author

The failed test seems unrelated to this PR.

@huxuan
Copy link
Member

huxuan commented May 22, 2024

The failed test seems unrelated to this PR.

Rerun makes everything OK. :-)

@gaborbernat gaborbernat merged commit 543af21 into pypa:main May 24, 2024
11 checks passed
@dukecat0 dukecat0 deleted the pin branch May 24, 2024 10:46
@kpfleming
Copy link

This feature was included in the 1.6.0 release but the documentation appears to be incomplete. When I run pipx --help then 'pin' and 'unpin' are included in the command list but don't have descriptions:

subcommands:
  Get help for commands with pipx COMMAND --help

  {install,install-all,uninject,inject,pin,unpin,upgrade,upgrade-all,upgrade-shared,uninstall,uninstall-all,reinstall,reinstall-all,list,interpreter,run,runpip,ensurepath,environment,completions}
    install             Install a package
    install-all         Install all packages
    uninject            Uninstall injected packages from an existing Virtual Environment
    inject              Install packages into an existing Virtual Environment
    upgrade             Upgrade a package
    upgrade-all         Upgrade all packages. Runs `pip install -U <pkgname>` for each package.
    upgrade-shared      Upgrade shared libraries.
    uninstall           Uninstall a package
    uninstall-all       Uninstall all packages
    reinstall           Reinstall a package
    reinstall-all       Reinstall all packages
    list                List installed packages
    interpreter         Interact with interpreters managed by pipx
    run                 Download the latest version of a package to a temporary virtual environment, then run an app from it. Also compatible with local `__pypackages__` directory (experimental).
    runpip              Run pip in an existing pipx-managed Virtual Environment
    ensurepath          Ensure directories necessary for pipx operation are in your PATH environment variable.
    environment         Print a list of environment variables and paths used by pipx.
    completions         Print instructions on enabling shell completions for pipx

They also don't appear in the online docs at https://pipx.pypa.io/stable/docs/ except (again) in the list of subcommands, but without descriptions of their behavior or entries in the table of contents.

@dukecat0
Copy link
Member Author

This was fixed in #1438.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants