virtualenv - commands to support both python2 and python3

pull/276/head^2
Scott Drennan 2014-03-15 11:47:40 -07:00
parent ef04c3613c
commit 180db373e7
1 changed files with 37 additions and 2 deletions

View File

@ -5,22 +5,42 @@ about-plugin 'virtualenvwrapper helper functions'
[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh
# default python version - use python2 to pick
# up Homebrew version if applicable
if hash brew 2>/dev/null && hash python2 2>/dev/null; then
PYVER="--python=`command -v python2`"
fi
function mkvenv {
about 'create a new virtualenv for this directory'
group 'virtualenv'
cwd=`basename \`pwd\``
mkvirtualenv $cwd
mkvirtualenv $PYVER $cwd
}
function mkvenv3 {
about 'create a new virtualenv for this directory using python3'
group 'virtualenv'
PYVER="--python=`command -v python3`"
mkvenv
}
function mkvbranch {
about 'create a new virtualenv for the current branch'
group 'virtualenv'
scm_prompt_info >/dev/null 2>&1
mkvirtualenv "$(basename `pwd`)@$SCM_BRANCH"
mkvirtualenv $PYVER "$(basename `pwd`)@$SCM_BRANCH"
}
function mkvbranch3 {
about 'create a new virtualenv for this directory using python3'
group 'virtualenv'
PYVER="--python=`command -v python3`"
mkvbranch
}
function wovbranch {
@ -37,3 +57,18 @@ function wovenv {
workon "$(basename `pwd`)"
}
function mkve {
about 'create a new virtualenv with the specified name'
group 'virtualenv'
mkvirtualenv $PYVER $1
}
function mkve3 {
about 'create a new virtualenv with the specified name using python3'
group 'virtualenv'
PYVER="--python=`command -v python3`"
mkve $1
}