On Tue, Jan 5, 2021 at 1:52 AM Calvin Spealman <cspea...@redhat.com> wrote:
>
>
>
> On Mon, Jan 4, 2021 at 9:47 AM Chris Angelico <ros...@gmail.com> wrote:
>>
>> On Tue, Jan 5, 2021 at 1:42 AM Abdur-Rahmaan Janhangeer
>> <arj.pyt...@gmail.com> wrote:
>> >
>> > Greetings list,
>> >
>> > put simply,
>> >
>> > be able to use
>> >
>> > $ python -m venv venv_name activate
>> >
>> > To activate an env instead of having each platform have a way of
>> > handling it
>> >
>>
>> Unfortunately, that wouldn't work. Activating a virtual environment
>> means setting some env vars in the current shell, and Python is
>> fundamentally unable to do that - it can only be done within the shell
>> itself (by sourcing a script).
>>
>> You can, of course, simply run the Python executable from that venv,
>> but activation is *by its nature* a shell feature, and will differ by
>> shell.
>
>
> This is true, but...
> it might be possible to include something more like pipenv's "shell" which 
> spawns a new instance of your shell with the right paths. It effectively 
> achieves the same goal, without needing to source,
>

Hmm. In terms of guaranteeing consistency, I'm not sure it's really
any better - what if it picks the wrong shell, or (worse) the right
shell with slightly different settings? The normal activation method
is pretty simple: set three environment variables (including PATH),
and change the prompt. Spawning a separate shell would require
correctly matching the behaviour of the current shell. Plus, I'm not
really a fan of spawning unnecessary shell levels, which you then end
up exiting out of as a stack.

But if a separate "python3 -m venv env shell" command were to exist,
I'm sure it would have some use. It shouldn't be considered
activation, but a completely separate feature with some similar
use-cases. (Though I wouldn't use it, myself.)

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FZNUDCTKNI4WK4N4UOQM5TY5WP5QADTN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to