On 15 November 2017 at 19:51, Paul Moore <p.f.moore@gmail.com> wrote:
On 15 November 2017 at 08:22, Nick Coghlan <ncoghlan@gmail.com> wrote:
> On 15 November 2017 at 16:13, Steve Barnes <gadgetsteve@live.co.uk> wrote:
>>
>>   - "pip -X[.Y][-32|-64] operation ..." tries to find a python matching
>> -X[.Y][-32|-64] and if it succeeds executes "python -m pip operation
>> ..." with that python, (if it doesn't find a matching python is should
>> fail with a sensible error message and possibly list the valid python
>> specifiers).
>
>
> This is a genuinely interesting option, especially as `pipenv` has already
> implemented a feature somewhat akin to this:
> https://docs.pipenv.org/basics.html#specifying-versions-of-python
>
> `pipenv` also allows `pipenv --two` and `pipenv --three` when setting up
> your initial virtual environment.

This is an interesting idea for *any* tool that's about "working with
Python environments" as opposed to "writing Python code". So pip,
virtualenv, tox, pipenv, ... Many of these tools are variously
reinventing "tell me which Python environment to work on" options.
Having a common way to do this would be really useful. I'm not sure
how likely it would be for pip to be able to use it (pip introspects
sys.executable to get site-packages, etc), but it's certainly a
possibility.

Having a standardised library/wrapper that handles the "select a
Python environment" process would be a huge plus. There's
https://github.com/zooba/pep514tools which is a start on handling the
Windows registry scanning logic, and building on that to include Unix
and anything else we needed would be great.

While I suspect pep514tools itself may not end up being the right place, I filed https://github.com/zooba/pep514tools/issues/2 to start discussing that idea further. For other platforms, just naively scanning `PATH` is often good enough, so it's mainly Windows where discovery needs to be a bit more aware of platform specific details (i.e. PEP 514's registry entries).

Cheers,
Nick.

--
Nick Coghlan   |   ncoghlan@gmail.com   |   Brisbane, Australia