Skip to main content

Bash helpers for navigating and managing Python VirtualEnvs.

Project description

envie is an ultra lightweight set of Bash functions aiming to increase your productivity when dealing with everyday VirtualEnv tasks, like: creating, destroying, listing and switching environments.

Summary

  • mkenv [<env>|"env"] [<pyexec>|"python"] - Create virtualenv in <env> based on Python version <pyexec>.

  • rmenv - Destroy the active environment.

  • cdenv - Interactively activate the closest environment (looking down, then up, with lsupenv).

  • lsenv [<start>|"." [<avoid>]] - List all environments below <start> directory, skipping <avoid> subdir.

  • lsupenv - Find the closest environments by first looking down and then dir-by-dir up the tree, starting with cwd.

  • envie init - Run (once) to enable (faster) searches with locate.

  • envie update - Run to re-index directories searched with updatedb.

  • envie register | unregister - Add/remove source statement to/from your .bashrc.

Examples

Create/destroy

To create a new VirtualEnv in the current directory, just type mkenv <envname>. This results with new environment created and activated in ./<envname>. When done with this environment, just type rmenv to destroy the active env.

stevie@caracal:~/demo$ ls
stevie@caracal:~/demo$ mkenv env
Creating python environment in 'env'.
Using Python 2.7.9 (/usr/bin/python).
(env)stevie@caracal:~/demo$ ls
env
(env)stevie@caracal:~/demo$ pip freeze
argparse==1.2.1
wsgiref==0.1.2
(env)stevie@caracal:~/demo$ rmenv
stevie@caracal:~/demo$ ls
stevie@caracal:~/demo$

Change/activate environment

Use cdenv to activate the closest environment, tree-wise. We first look down the tree, then up the tree. If a single Python environment is found, it’s automatically activated. In case the multiple environments are found, a choice is presented to user.

stevie@caracal:~/demo$ ls -F
env/ project/ file1 file2 ...
stevie@caracal:~/demo$ cdenv
(env)stevie@caracal:~/demo$

Assume the following tree exists:

~/demo
  |_ project1
  |  |_ env
  |  |  |_ ...
  |  |_ src
  |     |_ ...
  |_ project2
  |  |_ env
  |     |_ ...

Now, consider you work in ~/demo/project1/src/deep/path/to/module, but keep the environment in the env parallel to src. Instead of manually switching to env and activating it with something like source ../../../../../env/bin/activate, just type cdenv (cde<TAB> should actually do it, if you use tab completion):

stevie@caracal:~/demo/project1/src/deep/path/to/module$ cdenv
(env)stevie@caracal:~/demo/project1/src/deep/path/to/module$ which python
/home/stevie/demo/project1/env/bin/python

On the other hand, if there are multiple environments to choose from, you’ll get a prompt:

stevie@caracal:~/demo$ cdenv
1) ./project1/env
2) ./project2/env
#? 2
(env)stevie@caracal:~/demo$ which python
/home/stevie/demo/project2/env/bin/python

Search/list environments

To search down the tree for valid Python VirtualEnvs, use lsenv. Likewise, to search up the tree, level by level, use lsupenv. cdenv uses lsupenv when searching to environment to activate.

Install

For convenience, envie is packaged and distributed as a Python package. To install, simply type:

$ sudo pip install envie
$ envie register

The second line above will add a sourcing statement for envie to your .bashrc file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

envie-0.4.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

envie-0.4.1-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file envie-0.4.1.tar.gz.

File metadata

  • Download URL: envie-0.4.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for envie-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d814f1d320cce6f7834b8f11a75cb8a8abbd2d5a02ba0dc52935a056ca3225da
MD5 db25d648f4816bf3baf77562560c133a
BLAKE2b-256 6d98eb7f572bdc8ba9711306fbc0f91dea9ab215d6387738d4887b54384c3b4d

See more details on using hashes here.

File details

Details for the file envie-0.4.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for envie-0.4.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 81c961233eaa637595cdc2512f16ffae4aac3600f0b7af8919a2f2dd0796fda2
MD5 76f5e46918d77c6816e622e6df5517a1
BLAKE2b-256 37d994f2bb8dc2b5bc4bff703e3bbbc2c110473f43dda1a57923d9069fbf599a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page