Search code examples
google-app-engineujson

How to use ujson with Google App Engine


According to the official list of built-in libraries, ujson is available. However, the following app.yaml snippet:

libraries:
- name: ujson
  version: '1.35'

...generates this error:

Usage: appcfg.py [options] update <directory> | [file, ...]

appcfg.py: error: Error parsing ./app.yaml: the library "ujson" is not supported
  in "./app.yaml", line 89, column 1.

If I try to use other supported C libraries like numpy, it works fine. I am running SDK 159.0.0 (latest) and can even see a "ujson" entry in google-cloud-sdk/lib/googlecloudsdk/third_party/appengine/api/appinfo.py.

Any clue why ujson isn't usable?


Solution

  • ujson v1.35 was added to the app engine runtime in Python SDK version 1.9.55.

    This sdk version wasn't included in the gcloud sdk until v161.0.0 (2017-06-28):

    Updated App Engine components for Python to version 1.9.55. Please visit the release notes for details


    Anecdote:

    Some of us still prefer appcfg.py update . instead of gcloud app deploy app.yaml.(We are a rare and dying breed :D).

    So in the past I noticed that the appcfg.py tool I was using was an older version from the older app engine tooling. Doesn't come with all the gcloud components update awesomeness. You had to download the binaries each time.

    which appcfg.py should reveal the exact one being used which for me was:

    $ ~/google_appengine/appcfg.py
    

    I can't say I wasn't warned enough. Besides, I kept seeing this advice/warning each time I ran gcloud components update:

    WARNING: There are older versions of Google Cloud Platform tools on your system PATH. Please remove the following to avoid accidentally invoking these old tools:

    /Users/jeff/google_appengine/endpointscfg.py
    /usr/local/bin/endpointscfg.py
    /Users/jeff/google_appengine/dev_appserver.py
    

    So update to the latest version, update your paths to point to the right appcfg, and enjoy ujson or any of the goodies as and when they drop.

    $ ~/google-cloud-sdk/platform/google_appengine/appcfg.py update .