A doubt that arises sometimes is how to use Pydev with virtualenv, so, here we go...
For those that don't know about it, virtualenv is a Python tool that allows one to configure a new Python interpreter that's 'sandboxed' based on an existing interpreter.
Sample use of virtualenv:
Say you have an interpreter in d:\bin\python26 (with easy_install in place).
You could do d:\bin\python26\scripts\easy_install.exe virtualenv to install virtualenv and later do:
d:\bin\Python26\Scripts\virtualenv.exe d:\bin\Python26django, which would create a new Python install at d:\bin\Python26django.
Later, you could add new libraries just at that Python install without disturbing the base install.
E.g.:
d:\bin\Python26django\Scripts\easy_install-2.6.exe django would install django at that interpreter without changing the default one.
Now, as far as Pydev is concerned, there's nothing special in configuring a regular interpreter or an interpreter available through virtualenv. It's just a matter of following the default steps (available at http://pydev.org/manual_101_interpreter.html) but pointing to the interpreter created by virtualenv (in this case d:\bin\Python26django\scripts\python.exe).
Note: For linux users, the instructions should be similar, but the created folder by virtualenv doesn't put the interpreter at a 'scripts' folder, but at a 'bin' folder.
Update: Note that when selecting a virtualenv interpreter, the folders from the base install won't come checked by default when adding the interpreter, so, those have to be manually selected.
what is for now biggest annoyance with virtualenvs: Im working with virtualenv for month or two. I've installed a lot of packages using easy_install inside virtualenv. Now, when I add interpreter in pydev, it scans it's site-packages and discovers all the libraries. Thats is excelent, although it takes a while and Eclpise UI is frozen (modal box). Now when I add another virtualenv's interpreter (possibly with another bunch of libraries) pydev rescan every site-packages dir in every configured interpreter. Thats is horrible because adding 5th virtualenv is total pain. I can go to make a tea, chat with someonte - it takes really long to rescan all folders, and I repeat - UI i frozen because modal, unclosable box with scanning progress.
ReplyDeleteSuch solution as move parsing to background tasks (PDT does this such way), or parsing just only new virtualenv would be great.
Additionally, after adding virtualenv, when I use easy_install to add 10 another packages, then I must do many operations to include them in virtualenv configuration. Additionally, because I don't know which package was installed as egg and which as folder, amount of click need to be done increases dramatically. Option to auto-update or auto-rescan selected virtualenv would be extremely useful
Anyway I use virtualenvs extensively and its so such great feature. Just those two annoyances are bothering me ...
Hi Ivan,
ReplyDeleteI agree with your points -- the issues you talked about are actually already planned to be dealt with.
Cheers,
Fabio
Great to hear that, I'm really looking forward. Do you know any rough estimation when it may be implemented ?
ReplyDeleteIt should be implemented at most in 2 months (in one of the 2 next releases).
ReplyDeleteit must implement. Virtualenv is very usefull in any situation. Thank for a great jobs.
ReplyDeleteJust wanted to leave a note saying that in the latest pydev releases the issue about restoring all the interpreters is now solved (1.6.4 also fixed an issue with having multiple interpreters).
ReplyDelete