Pipx's 'reinstall' command works right by reinstalling injected packages too
pipx is a good way to
manage virtual environments for third party Python programs installed
through PyPy, it necessarily still has some of the general issues
with upgrading programs with
pipx, though, the theoretically obvious solution to this is that
pipx upgrade' isn't making you happy any more, you can use
pipx reinstall' to redo everything from scratch. However, one of
my questions about pipx reinstall has always been if it would deal
with a virtual environment, such as one for the Python LSP server, that also contains
additional packages injected later.
(In the case of the Python LSP server, there are third party plugins. As far as I know you can only install these by injecting them into the LSP server virtual environment after the fact.)
Today, in a spirit of experimentation, I did a '
python-lsp-server', after saving the actual Pip package list. To
my happy surprise, pipx also reinstalled the extra injected packages
for the third party plugins I want, and the only difference in the
package lists is unimportant (at some point
toml apparently stopped
being part of someone's requirements). This means that having pipx
reinstall things is generally going to be a reliable way of recreating
a program's virtual environment with whatever package dependencies
(and their versions) you 'should' have.
(For a version of 'should' that is 'what a person doing this from scratch would get today'. If you want to give someone an exact clone of your known to work virtual environment for a program, you need something else.)
This makes me happy, for obvious reasons. I do wish that the help
documentation for '
pipx reinstall' actually said this explicitly,
because the current phrasing silently implies that it doesn't also
reinstall additional injected packages.
(The reinstall documentation says that the package is installed with
pipx install ...'. A '
pipx install' obviously only installs the
original package; it doesn't magically add any additional injected
packages. Pipx is clearly doing something more than a plain install
here, which is good, but it would also be good if it was documented.)