pipx
pipx copied to clipboard
pipx installation should implicitly be "aware" of `$PIPX_HOME/$PIPX_BIN_DIR` values
How would this feature be useful?
Two background details:
-
I keep my pipx repos outside of
~/.local/pipx
, so I have to have the envariables$PIPX_HOME
and$PIPX_BIN_DIR
set to/home/user/code/pipx
and/home/user/code/pipx/bin
(or whatever). -
note above that I keep my
$PIPX_BIN_DIR
inside$PIPX_HOME
, many folks do this -
I use
pipx
to manage itself, so my repo containspipx
in$PIPX_BIN_DIR
The problem: Once $PIPX_BIN_DIR
is added to my path, I can run all the binaries in my repo, with the exception of pipx
itself. If I ever need to call pipx
on my repository for upgrade/installs, I need to set these envariables again.
Describe the solution you'd like
It would be great if pipx
can "cache" or else store these values inside the repo itself, such that I can call pipx
and have it do the right thing.
This is roughly analogous to how pip
itself works:
$ python -m venv /home/user/code/venv
$ /home/user/code/venv/bin/pip install pycowsay
$ /home/user/code/venv/bin/pycowsay
Notice above that I didn't need to set any environment varaibles. When calling pip
and pycowsay
from the command line, they implicitly understood that their libraries were in /home/user/code/venv/lib/python3.x/site-packages
and did the right thing in finding them. pipx
should work the same way.
Describe alternatives you've considered
I can set $PIPX_HOME
and $PIPX_BIN_DIR
in my shell's rc file as needed, so this is not a terribly big deal, but having the values cached, allows me to move my pipx
repository around anywhere without updating the envariables all the time.
It would be great if
pipx
can "cache" or else store these values inside the repo itself, such that I can callpipx
and have it do the right thing.This is roughly analogous to how
pip
itself works:$ python -m venv /home/user/code/venv $ /home/user/code/venv/bin/pip install pycowsay $ /home/user/code/venv/bin/pycowsay
I’m confused. pip does not cache or whatever anything in the repo; in this example, you created a virtual environment and run pip of it; this is not different from setting the PIPX_*
environment variables, except that the virtual environment sets those automatically for you. So is the request for pipx to create some sort of “virtual pipx container” that automatically “chroot” (sort of) there the apps are installed?
Also note that virtual environments are a part of pip, but two entirely different projects.
I think I confused things with my inital report. Let me show you what I am doing:
# create temp venv
/usr/local/bin/python -m venv /home/user/foo/venv
# install temp pipx
/home/user/foo/venv/bin/pip install pipx
# set appropriate environment variables
export 'PIPX_HOME=/home/user/foo/pipx'
export 'PIPX_BIN_DIR=/home/user/foo/pipx/bin'
export 'PIPX_DEFAULT_PYTHON=/usr/local/bin/python'
# install main pipx into $PIPX_HOME, using $PIPX_BIN_DIR as the binary directory
/home/user/foo/venv/bin/pipx install pipx
# update main pipx to use primary $PIPX_DEFAULT_PYTHON
# (and not depend on temp pipx)
/home/user/foo/pipx/bin/pipx reinstall-all
# now we can install programs into our main pipx repo using its own pipx
/home/user/foo/pipx/bin/pipx install pycowsay
# delete temp venv
rm -rf /home/user/foo/venv
Now we can run /home/user/foo/pipx/bin/pycowsay
or any other pipx
installed program by calling it with the full path.
And because $PIPX_HOME
, $PIPX_BIN_DIR
, an $PIPX_DEFAULT_PYTHON
are set, we just need to call /home/user/foo/pipx/bin/pipx
to install/upgrade other programs, including pipx
itself.
[...]
Some time passes and I open up a new shell. /home/user/foo/pipx/bin/pycowsay
and all installed programs still
work, BUT (and this is the part I'd like to change): /home/user/foo/pipx/bin/pipx
does not work, because the above
envariables are not set.
We need to set the following to make it work again:
export 'PIPX_HOME=/home/user/foo/pipx'
export 'PIPX_BIN_DIR=/home/user/foo/pipx/bin'
export 'PIPX_DEFAULT_PYTHON=/usr/local/bin/python'
My request: make the pipx repo (/home/user/foo/pipx
), be "aware" of the above environment variables such that once they are created/set, you never have to set them again. Calling /home/user/foo/pipx/bin/pipx
will do the right thing and it will "understand" you want to install things into `/home/user/foo/pipx'.
I think it’s the term “repo” that’s confusing me. For me “pipx installation” is a better word. But I get your point.
I think it’s the term “repo” that’s confusing me. For me “pipx installation” is a better word. But I get your point.
Gotcha. I updated the title of the bug to reflect the proper nomenclature.
PR welcome.