Automatically activate python virtualenv using virtualenvwrapper.el
Emacs Lisp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
auto-virtualenvwrapper.el

README.md

auto-virtualenvwrapper

Automatically activates python virtualenv on emacs using:

  • python-version file in the project root.
  • .venv or venv directory (or link) in the project root.
  • Try find a virtualenv with the same name of Project Root.

Project root is defined as a parent directory containing auto-virtualenvwrapper-project-root-files. By default the variable equals to (".python-version" ".dir-locals.el" ".projectile" ".emacs-project" "manage.py" ".git" ".hg").

This code is based on auto-virtualenv, but uses tiny virtualenvwrapper library rather then pyenv. This way you avoid additional dependencies: pyenv and elpy.

Installation

MELPA

M-x package-install [RET] auto-virtualenvwrapper [RET]

manual

Clone this repository somewhere and add this directory to you load-path.

Usage

(require 'auto-virtualenvwrapper)
(add-hook 'python-mode-hook #'auto-virtualenvwrapper-activate)

Optionally:

;; Activate on changing buffers
(add-hook 'window-configuration-change-hook #'auto-virtualenvwrapper-activate)
;; Activate on focus in
(add-hook 'focus-in-hook #'auto-virtualenvwrapper-activate)

Alternatives

License

GNU GPL v3.0

View official GNU site http://www.gnu.org/licenses/gpl.html.