pyvenv
pyvenv copied to clipboard
Add an auto-detect function
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.
(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?
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. :-)