-
-
Save blturner/1368191 to your computer and use it in GitHub Desktop.
Setup virtual env for appengine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Build a virtual environment suitable for running appengine. | |
| # This uses virtualenvwrapper to make the virtual environment | |
| # and modifies the postactivate/postdeactivate scripts to make | |
| # the appengine code happy. | |
| # | |
| # Usage: | |
| # $ curl -s https://raw.github.com/gist/1012769 | bash | |
| # | |
| # | |
| # Install steps: | |
| # 1) Checks for virtualenvwrapper and install if needed. | |
| # 2) Activates virtualenvwrapper and creates $WORKON_HOME | |
| # 3) Makes 'appengine' virtual environment | |
| # 4) Modifies postactivate scripts | |
| # 5) Downloads and extracts google appengine source | |
| # 6) pip installs a few extra packages | |
| # | |
| # | |
| # Modify me as new versions are released. | |
| APPENGINE_VERSION=google_appengine_1.5.0.zip | |
| PLATFORM=`uname -s` | |
| which virtualenvwrapper.sh | |
| VWNOTFOUND=$? | |
| if (( $VWNOTFOUND == 1 )) | |
| then | |
| echo 'Installing virtualenvwrapper...' | |
| sudo easy_install virtualenvwrapper | |
| fi | |
| if [[ ! $WORKON_HOME ]] | |
| then | |
| export WORKON_HOME=$HOME/envs | |
| fi | |
| # make sure we are not dealing with a customize path | |
| unset PYTHONPATH | |
| mkdir -p $WORKON_HOME | |
| source `which virtualenvwrapper.sh` | |
| cd $WORKON_HOME | |
| mkvirtualenv --no-site-packages --distribute --python=python2.5 appengine | |
| if [[ ! $VIRTUAL_ENV ]] | |
| then | |
| echo "Problem running mkvirtualenv!" | |
| exit 1 | |
| fi | |
| POSTACTIVATE=$VIRTUAL_ENV/bin/postactivate | |
| POSTDEACTIVATE=$VIRTUAL_ENV/bin/postdeactivate | |
| PREDEACTIVATE=$VIRTUAL_ENV/bin/predeactivate | |
| # EDIT postactivate script | |
| echo 'export REALPREFIX=`python2.5 -c "import sys;print sys.real_prefix"`' >> $POSTACTIVATE | |
| echo 'export PREPATH=$PATH' >> $POSTACTIVATE | |
| echo 'export PATH=$PATH:$VIRTUAL_ENV/bin/google_appengine' >> $POSTACTIVATE | |
| echo 'export PYTHONPATH=$VIRTUAL_ENV/bin/google_appengine:$REALPREFIX/lib/python2.5' >> $POSTACTIVATE | |
| # EDIT postdeactivate script | |
| echo 'unset PYTHONPATH' >> $PREDEACTIVATE | |
| echo 'export PATH=$PREPATH' >> $POSTDEACTIVATE | |
| echo 'unset REALPREFIX' >> $POSTDEACTIVATE | |
| echo 'unset PREPATH' >> $POSTDEACTIVATE | |
| if [ ! -e $APPENGINE_VERSION ] | |
| then | |
| curl -O http://googleappengine.googlecode.com/files/$APPENGINE_VERSION | |
| fi | |
| unzip $APPENGINE_VERSION -d $VIRTUAL_ENV/bin/ | |
| # On mac's add some compiler flags. | |
| if [[ $PLATFORM -eq "Darwin" ]] | |
| then | |
| ARCHFLAGS="-arch i386 -arch x86_64" | |
| fi | |
| for package in webtest PIL fabric coverage django==1.1 | |
| do | |
| echo "Installing $package ..." | |
| pip install -q $package | |
| done | |
| # SSL needs to be installed with sudo!! lame! | |
| echo "Installing ssl with sudo:" | |
| sudo pip install -q ssl | |
| echo "Fixing perms" | |
| sudo chown -R `whoami` $VIRTUAL_ENV | |
| # uninstall webob as it conflicts with the bundled one in app engine. | |
| pip uninstall -q -y webob | |
| echo "You are ready to roll. Edit .bashrc as needed and run 'workon appengine'" | |
| if (( $VWNOTFOUND == 1 )) | |
| then | |
| echo "Virtualenvwrapper has been installed." | |
| echo "Please add the following to your .bashrc file:" | |
| echo ' export WORKON_HOME=$HOME/envs' | |
| echo ' source `which virtualenvwrapper.sh`' | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment