pyvenv icon indicating copy to clipboard operation
pyvenv copied to clipboard

Add an auto-detect function

Open jorgenschaefer opened this issue 10 years ago • 2 comments

A function (e.g. for elpy-mode-hook) that auto-detects the current virtualenv would be nice.

It should look through ~/.virtualenvs/*/.project for a directory prefix of the current directory and activate said virtualenv.

jorgenschaefer avatar Mar 07 '15 18:03 jorgenschaefer

(Previously posted from my work account. Deleted and copied.)

I have this written for my own setup already, though with pyenv virtualenv instead. My approach is to automatically look for a .dir-locals.el with the pyvenv-workon command set. If so, bail. If not, look for the pyenv - instead of looking for the file, I actually shell out to pyenv versions.

What's nice about this is the ability to manually override the virtualenv used - maybe you have multiple clones of a git repo working on different branches, and you're testing different required package versions.

Is this something you'd like as a PR?

jennykwan avatar Sep 11 '15 00:09 jennykwan

This sounds interesting! I do not think that pyvenv.el should prescribe the use of .dir-locals.el or similar Emacs-centric workflows, hence why I mentioned using the standard project files of virtualenvwrapper above. :-)

jorgenschaefer avatar Sep 12 '15 11:09 jorgenschaefer