0

I'm want to debug my python application on google app engine with pudb. I've installed buildout without of using virtualenv and created config file for it buildout.cfg:

[buildout]
develop = .
parts =
    python
    app
    pudb
    nosetests
    zipsymlink

eggs =
    gaeapp

unzip = true

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[app]
recipe = rod.recipe.appengine
url = https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.11.zip
server-script = dev_appserver
src = ${buildout:directory}/src/gaeapp
exclude = tests
zip-packages = True

[pudb]
recipe = zc.recipe.egg
eggs =
    gaeapp
    pudb

[nosetests]
recipe = zc.recipe.egg
eggs =
    NoseGAE
    WebTest
    gaeapp
    nose

extra-paths =
    ${buildout:directory}/etc
    ${buildout:directory}/parts/google_appengine
    ${buildout:directory}/parts/google_appengine/lib/antlr3
    ${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

interpreter = python

[zipsymlink]
recipe = svetlyak40wt.recipe.symlinks
path = ${app:src}
files = ${app:app-directory}/packages.zip

# Tools and dependencies
svetlyak40wt.recipe.symlinks = 0.2.1

My app.yaml:

application: gaeapp
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /_ah/spi/.*
  script: gae_api.APPLICATION

libraries:
- name: pycrypto
  version: latest

- name: endpoints
  version: 1.0

- name: setuptools
  version: latest

- name: webob
  version: latest

- name: webapp2
  version: latest

builtins:
- deferred: on

My setup.py:

from setuptools import setup, find_packages

setup(
    name = "gaeapp",
    version = "1.0",
    url = 'http://github.com/blabla/gaeapp',
    license = 'BSD',
    description = "Just a test GAE app.",
    author = 'WOW',
    packages = find_packages('src'),
    package_dir = {'': 'src'},
    install_requires = ['setuptools', 'pudb']
)

Everything installed fine, nosetests and devappserver are works. Run server:

bin/devappserver parts/app

I'm trying to use pudb in code:

import pudb; pudb.set_trace();

And just see such error:

ImportError: No module named pudb

Are there any ways to use pudb with GAE apps?

Igor Komar
  • 381
  • 1
  • 8
  • 16

1 Answers1

0

You need to tell rod.recipe.appengine what eggs to copy:

packages =
    pudb
    urwid
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • I just tried, after I runned `bin/buildout` and It's didn't help, have the same error. – Igor Komar Sep 22 '14 at 23:38
  • what is in the `parts/app` directory? Can you also look into the zip file produced for the libraries? – Martijn Pieters Sep 23 '14 at 06:44
  • yes, of course. If I write in `app` part just this code as you said `eggs = gaeapp`, the `parts/app` structure is: `gaeapp` - copy of my project. Else if I write in `app` part this `eggs = gaeapp, pudb` the `parts/app` will be: `gaeapp` - copy of my project, `EGGS-INFO` , `packages.zip` - there are a file `pkg_resources.py` in which: `def _dummy_func(*args): pass declare_namespace = _dummy_func resource_filename = _dummy_func` – Igor Komar Sep 23 '14 at 08:37
  • @kazantip: and that's the full contents of `packages.zip`? Then the dependency wasn't copied in. Try adding `pudb` to the eggs list explicitly. – Martijn Pieters Sep 23 '14 at 09:08
  • ok, I've added `pudb` in `app -> eggs` list, the `packages.zip` hasn't changed. – Igor Komar Sep 23 '14 at 09:20
  • @kazantip: next option: `packages = pudb`. – Martijn Pieters Sep 23 '14 at 09:23
  • Added `packages = pudb` and in packages.zip appeared folder packages, which contains pudb. Now `import pudb` is - ok, but when I write `pudb.set_trace()` => I have the next error `File "packages.zip/pudb/debugger.py", line 5, in ImportError: No module named urwid` – Igor Komar Sep 23 '14 at 10:11
  • @kazantip: so `urwid` is another dependency you need to add. – Martijn Pieters Sep 23 '14 at 10:26
  • @kazantip: Personally, I use [`appfy.recipe.gae`](https://pypi.python.org/pypi/appfy.recipe.gae/0.9.7) instead; gives me more control over what is included, as I can then specify in app.yaml what not to upload (e.g. exclude debugging tools and local libraries GAE has local copies of for me). – Martijn Pieters Sep 23 '14 at 10:28
  • I'm sorry, but I really doesn't know why google app engine gives such error now: `google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 886, in load_module` `ImportError: No module named termios`. Think it's strange – Igor Komar Sep 23 '14 at 13:23
  • You are deploying a debugger library that relies on access to the terminal. There is no terminal on GAE, and that means there are no terminal-specific libraries like `termios` either. – Martijn Pieters Sep 23 '14 at 13:26
  • yes, but this error shows locally in dev server, I didn't deployed it in cloud. – Igor Komar Sep 23 '14 at 13:33
  • But the dev server tries to faithfully reproduce the server environment for you. That includes hiding stdlib libraries not available on GAE. – Martijn Pieters Sep 23 '14 at 13:42
  • so, thanks a lot, now I will be know, that it impossible to use comfortable debugger while developing GAE apps. – Igor Komar Sep 23 '14 at 13:46