I need to do buildout google app engine. I wrote config file buildout.cfg:
[buildout]
parts =
gae_sdk
gae_tools
app_lib
unzip = true
relative-paths = true
download-cache = etc/downloads
develop-eggs-directory = etc/develop-eggs
parts-directory = etc/parts
[gae_sdk]
recipe = appfy.recipe.gae:sdk
url = http://googleappengine.googlecode.com/files/google_appengine_1.4.3.zip
destination = ${buildout:parts-directory}
hash-name = false
clear-destination = true
[gae_tools]
recipe = appfy.recipe.gae:tools
sdk-directory = ${gae_sdk:destination}/google_appengine
[app_lib]
recipe = appfy.recipe.gae:app_lib
lib-directory = src/distlib
use-zipimport = false
eggs =
webapp2
After run command python <(curl http://python-distribute.org/bootstrap.py) –distribute and ./bin/buildout GAE doesn`t want to work. Server is working but the most simple Hello world from GAE site shows a mistake importError: No module named webapp2. On the first I need to run Hello world, after my script. file and folder structure is: progect/buildout.cfg progect/src/hello_world.py , app.yaml
file app.yaml:
application: hello_world
version: 1
runtime: python
api_version: 1
threadsafe: true
handlers:
- url: /.*
script:hello_world.app
builtins:
- deferred: on
file hello_world.py:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers = ‘text/plain’
self.response.out.write('Hello, webapp World!')
app = webapp2.WSGIApplication(,
debug=True)
help me, please.
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 zippedpackageswhere zippedpackages.py looks likeAlso note that settings.py and app.yaml are generated from templates and variables like
appspotnameandappspotversionare 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.
An app.yaml template can look like
Nose tests config template, running tests against src directory (as opposed to the main alternative parts/progect):
When I want to set this up, I go to the buildout root directory and type
and then I can run
bin/nosetestsorbin/dev_appserver parts/progect