Live data from Hacker News

Show HN: Vex, a new way to run things in Python's virtualenvs

pypi.python.org

11–20 of 35 posts

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#11

Ha. I always thought something was unnecessarily awkward about virtualenv, but I couldn't quite put my finger on it. Virtualenvwrapper was an improvement in many ways, but its lack of portability could be a pain. Reading the docs, Vex makes perfect sense. We should use virtualenv basically the same way we sudo. It's kind of amazing it took this long for someone to do it. Thanks!

Vex seems very convenient, but it is also possible to avoid the "magic" with just standard virtualenv. If you provide the full path to the python binary in the virtualenv, it executes with the virtualenv loaded: /home/acjohnson/virtualenvs/foo/bin/python myscript.py This is useful for crontabs, system service config, etc. which don't load a regular user's bash setup files.

Similarly, anything you've installed in that virtualenv that installs itself in a bin folder (pip, mercurial, django-admin.py, etc) will be in that bin folder, and calling them from that directory will execute them in the context of that virtualenv as well.

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#13
This is cool, I like tools that focus on one thing.

Just like the author, I never used all virtualenvwrapper's features and was always happy to create and delete VEs on my own. The only thing missing from standard virtualenv workflow is easy way to activate the VE; so I wrote that on my own and been using it since ever. It's trivially small shell script but it does the work well, you can check it out at pypi:

https://pypi.python.org/pypi/ave/

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#14

This is cool, I like tools that focus on one thing. Just like the author, I never used all virtualenvwrapper's features and was always happy to create and delete VEs on my own. The only thing missing from standard virtualenv workflow is easy way to activate the VE; so I wrote that on my own and been using it since ever. It's trivially small shell script but it does the work well, you can check it out at pypi: https:/…

What is truly horrible is that I wrote my shell function, named it ave, thought it was a great name and then months later (edit: after I released vex) realized you had written a package named ave. Oh well.. :)

This is also worth checking out if you just want 'workon' type functionality without the fuss.

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#15

Ha. I always thought something was unnecessarily awkward about virtualenv, but I couldn't quite put my finger on it. Virtualenvwrapper was an improvement in many ways, but its lack of portability could be a pain. Reading the docs, Vex makes perfect sense. We should use virtualenv basically the same way we sudo. It's kind of amazing it took this long for someone to do it. Thanks!

Vex seems very convenient, but it is also possible to avoid the "magic" with just standard virtualenv. If you provide the full path to the python binary in the virtualenv, it executes with the virtualenv loaded: /home/acjohnson/virtualenvs/foo/bin/python myscript.py This is useful for crontabs, system service config, etc. which don't load a regular user's bash setup files.

Fully agreed, and the README for vex suggests this if you are worried about overhead from the wrapper especially for non-interactive purposes where you are repeatedly incurring python startup.

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#17
post #9

Looks good. I currently use http://tudb.org/articles/2014/03/31/vpython/ for pretty much all of my python projects (also, i am the author of vpython).

Ah, discovering it from the directory. I considered this in analogy with the way vagrant works.

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#18

This is based on my personal experience with tools for using virtualenv. virtualenvwrapper is very powerful with all kinds of hooks but I just never used all that power and needed things like speed more. virtualenvwrapper provided a lazy loader but that would have various problems from time to time as you'll see on the issue tracker. So then for a long time I just ran 'virtualenv' and source wherever/bin/activate and…

> pydoc still doesn't work Are you using `pydoc` on the command line? If so, try pdoc: https://github.com/BurntSushi/pdoc . I wrote it as a tool to replace epydoc (strictly automatic documentation), but it works on the command line just like pydoc. (It can also generate HTML documentation with cross module linking that isn't crap. See an example here: http://pdoc.burntsushi.net/nfldb )

I do sometimes, more as a matter of muscle memory than volition. I'm going to make a try to use your tool as a replacement for a while and see if I can generate any issues for you :)

However, I still would like to eventually unbreak pydoc for users who might have bad habits like I do.

The issue is that virtualenv itself had an opportunity to fix this (with multiple patches submitted IIRC) and they decided to punt by implementing it as yet another shell function. So for me to unpunt without coupling to the shell, I pretty much have to dump a script into bin/. I guess maybe not that many people use pydoc anyway?

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#19

This is cool, I like tools that focus on one thing. Just like the author, I never used all virtualenvwrapper's features and was always happy to create and delete VEs on my own. The only thing missing from standard virtualenv workflow is easy way to activate the VE; so I wrote that on my own and been using it since ever. It's trivially small shell script but it does the work well, you can check it out at pypi: https:/…

What is truly horrible is that I wrote my shell function, named it ave, thought it was a great name and then months later (edit: after I released vex) realized you had written a package named ave. Oh well.. :) This is also worth checking out if you just want 'workon' type functionality without the fuss.

I guess I was faster picking ave :) but vex is good too.

Re: Show HN: Vex, a new way to run things in Python's virtualenvs

#20
post #10

This is based on my personal experience with tools for using virtualenv. virtualenvwrapper is very powerful with all kinds of hooks but I just never used all that power and needed things like speed more. virtualenvwrapper provided a lazy loader but that would have various problems from time to time as you'll see on the issue tracker. So then for a long time I just ran 'virtualenv' and source wherever/bin/activate and…

> everyone finds 'workon' invaluable, a position I do understand. At first I wanted to praise virtualfish [1] and its ability to automatically activate a virtualenv when I cd into it, but then I realized that vex's way does indeed make more sense. What do we do in a virtualenv? We basically just run pip to do various things, or run the program (in case it's an application and not a library) or test suite. So yeah, I…

Awesome, thank you for trying this. Please make a github issue or email me if you have any suggestions informed by the experience :)

edit: That one feature reminded me of Kenneth Reitz's autoenv (https://github.com/kennethreitz/autoenv).

I can't do anything to futz with cd, but it could be possible to reverse that and cd to a project directory when a virtualenv is activated, I am just not sure yet mechanically the right way to choose which one. Worth considering.

Post reply on HN