-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip install from stdin #7822
Comments
Strong -1 on the I can see the value of @pypa/pip-committers Is anyone actively against this new feature? I don't want to suggest that someone should go to the effort of writing a PR if it's just going to get rejected. I've marked the request as "deferred till PR" - I doubt there's much more to discuss until there's actual code to base a discussion on. |
Also -1 on the Concerning |
From personal experience working with other software, a common practice is to accept stdin separated by EOF ( |
Also −1 on |
I think, if this is added, @xavfernandez thank you for pointing out that potential complication. I didn't even know constraints files existed until reading your comment. 🙂 |
Just to be a POSIX defender: I don't think we'd enjoy a world quite as much where we routinely had to write That said, I don't need to debate the philosophy, it would just be nice if we had something in |
Added more labels, to clarify state.
Not me. As far as I can tell:
|
Personally, I'd just say it's not allowed. It's extremely non-obvious what the best approach is, and it's a pretty obscure corner case. I'd actually be perfectly happy to just call YAGNI on |
An alternative that works today (example with pip install $(curl https://foo.com/requirements.txt) |
@sbidoul I think your workaround is probably less desirable than the The mental exercise of knowing the different consequences of those two variants, for which versions of which shells, is why I think being able to read from (details:) If you're using a reasonably modern version of Although the above talks about security concerns, shell interpolation can also cause insidious bugs in your workflow if you're not really careful, so I'd just recommend avoiding it when it's not needed. |
@kenahoo sure, your arguments about the risk of shell interpolation are valid. I was not meaning to dismiss the feature request :)
Regarding this specific point, note pip does recognize a number of options inside requirements files, so this risk would still exist when reading requirements from stdin. |
Oh, I didn't realize that! Thanks for pointing it out, will probably be useful someday. |
Yes, I realized this would be handy if you want to use My current workaround is:
|
Have another solution using xargs (filters all packages with letter "a"):
|
I've using something like this for installing the netbox requirements.txt but it recently start to fail cause of the newly added comment char isn't recognized as as a pip package (but included as argument). So it would be saver to rely on pip's requirements.txt parsing instead appending to the arguments. |
My use case for this is trying to install my requirements inside a remote Docker container: cat requirements.txt | docker exec -i my-container pip install -r - But alas 🙁 Seems I'll have to copy them to a temporary file in the container. |
I think I found elegant solution, which works in Dockerfile RUN statement and correctly handling error in pipe (because |
@bashlakov that's the same solution @mitar pointed out as a workaround. It has the same problem as several other solutions, which is that it depends on a specific OS (e.g. It's a good workaround if you don't need it to work on other systems besides the one you wrote it for, though. |
I see that an existing ticket has been rejected: #3880 . I'm requesting that the team reconsider.
The main use case I have for this feature is to build an environment using a set of requirements specified in a URL or coming from a specific
git
commit:There are workarounds, e.g. to leverage some shell feature for running a subprocess (e.g.
pip install -r <(curl https://foo.com/requirements.txt)
or similar) or download the file in advance to some temporary location, but these are more esoteric, shell-dependent, or require extra cleanup steps. I believe the cleanest solution for the user is simply to behave like a standard command-line tool and usestdin
/stdout
in the normal ways.In the spirit of conforming even better to standard POSIX style, I'd further recommend that the
-
be unnecessary, e.g. if no file argument is given for-r
that input be taken fromstdin
, just like other input-consuming tools likecat
,cut
,less
,python
etc. do:Thanks for considering.
The text was updated successfully, but these errors were encountered: