Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

auto-virtualenv

Automatically activate python virtualenvs on emacs based on project name or .python-version file.

Installation

MELPA

auto-virtualenv is available on MELPA.

You can install auto-virtualenv with the following command.

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

manual

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

Configuration

(require 'auto-virtualenv)
(add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)

Optionally:

;; Activate on changing buffers
(add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
;; Activate on focus in
(add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)

How it works

On auto-virtualenv-set-virtualenv, the hierarchy is scanned for a special file, which is part of the list auto-virtualenv-project-root-files. The list contains files which indicate a project root, like a .git directory or a .dir-locals.el file.

If a .python-version file exists, the contents of the file joined to the project root, form the location of the virtualenv. Otherwise if a .venv directory is found in the project root, this directory is used. Otherwise a directory within ~/.virtualenvs or ~/.pyenv/versions/, having with the project's name, which is the directory name of the project root, is checked for being a virtual env.

The found environment is finally activated using pyvenv-activate.

Alternatives

License

GNU GPL v3.0

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

About

Automatically activate python virtualenv on Emacs

Resources

License

Releases

No releases published

Packages

No packages published