/pyvenv-extras

An Emacs package that adds projectile-based Python virtual environment tracking to pyvenv, and more

Primary LanguageEmacs Lisp

pyvenv-extras

https://github.com/brandonwillard/pyvenv-extras/workflows/Testing%20Workflow/badge.svg

An Emacs package that adds projectile and/or persp-mode-based Python virtual environment tracking to pyvenv, and more.

Features

pyvenv-extras-mode

  • Initialize terminals so that they automatically enable the local venv (implemented for term and vterm)
  • Add CONDA_PREFIX and CONDA_DEFAULT_ENV variables to the environment
  • Activate comint buffers within the projectile-determined project root directory
  • Start and restart Python inferior processes in a way that preserves the pyvenv venv settings and prevents the cursor from jumping
  • Make interactive Python sessions project-specific by adding projectile project names to python-mode process names
  • Make flycheck use the projectile project directory

pyvenv-projectile-tracking-mode

This mode augments pyvenv-tracking-mode by only changing the virtual environment when the projectile project changes (and has a different virtual environment).

Currently, the approach used relies on the availability of pyvenv-workon values within in each projects’ .dir-locals.el, so each project must have those set.

pyvenv-persp-tracking-mode

This mode sets the virtual environment when a persp-mode perspective is activated.

When projectile is set to use persp-mode-scoped projects via =proj-persp-extras= and pyvenv-projectile-tracking-mode is enabled, this mode effectively enables persp-mode-based virtual environment scopes. In other words, your current persp-mode perspective determines which virtual environment is activate.

Usage

Just enable the minor modes:

(pyvenv-extras-mode +1)
(pyvenv-projectile-tracking-mode +1)
(pyvenv-persp-tracking-mode +1)

Installation

Use your favorite approach to installing Emacs packages from GitHub.

Here’s an example of one:

(quelpa
'(pyvenv-extras
  :fetcher git
  :url "https://github.com/brandonwillard/pyvenv-extras.git"))

Development

To use as a Cask dependency:

(depends-on "pyvenv-extras"
            :git "https://github.com/brandonwillard/pyvenv-extras.git"
            :branch "master")