Wandering Thoughts archives


Using pipx in a PyPy installation more or less just works

I've decided that going forward I pretty much want to manage any third party Python programs I install, like the Python LSP server and pxpx, through pipx (as an extension of managing them in virtual environments). I've also experimented with installing PyPy myself. One of the advantages of using my own PyPy on our Ubuntu servers is that our Ubuntu servers run various versions of Ubuntu LTS, and so I would normally run into the pip Python version issue if I relied on the system Python. All of this (plus how pipx isn't packaged for Ubuntu 18.04) got me to wondering if pipx worked in PyPy. The answer is yes.

As you'd expect, you use the PyPy install's version of pip to install pipx, which winds up in the PyPy bin/ directory. When you run it, it creates and operates on your .local/pipx/venvs hierarchy and (still) puts links to the programs from installed packages into your .local/bin, instead of putting them in PyPy's bin/ directory. The installed packages do use your PyPy, not the system (C)Python, as you'd sort of expect. Running the pipx installed programs just works.

In a quick test, installing a (C)Python based package with the PyPy pipx works with 'pipx install --python ...'. Pipx lists the resulting venv as using the system version of Python, and the symlinks and so on in the venv point in the right place. This sort of thing may be necessary if you have some things (such as mypy) that don't really work under PyPy. Without testing it, I suspect that you can use several copies of pipx on the same pipx venv tree, so you can manage your CPython pipx things with the CPython pipx and the PyPy pipx things with your PyPy pipx.

Although I haven't gone through the exercise yet, I expect that the process of upgrading my version of PyPy will be to install the new PyPy, install pipx in the new PyPy version, and then run 'pipx reinstall-all' using the new pipx (or perhaps I will have to selectively reinstall only the venvs that are using PyPy). It's possible that there's a better way, since pipx's reinstall-all feels a bit brute force. On the other hand, there are probably a lot of bits of the pipx-created virtual environment that would have to be shuffled around to do it any other way, and pipx mostly makes it simple at the command level.

(I haven't tested 'pipx reinstall' on my Python LSP server venv, where I inject some extra optional packages on top of the LSP server package and its install options. It would be ideal if pipx reinjects those extra packages, but I'm not sure if it captures enough information in its metadata to do that.)

python/PyPyAndPipx written at 23:22:13; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.