<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On Nov 13, 2017 6:47 PM, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>> wrote:<br type="attribution"><blockquote class="m_4754344438644535503quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_4754344438644535503quoted-text">On 14 November 2017 at 11:51, Nathaniel Smith <<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>> wrote:<br>
> What if instead of installing a standard entry point, the pip<br>
> executable was installed as<br>
><br>
> #!/bin/sh<br>
> exec python -m pip "$@"<br>
><br>
> on Unix-likes<br>
<br>
</div>It would technically be enough to make the shebang line<br>
`#!/usr/bin/env python` so the interpreter used was picked up from the<br>
environment, rather than being preconfigured at install time. However,<br>
the problem is that you don't know for certain that that python will<br>
actually have `pip` installed, so it might just fail with a cryptic<br>
error instead.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">This would still be a massive improvement over the status quo, which in this situation would present a perfect simulacrum of downloading and installing the package you asked for, except then when you start python the import still fails.</div><div dir="auto"><br></div><div dir="auto">I did think of another issue: when installing into a virtualenv, we probably want to keep the current system, so explicit/path/bin/pip continues to work as expected.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_4754344438644535503quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
However, `pip` could potentially be updated with a `checkenv`<br>
subcommand that complains if `sys.executable` and<br>
`shutil.which('python')` don't match (and could presumably include<br>
other checks as well).<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Unfortunately by the time you know to run this command to have already understood the problem and how to fix it :-). That said, this is probably cheap enough we could do it automatically at startup. Does pip know whether it's pip, pip3, etc. that invoked it? I guess sys.argv[0] should tell us?</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="m_4754344438644535503quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="m_4754344438644535503quoted-text"><br>
> and a pip.bat with the equivalent contents on Windows?<br>
> (Bonus: maybe this would fix the problem with upgrading pip on<br>
> Windows?)<br>
<br>
</div>Depending on how the batch file was written, I think the answer to<br>
that is "maybe":<br>
<a href="https://stackoverflow.com/questions/2888976/how-to-make-bat-file-delete-it-self-after-completion/20333152#20333152" rel="noreferrer" target="_blank">https://stackoverflow.com/ques<wbr>tions/2888976/how-to-make-bat-<wbr>file-delete-it-self-after-comp<wbr>letion/20333152#20333152</a><br>
<div class="m_4754344438644535503elided-text"></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Sigh.</div><div dir="auto"><br></div><div dir="auto">-n</div></div>