virtualenvでgoogle app engine開発用の環境を作成したときのメモ

virtualenv、virtualenvwrapperのインストール

こことか、
http://labs.unoh.net/2009/12/2009python.html
ここを参考に
http://www.ianlewis.org/jp/virtualenv-pip-fabric

virtualenvで環境を作成する

mkvirtualenv --python=/usr/bin/python2.5 gae
Running virtualenv with interpreter /usr/bin/python2.5
New python executable in gae/bin/python2.5
Also creating executable in gae/bin/python
Installing setuptools............................done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/yuhei/.virtualenvs/gae/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/yuhei/.virtualenvs/gae/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/yuhei/.virtualenvs/gae/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/yuhei/.virtualenvs/gae/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/yuhei/.virtualenvs/gae/bin/get_env_details

これで

workon gae

で環境が有効になる

アプリ起動

開発中のgaeアプリを起動したところ、「ImportError: No module named cgi」エラーが発生
https://gist.github.com/1336366


調べたところ、dev_appserver.pyにパッチを当てる必要があるという情報を発見
http://code.google.com/p/googleappengine/issues/detail?id=4339

cd /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine
patch -p0 < ~/Downloads/dev_appserver.patch 

これで正常に動いた