I know nothing of the details, but I think the goal is to have the same
command work (almost) everywhere, yes?

That does not need to be a python script, however. In fact, it's nice if
activating an environment is as fast as possible so firing up Python to do
it is less than ideal.

Anyway -- I'd encourage folks to look at conda -- it now provides a conda
command that can activate on multiple plaatfroms the same way:

conda activate env_name

I don't know how many different shells that works with, but it at least
hits the big few.

"conda" used to be a python script but I'm pretty sure it's now some kind
of custom executable that re-directs the commands, and I'm sure is
different on different platforms.

prior art and all that.

-CHB




On Mon, Jan 4, 2021 at 8:34 AM M.-A. Lemburg <m...@egenix.com> wrote:

> On 04.01.2021 15:45, Chris Angelico 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.
>
> Something that would work is using the ssh-agent approach to
> output shell commands which configure the environment:
>
> # For bash et al:
> `python3 -c "print('export TEST=1')"`
>
> A new command:
>
> `python3 -m venv activate myenv bash`
>
> could do the trick.
>
> Of course, venv itself could also create the necessary
> shell files in the bin/ dir. You'd then just need to
> run:
>
> source myenv/bin/activate.sh
>
> (this is how virtualenv does this)
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Experts (#1, Jan 04 2021)
> >>> Python Projects, Coaching and Support ...    https://www.egenix.com/
> >>> Python Product Development ...        https://consulting.egenix.com/
> ________________________________________________________________________
>
> ::: We implement business ideas - efficiently in both time and costs :::
>
>    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>            Registered at Amtsgericht Duesseldorf: HRB 46611
>                https://www.egenix.com/company/contact/
>                      https://www.malemburg.com/
> _______________________________________________
> 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/7MOIJHJFQVVRL7GW4HY6E3V5X2CGHQX6/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/447QJQ5XMRFA6TRDZJFDDYB2K4PRA6E4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to