webapp2 is included in recent SDKs (google_appengine/lib/webapp2). If you either use a newer SDK or don't import webapp2 it should work for you.
In case you're interested in a slightly different buildout setup, I've included one.
I've been using rod.recipe.appengine for buildout, and have been quite happy with it. It even allows you to patch the app engine SDK if you need to fix PyCrypto imports etc.
I made my config based on the bobo example and some other sources. The example below allows you to get dependencies like PIL from dist.plone.org, it pulls wtforms for form handling and gdata for crypto convenience and put them in packages.zip which can be added to sys.path before imports, for example with import zippedpackages
where zippedpackages.py looks like
import sys
if 'packages.zip' not in sys.path:
sys.path.insert(0, 'packages.zip')
Also note that settings.py and app.yaml are generated from templates and variables like appspotname
and appspotversion
are inserted.
The buildout is based on a running buildout, but this exact example has not been tested, and is also missing some templates. If you look up the different recipes on pypi you can read up on options and syntax.
If you use templates, you might have to run the buildout twice in order to first generate files from templates (in src directory in my setup) and then create symlink to parts directory (where SDK runs from). If you don't want templates, remove from buildout and set up as you normally do. Using eggs instead of virtualenv enables you to switch libraries as configuration instead of having different virtualenvs. Not a big problem though, as library versions rarely change. If you run into issues with eggs, it's also worth noting that the SDK import magic is aware of site-packages and to some extent virtualenvs, but not eggs, so some libraries might have to be installed in the virtualenv anyway.
[buildout]
appspotname = progect
appspotversion = dev
versions = versions
develop =
src/progect
parts =
progect
progectconfig
progectsettings
nosetests
noseconfig
zipsymlink
unzip = true
find-links =
http://dist.plone.org/thirdparty/
[progect]
recipe = rod.recipe.appengine
url = http://googleappengine.googlecode.com/files/google_appengine_1.6.6.zip
server-script = dev_appserver
packages =
wtforms
gdata
src = ${buildout:directory}/src/progect
exclude = tests
zip-packages = True
use_setuptools_pkg_resources = True
# We have a patch overriding imports to enable buildout and eggs
#patch = ${buildout:directory}/google_appserver.patch
[progectconfig]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/app.yaml.in
output = ${progect:src}/app.yaml
[progectsettings]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/settings.py.in
output = ${progect:src}/settings.py
[nosetests]
recipe = zc.recipe.egg
eggs =
NoseGAE
WebTest
progect
nose
extra-paths =
${buildout:directory}/etc
${buildout:directory}/parts/google_appengine
${buildout:directory}/parts/google_appengine/lib/antlr3
${buildout:directory}/parts/google_appengine/lib/django_1_3
${buildout:directory}/parts/google_appengine/lib/fancy_urllib
${buildout:directory}/parts/google_appengine/lib/ipaddr
${buildout:directory}/parts/google_appengine/lib/webob_1_1_1
${buildout:directory}/parts/google_appengine/lib/webapp2/
${buildout:directory}/parts/google_appengine/lib/yaml/lib
${buildout:directory}/parts/google_appengine/lib/simplejson
${buildout:directory}/parts/google_appengine/lib/graphy
interpreter = python
[noseconfig]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/setup.cfg.in
output = ${buildout:directory}/setup.cfg
[zipsymlink]
recipe = svetlyak40wt.recipe.symlinks
path = ${progect:src}
files = ${progect:app-directory}/packages.zip
[versions]
Django = 1.3
gdata = 2.0.16
lxml = 2.3
PIL = 1.1.7
PyCrypto = 2.3
setuptools = 0.6c11
webapp2 = 2.3
WebOb = 1.1.1
WTForms = 1.0.1
# Tools and dependencies
svetlyak40wt.recipe.symlinks = 0.2.1
An app.yaml template can look like
application: ${buildout:appspotname}
version: ${buildout:appspotversion}
runtime: python27
threadsafe: true
api_version: 1
libraries:
- name: PIL
version: "${versions:PIL}"
- name: pycrypto
version: "${versions:PyCrypto}"
- name: django
version: "${versions:Django}"
- name: lxml
version: "${versions:lxml}"
- name: setuptools
version: "${versions:setuptools}"
- name: webapp2
version: "${versions:webapp2}"
- name: webob
version: "${versions:WebOb}"
handlers:
- url: /.*
script:hello_world.app
- url: /_ah/queue/deferred
script: google.appengine.ext.deferred.application
login: admin
builtins:
- deferred: on
Nose tests config template, running tests against src directory (as opposed to the main alternative parts/progect):
[nosetests]
verbosity=1
detailed-errors=1
with-gae=1
gae-application=${progect:src}
gae-lib-root=${buildout:directory}/parts/google_appengine
where=${progect:src}
When I want to set this up, I go to the buildout root directory and type
/path/to/appropriate/python bootstrap.py --distribute
bin/buildout -c buildout.cfg
and then I can run bin/nosetests
or bin/dev_appserver parts/progect