Home

Awesome

aactivator

PyPI version Build Status

aactivator is a simple tool that automatically sources ("activates") and unsources a project's environment when entering and exiting it.

Key features of aactivator include:

aactivator supports Python 2.7, 3.4+; it has no dependencies besides the standard library.

The aactivator interface

aactivator provides a simple interface for projects, via two files at the root of the project:

Note that neither of these files need to be executable or contain a shebang. This is because they are sourced (run inside your current shell) and not executed.

Installing into your shell

We recommend adding aactivator to your shell's config. It will stay out of your way during regular usage, and you'll only ever notice it doing its job when you cd into a project directory that supports aactivator.

You first need to install the aactivator binary somewhere on your system. You have a few options:

  1. Just copy the aactivator.py script somewhere on your system and make it executable (chmod +x aactivator.py). It has no dependencies besides the Python standard library.

  2. Install it via pip (pip install aactivator). You can install system-wide, to your home directory, or into a virtualenv (your preference).

  3. Install the Debian package. This is the best option for system-wide automated installations, and gives you other niceties like a man-page. You can find pre-built Debian packages under the Releases GitHub tab.

Once you have aactivator installed, you need to enable it on login. To do that, just add this line to the .bashrc (or .zshrc for zsh) file in your home directory:

eval "$(aactivator init)"

(You may need to prefix aactivator with the full path to the binary if you didn't install it somewhere on your $PATH).

Motivation

Automatically sourcing virtualenvs is a huge boon to large projects. It means that you can directly execute tools like pytest, and also that the project can register command-line tools (via setuptools' console_scripts entrypoint) for use by contributors.

Security considerations

We tried pretty hard to make this not a giant arbitrary-code-execution vector. There are two main protections:

Alternatives to aactivator

Some alternatives to aactivator already exist. For example:

These alternatives all have at least one of the following problems (compared to aactivator):