GithubHelp home page GithubHelp logo

ave's Introduction

ave - Activate Virtual Environment

ave is small shell (bash, zsh) function to help out with activation of Python's virtual environments; the name stands for Activate Virtual Environment (which is almost all it does).

How to use it?

ave was created out of my personal needs of organizing projects and need to type less. There are two ways in which ave can be used. If you type ave with no arguments, it will start from current directory and search for virtual environment by cd ing upwards thru parent directories or by looking inside ~/$WORKON_HOME. When virtual environment is found, it is activated (sourced). Called with an argument, it will do the same and optionally cd to project directory if it's held under source control (git, mercurial or svn).

The above is all ave does, but it's easier to understand with following example. Let's assume we have this directory structure:

# this is where we store our projects
~/projects/
    common-env/
        project_1/
        project_2/
        project_3/
    project_a/
    project_b/
    project_c/

# this is where we store virtual environments
~/$WORKON_HOME/
    common-env/
    project_a/
    project_b/
    project_c/

# temp directory to work with throwaway stuff
~/tmp/

Multiple projects based on common virtual environment

These are projects that are all based on the same virtual environment, common-env in the example:

ave ~/projects/common-env/project_1

or

cd ~/projects/common-env/project_1
ave

After any of those commands, common-env is activated and current directory is changed to project_1.

One project per virtual environment

Each project has its own virtual environment:

ave ~/projects/project_a

or

cd ~/projects/project_a
ave

With bash (or any other shell) and tab completion, very few keystrokes are needed.

Playground and throwaway environmets

There is often a need to test new libraries. You want to quickly make an environment, type out some code (directly in python shell or by creating a file), play with it and delete it.

virtualenv ~/tmp/foo-playground
cd ~/tmp/foo-playground
ave

pip install foo
python
# import foo and play with it

# enough play, go to work
rm -rf ~/foo-playground

This way you are not cluttering WORKON_HOME directory even if you don't delete temporary environmets right away after use (which I usually don't).

How to install it?

Via pip

Install for user:

pip install ave --user

or if you want to install globally:

sudo pip install ave

Manually

Clone the repository and source ave.sh script from your .bashrc or .profile.

Configure it

# define directory to put virtual environments
export WORKON_HOME=~/.venvs

# source ave function
source /path/to/ave.sh

What about virtualenvwrapper?

By all means, virtualenvwrapper is mature and well tested software. It works great and is recommended by many pythonistas. It does so much more than ave and if you need its functionality, you should check it out.

ave uses the same WORKON_HOME evnironment variable so it's compatible with virtualenvwrapper, both can be used at the same time.

ave is simple to the point that this documentation is longer than the complete ave code. I like simple.

Licence

ave is MIT licensed.

ave's People

Contributors

selectnull avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.