Live data from Hacker News

Virtualenv's bin/activate is Doing It Wrong

gist.github.com

1–10 of 31 posts

Re: Virtualenv's bin/activate is Doing It Wrong

#7
post #6
post #4

But what will be the added CO2 footprint of launching so many unnecessary shells! Also, I don't like the prospect of having to hit Ctrl-D twice to logout.

Then type 'exec inve' instead of just 'inve.'

Perhaps that makes sense. Actually I usually type 'workon myproject' (using virtualenvwrapper, because it provides a nice standard location and activation command for virtualenvs), so maybe this could all be transparent.

Re: Virtualenv's bin/activate is Doing It Wrong

#9

The fact that it does not use a subshell makes it useful. You can trivially use it in bash scripts and cronjobs.

Why can you not do?:

  #!/usr/bin/virtual-bash my-env
  
  echo hello
Edit: in fact something like /usr/bin/virt-python my-env is much nicer than /var/lib/my-app/env/bin/python. Basically like virtualenvwrapper but for Python scripts that are not run interactively.

Re: Virtualenv's bin/activate is Doing It Wrong

#10

The fact that it does not use a subshell makes it useful. You can trivially use it in bash scripts and cronjobs.

Why can you not do?: #!/usr/bin/virtual-bash my-env echo hello Edit: in fact something like /usr/bin/virt-python my-env is much nicer than /var/lib/my-app/env/bin/python. Basically like virtualenvwrapper but for Python scripts that are not run interactively.

I regularly write scripts that involve more than one virtualenv. At the moment this is trivial by just activating and deactivating envs from one script. Starting subshells is complicated because communication into the shell barely exists. Worse than that is that the shebang only supports two arguments and is heavily length limited.
Post reply on HN