Skip to content

Instantly share code, notes, and snippets.

@gtzilla
Created January 31, 2011 16:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtzilla/804341 to your computer and use it in GitHub Desktop.
Save gtzilla/804341 to your computer and use it in GitHub Desktop.
Delay sourcing virtualenvwrapper.sh until first call to workon
## delay sourcing venv to workon call
## replace "source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh"
## with below block
function load_env {
if [ type -p workon &> /dev/null ]; then
# nothing, source is loaded
workon "$@"
else
unalias workon
source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh
workon "$@"
fi
}
alias workon="load_env"
@warvariuc
Copy link

http://virtualenvwrapper.readthedocs.org/en/latest/install.html#lazy-loading
I did:

export PROJECT_HOME=~/projects/
export WORKON_HOME=~/projects/venv
#export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUAL_ENV_DISABLE_PROMPT=1

if [ -f `which virtualenvwrapper_lazy.sh` ]; then
    source `which virtualenvwrapper_lazy.sh`
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment