Question

Ian Kelly ian.g.kelly at gmail.com
Tue Mar 8 20:27:45 EST 2016


On Tue, Mar 8, 2016 at 5:13 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Mar 9, 2016 at 10:52 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>>> Well, running bash on Windows is decidedly non-standard. This is like
>>> installing a Python package on a Linux system and then complaining
>>> that it won't run under wine. I don't think that Python should be
>>> expected to provide an activate script for all possible shells the
>>> user might conceivably want to use.
>>
>> Not "all possible shells", no. But it's not unreasonable for it to handle
>> the single most popular operating system environment in the world, Windows,
>> don't you think?
>
> I'm not sure that the issue is "Windows can't use venv", but "Windows
> with Git Bash can't use venv". Windows has a number of shells
> available; the default one is pretty terrible but does kinda work, and
> then there's PowerShell, and ports of other shells like bash. Cygwin
> provides its own shell (which I think is bash), and I'm not sure if
> that's the same as Git Bash installs. And then there's the difference
> between the shell (the command interpreter) and the, for want of a
> better name, terminal emulator (the thing that displays stuff on the
> screen).
>
> Working purely within cmd.exe and the default terminal emulator, I was
> able to "py -m venv env" and then "env\scripts\activate" (note, *not*
> env/bin/activate which is what I'm used to - no idea why). It seemed
> to work.
>
> Working instead in Git Bash, though, leaves me unable to activate,
> because there is no bash script for venv activation. Hence, the
> problem is "supporting all possible shells" (which is an enormous
> challenge), rather than "supporting one of the three most popular
> operating systems" (which, I agree, is well worth doing).

It looks like the shell environment that comes with Git for Windows is
actually Windows Powershell [1], so presumably the activate.ps1 script
that's already provided by venv is what's needed, not a bash script.

Git Bash is apparently separate and runs under MinGW, which in my
limited experience could charitably be described as "semi-functional".
Admittedly, it's been a long while since the last time I tried to use
it. Cygwin is much better, and it emulates a POSIX platform so closely
that I wouldn't be surprised if a Python running under Cygwin simply
installed the bash venv script to begin with.

[1] https://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Powershell



More information about the Python-list mailing list