This page describes how to install and use legacy bundled services with the Python 3 runtime for the standard environment. Your app must access the bundled services through the App Engine services SDK for Python 3.
Before you begin
- Refer to the list of legacy bundled services APIs you can call in the Python runtime.
- Before starting a migration project to Python 3, see the runtime migration overview and migration considerations when using legacy bundled services.
Installing the App Engine services SDK
To install the App Engine services SDK, follow these steps:
Include the SDK with your app by adding the following line to your
requirements.txtfile:appengine-python-standard>=1.0.0You can find the SDK on GitHub under the
appengine-python-standardrepository, and on PyPI.Add the following code in your main Python script. This code creates WSGI middleware that sets the variables required to enable your API calls.
Flask
from flask import Flask from google.appengine.api import wrap_wsgi_app app = Flask(__name__) app.wsgi_app = wrap_wsgi_app(app.wsgi_app)Django
from DJANGO_PROJECT_NAME.wsgi import application from google.appengine.api import wrap_wsgi_app app = wrap_wsgi_app(application)Pyramid
from pyramid.config import Configurator from google.appengine.api import wrap_wsgi_app config = Configurator() # make configuration settings app = config.make_wsgi_app() app = wrap_wsgi_app(app)WSGI
import google.appengine.api def app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield b'Hello world!\n' app = google.appengine.api.wrap_wsgi_app(app)Update your
app.yamlfile to specify one or more legacy bundled services. For example:app_engine_bundled_services: - datastore_v3 - memcache - userIf you use features such as
login: adminin thehandlerssection ofapp.yamlfile, enable the Users API by configuring theusersetting in theapp_engine_bundled_serviceslist.To deploy your app, use the
gcloud app deploycommand.
Migration considerations
You should be aware of the following considerations if you are migrating to the Python 3 runtime and your app uses legacy bundled services.