Skip to content

Instantly share code, notes, and snippets.

@dcwangmit01
Last active March 30, 2016 01:58
Show Gist options
  • Save dcwangmit01/b0ecea10fd7c7d531b545960bbb3b7fa to your computer and use it in GitHub Desktop.
Save dcwangmit01/b0ecea10fd7c7d531b545960bbb3b7fa to your computer and use it in GitHub Desktop.
Direnv .envrc for Python Virtualenv
# direnv file: https://github.com/direnv/direnv
# Automatically sets the gopath to the directory wherever this .envrc
# file lives, even from subdirectories
OLD_PYTHON=`which python`
VENV_PATH=`pwd`/.venv/`hostname`
if [ ! -d "$VENV_PATH" ]; then
virtualenv $VENV_PATH
fi
source $VENV_PATH/bin/activate
NEW_PYTHON=`which python`
if [ "$OLD_PYTHON" != "$NEW_PYTHON" ]; then # don't quote the variables, to strip the newline
echo "Virtualenv changed"
echo " from $OLD_PYTHON"
echo " to $NEW_PYTHON"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment