pipx
pipx copied to clipboard
Allow to install multiple packages
Edit Adjusted the title because there is another proposal not related to --spec option in https://github.com/pipxproject/pipx/issues/88#issuecomment-461373956
Instead of using inject to install optional dependencies or plugins, it would be much nicer just to pass --spec multiple times, e.g. pipx install flake8 --spec "flake8" --spec "flake8-print".
This makes inject obsolete and you should deprecate it. Instead of inject you should use upgrade with specs.
So in combination with #87 this gives you a very nice way to port your pipx venvs to another PC. Just copy your pipx config file and run reinstall-all. This would also fix #63.
This would somehow give a solution for #83, too. Instead of having a venv for every cmd he could install multiple commands in one "grouped" venv.
Instead of using
inject... it would be much nicer just to pass--specmultiple times
I don't see how this is much nicer. This is convoluted, not discoverable, and unintuitive, especially for novice users. This was the reason why inject was added in the first place.
This gives you reproducible environments and would allow you to install binaries from multiple packages. IMO these are two major benefits.
Actually you could make inject still works by internally handle this as just updating the specs.
BTW, you are missing your arguments when you buzzword my proposal as "convoluted, not discoverable, and unintuitive". Please do not push back interested contributors by not having a professional technical debate.
This would also solve #79.
And in combination with #87 you can solve #67 by updating the spec and reinstall.
@schinckel You might be interested in this proposal as it should handle all your use cases.
Please note that my answer concerns only your "much nicer" statement. That was not exactly a technical argument, hence neither is my response. I simply offered a (novice) user perspective on the inject command and the alternative you proposed. That said, I can elaborate on the buzzwords I used (although I believe the meaning is clear anyway):
- Convoluted: multiple
--specoptions, repeating the name of the "main" package twice, quotes; - Not discoverable: a new user wants to add a plugin package to existing package. They call
pipx --help, but there is no obvious command that can do that; - Unintuitive: without reading up what
--specdoes it's hard to understand the command you posted.
For the record, I do not care at all how inject is implemented behind the scenes. Fine for me if it's using specs, as long as I don't need to figure out that command you posted every time I want to inject a plugin.
Maybe better: allow packages separated by whitespace in spec so this would be equal to pip install and pipx inject:
pipx install flake8 --spec "flake8 flake8-print"
BTW, the real problem here is that the main API entry pipx install [package] is assuming that package==venv which is not always the case (e.g. when installing something completely unrelated with --spec). This is somehow a leaky abstraction.
However I'm not sure if "fixing" the main API is an option. IMO more correct would be something like:
pipx install flake8 --venv test # instead of pipx install test --spec flake8
pipx install flake8 flake8-print # installs everything in flake8 venv
pipx install flake8 flake8-print --venv test # installs everything in test venv
pipx install flake8==2.0.0 # installs in flake8 env
Actually this could be implemented in a backwards compatible way so maybe this isn't off the table.
Just one last addition (I hope): The main benefit is that you can install multiple packages at once with a single command. Doing pipx install flake8 + pipx inject flake8 flake8-print just to install two packages in a venv is not "nice".
I thought this would be obvious but as @taketwo did not react to that advantage maybe it isn't :)
I agree with everything @schlamar has said. I'm running into this because I installed ansible via pipx which has optional dependencies for certain Ansible modules. In particular, I also need to install the boto and netaddr packages into the ansible virtualenv in order to run my playbooks.
Probably out of scope for this issue (and maybe pipx as well), but it would be nice to have a flag or command that reads requirements.txt and installs everything it finds there into the virtualenv.
would be nice to have a flag or command that reads requirements.txt and installs everything it finds there into the virtualenv.
I think the pipx runpip PACKAGE PIP_COMMAND (not part of pipx at this time) would work well for this use case.
For now, the pipx inject command would probably work for you. i.e. pipx inject ansible boto netaddr
Just used pipx inject to install flake8 along with plugins and have to say it was quite easy to follow.
works great! thanks
pipx install rasterio --python python3.9
pipx inject rasterio rio-cogeo
Hi guys, before opening a separate issue, I figured I'd check here...
Instead of having a script in my dotfiles such as
pipx install 'glances[action,browser,cloud,cpuinfo,docker,export,folders,gpu,graph,ip,raid,snmp,web,wifi]'
pipx install rich-cli
pipx install bpython
...
...
...would it be possible to either use a requests.txt file or some sort of "pipxfile", to have each tool installed in its own venv?
@fredrikaverpil This should be a separate issue. There is some sort of metadata storage (https://github.com/pypa/pipx/pull/222), so this should be doable.
The main purpose of this issue is the point, that the inject API to install multiple packages is not very user friendly, not intuitive and is ignoring standards like requirements.txt.
I'm a bit confused by the discussion, likely stemming from the re-titling of this issue. I came here because I want to install multiple packages in the same way that executing pipx multiple times would do. That is, with separate virtual-envs. It seems that this issue is talking about installing multiple packages in the same venv (correct me if I'm wrong).
So for example I'd like to be able to do pipx install ansible fabric to have both executables available. This is similar to what @fredrikaverpil mentioned about a pipxfile. Although I would prefer additional arguments on the CLI than adding a new file to my repo.
Absolutely 💯 correct
On Fri, Mar 24, 2023, 5:40 AM Michel Albert @.***> wrote:
I'm a bit confused by the discussion, likely stemming from the re-titling of this issue. I came here because I want to install multiple packages in the same way that executing pipx multiple times would do. That is, with separate virtual-envs. It seems that this issue is talking about installing multiple packages in the same venv (correct me if I'm wrong).
So for example I'd like to be able to do pipx install ansible fabric to have both executables available. This is similar to what @fredrikaverpil https://github.com/fredrikaverpil mentioned about a pipxfile. Although I would prefer additional arguments on the CLI than adding a new file to my repo.
— Reply to this email directly, view it on GitHub https://github.com/pypa/pipx/issues/88#issuecomment-1482667386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI4X2QJ6KE3DZD4T42AZVIDW5WB3FANCNFSM4GU3VYAA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
As @schlamar already pointed out a year ago (and very clearly I might add), this issue has nothing to do with creating multiple virtual environments in a single pipx invocation, but rather the desire to install multiple Python packages in the same virtual environment in a single pipx invocation.
Workarounds for the former could include a for loop, such as this example in Fish shell:
for p in ansible fabric; pipx install $p; end
But still, that is entirely besides the point. Since this issue is about installing multiple Python packages in the same virtual environment in a single pipx invocation, please refrain from trying to shoehorn unrelated use cases into this issue, and instead create a new issue if you feel strongly enough about it. Thanks!
It seems pipx install package --pip-args -r requirements.txt with a requirements file listing additional packages works. But it's rather non intuitive. Or am i missing something?
PR welcome.
It seems
pipx install package --pip-args -r requirements.txtwith a requirements file listing additional packages works. But it's rather non intuitive. Or am i missing something?
Almost as simple as my version: for i in `cat requirements.txt`; do pipx install $i; done
The funny point is that an error message told me
The argument you provided (requirements.txt) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.
So I run pipx install -r requirements.txt and then
pipx: error: unrecognized arguments: -r
Grrr
This feature was added in https://github.com/pypa/pipx/pull/1102.