pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Allow to install multiple packages

Open schlamar opened this issue 6 years ago • 13 comments
trafficstars

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.

schlamar avatar Feb 07 '19 09:02 schlamar

Instead of using inject ... it would be much nicer just to pass --spec multiple 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.

taketwo avatar Feb 07 '19 09:02 taketwo

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.

schlamar avatar Feb 07 '19 10:02 schlamar

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.

schlamar avatar Feb 07 '19 10:02 schlamar

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 --spec options, 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 --spec does 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.

taketwo avatar Feb 07 '19 10:02 taketwo

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"

schlamar avatar Feb 07 '19 10:02 schlamar

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.

schlamar avatar Feb 07 '19 10:02 schlamar

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 :)

schlamar avatar Feb 07 '19 11:02 schlamar

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.

cu avatar Mar 19 '19 18:03 cu

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

cs01 avatar Mar 19 '19 19:03 cs01

Just used pipx inject to install flake8 along with plugins and have to say it was quite easy to follow.

kornicameister avatar Jan 04 '22 23:01 kornicameister

works great! thanks

pipx install rasterio --python python3.9
pipx inject rasterio rio-cogeo

chapmanjacobd avatar Feb 09 '22 23:02 chapmanjacobd

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 avatar Mar 03 '22 06:03 fredrikaverpil

@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.

schlamar avatar Mar 03 '22 10:03 schlamar

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.

exhuma avatar Mar 24 '23 11:03 exhuma

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: @.***>

guiillermo avatar Mar 24 '23 11:03 guiillermo

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!

justinmayer avatar Mar 24 '23 12:03 justinmayer

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?

elupus avatar Oct 11 '23 10:10 elupus

PR welcome.

gaborbernat avatar Dec 02 '23 17:12 gaborbernat

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?

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

oricou avatar Jan 12 '24 16:01 oricou

This feature was added in https://github.com/pypa/pipx/pull/1102.

dukecat0 avatar Jan 20 '24 17:01 dukecat0