Skip to content

Instantly share code, notes, and snippets.

@pranavraja
Last active December 16, 2015 09:28
Show Gist options
  • Save pranavraja/5412795 to your computer and use it in GitHub Desktop.
Save pranavraja/5412795 to your computer and use it in GitHub Desktop.
Virtualenv helpers

Assumes pip and virtualenv, and in a project directory with requirements.txt.

Run ./deps to create a virtual environment if needed, and install dependencies from requirements.txt.

Run ./inenv [command] to run a command within the virtualenv (e.g. ./inenv python application.py).

if [ ! -f 'requirements.txt' ]; then
echo "No requirements.txt, exiting...."
exit 1
fi
if [ ! -d "venv" ]; then
virtualenv venv --distribute
echo "source venv/bin/activate" >> .env
fi
`dirname $0`/inenv pip install -r requirements.txt
source .env && $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment