[Python-ideas] Looking for input to help with the pip situation
ncoghlan at gmail.com
Mon Nov 13 22:56:21 EST 2017
On 14 November 2017 at 13:08, Nathaniel Smith <njs at pobox.com> wrote:
> On Nov 13, 2017 6:47 PM, "Nick Coghlan" <ncoghlan at gmail.com> wrote:
> On 14 November 2017 at 11:51, Nathaniel Smith <njs at pobox.com> wrote:
> > What if instead of installing a standard entry point, the pip
> > executable was installed as
> > #!/bin/sh
> > exec python -m pip "$@"
> > on Unix-likes
> It would technically be enough to make the shebang line
> `#!/usr/bin/env python` so the interpreter used was picked up from the
> environment, rather than being preconfigured at install time. However,
> the problem is that you don't know for certain that that python will
> actually have `pip` installed, so it might just fail with a cryptic
> error instead.
> 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.
> 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.
My essential concern is that I don't think we should be opening ourselves
up to *even more* platform dependent behaviours in this area.
Instead, if we decide that we would like to request that pip to start doing
something different when:
* `sys.executable` and `shutil.which('python')` are inconsistent with each
* `sys.argv` doesn't end with `site-packages/pip/__main__.py` and isn't
then we'd be better off putting that logic in pip's Python code, rather
than in the platform dependent script wrappers where we can't control the
error messages presented when our expectations aren't met.
I do like the idea of making that distinction in principle though, as it's
a better one than "inside a virtual environment or not?".
While Python level venvs are *a* way to obtain the desired pip/python
consistency, they're not the only one:
- Arch Linux does it by default
- Docker's Python 3 images do it by default (Alpine Linux may even do it by
default in general)
- Windows installs do it by default (if PATH is configured correctly)
- conda env does it
- Software Collections do it (including in the Python 3 Docker images for
RHEL & CentOS)
- *nix environment modules do it
- system admins may set up per-user install profiles to do it
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas