Skip to content

Instantly share code, notes, and snippets.

@acdha
Created September 2, 2011 13:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/1188557 to your computer and use it in GitHub Desktop.
Save acdha/1188557 to your computer and use it in GitHub Desktop.
My virtualenvwrapper postmkvirtualenv hook
#!/bin/bash
# This hook is run after a new virtualenv is activated.
set -e
(cat <<'PYDOC'
#!/usr/bin/env python
import pydoc
if __name__ == '__main__':
pydoc.cli()
PYDOC
) > $VIRTUAL_ENV/bin/pydoc
chmod +x $VIRTUAL_ENV/bin/pydoc
(cat <<'POSTACTIVATE'
#!/bin/sh
export PROJECT_ROOT=$HOME/Projects/__PROJECT_ROOT__
export PATH=$PROJECT_ROOT/bin:$PATH
pushd $PROJECT_ROOT
POSTACTIVATE
) > $VIRTUAL_ENV/bin/postactivate
sed -i -e "s/__PROJECT_ROOT__/`basename $VIRTUAL_ENV`/g" $VIRTUAL_ENV/bin/postactivate
chmod +x $VIRTUAL_ENV/bin/postactivate
pip install -q https://github.com/acdha/pep8/tarball/master pyflakes ipython ipdb flake8
@dhellmann
Copy link

Check out the virtualenvwrapper.project plugin for managing the cwd when you activate an environment.

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