January 5, 2009

Setting up my python development environment

Note to self:
my setup for a python development environment
sketch so far:


use virtualenv wrapper changed mkvirtualenv function to to virtualenvwrapper_bashrc
function mkvirtualenv () {
    verify_workon_home
    (cd "$WORKON_HOME"; virtualenv $*)
    if [ ! -f $WORKON_HOME/$1/bin/postactivate ]
    then
        workon "${@:-1}"
        easy_install ipython
        easy_install pysmell
        wget http://www.eletztrick.de/software/mkvimproject/releases/0.4.2.3/mkvimproject-0.4.2.3.tar.gz
        easy_install mkvimproject-0.4.2.3.tar.gz
        rm mkvimproject-0.4.2.3.tar.gz
        deactivate
        touch $WORKON_HOME/$1/bin/postactivate
        postactivate="$WORKON_HOME/$1/bin/postactivate"
        echo "cd $WORKON_HOME/$1" >> $postactivate 
        echo "export PYTHONPATH=$WORKON_HOME/$1/scr:$PYTHONPATH" >> $postactivate    
        echo "if [ ! -d $WORKON_HOME/$1/src ]" >> $postactivate
        echo "then" >> $postactivate
        echo "    mkdir -p $WORKON_HOME/$1/src" >> $postactivate
        echo "fi" >> $postactivate
        echo "if [ ! -f $WORKON_HOME/$1/$1.vpj ]" >> $postactivate
        echo "then" >> $postactivate
        echo "    mkvimproject -o $1.vpj -s python" >> $postactivate
        echo "fi" >> $postactivate
        echo "if [ ! -f $WORKON_HOME/$1/PYSMELLTAGS ]" >> $postactivate
        echo "then" >> $postactivate
        echo "    pysmell src;" >> $postactivate
        echo "  cd lib/python2.5;" >> $postactivate;
        echo "  pysmell . -x site-packages -o ../../PYSMELLTAGS.stdlib;" >> $postactivate
        echo "  cd ../..;" >> $postactivate 
        echo "fi" >> $postactivate
        echo "pproject -U" >> $postactivate
    fi
    workon "${@:-1}"
}

then create a new virtual env with mkvirtualenv projectName --no-site-packages
this will setup the environment for vim and allow for the use of pysmell omnicompletion
and allows a ipython shell within the environment.