Amazon.co.jp ウィジェット
スポンサードリンク

2008年09月25日

GAE 1.1.3 の zipimport は py_zipimport

GAE 1.1.3 + zipimport + setuptools

appengine-monkey + zipimport の合わせ技で Pylons 0.9.7 を動かそうとしたのだが、うまくいかない。

setuptools が entry points を探しに行く段階で、以下のように怒られてしまいます。

Error loading application:
Traceback (most recent call last):
  File "/base/data/home/apps/bia-hanoi/2.23/paste-deploy.py", line 51, in 
    app = loadapp(CONF_FILE)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 210, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 230, in loadobj
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 254, in loadcontext
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 284, in _loadconfig
    return loader.get_context(object_type, name, global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 411, in get_context
    global_additions=global_additions)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 506, in _pipeline_app_context
    APP, pipeline[-1], global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 415, in get_context
    section)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 437, in _context_from_use
    object_type, name=use, global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 367, in get_context
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 254, in loadcontext
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 284, in _loadconfig
    return loader.get_context(object_type, name, global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 415, in get_context
    section)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 437, in _context_from_use
    object_type, name=use, global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 367, in get_context
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 254, in loadcontext
    global_conf=global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 291, in _loadegg
    return loader.get_context(object_type, name, global_conf)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 567, in get_context
    object_type, name=name)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg/paste/deploy/loadwsgi.py", line 587, in find_egg_entry_point
    pkg_resources.require(self.spec)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 627, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 522, in resolve
    env = Environment(self.entries)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 682, in __init__
    self.scan(search_path)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 711, in scan
    for dist in find_distributions(item):
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1673, in find_on_path
    for dist in find_distributions(os.path.join(path_item, entry)):
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1620, in find_in_zip
    metadata = EggMetadata(importer)
  File "/base/data/home/apps/bia-hanoi/2.23/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1509, in __init__
    self.zipinfo = zipimport._zip_directory_cache[importer.archive]
AttributeError: 'module' object has no attribute '_zip_directory_cache'

App Engine Console

App Engine Console を借りて zipimport の中身を見てみる。


>>> import zipimport
>>> help(zipimport)

Help on module py_zipimport:

py_zipimport = <module 'py_zipimport' from '/base/python_dist/lib/python2.5/py_zipimport.py'>

GAE 1.1.3 の zipimport は py_zipimport で、py_zipimport は_zip_directory_cache をサポートしていないということでしょうか。あるいは、 GAE の仕組み上、 _zip_directory_cache を提供できない理由がある?

いずれにせよ、zipimport と entry points を併用できないのは痛い。

Tips

以下、調査の過程で見つけたTipsです。
  • GAE でも以下のように出力先を明示的に与えると、開発環境で pdb が利用できます。
    
    def set_trace():
        import pdb, sys
        debugger = pdb.Pdb(stdin=sys.__stdin__,
                           stdout=sys.__stdout__)
        debugger.set_trace(sys._getframe().f_back)
    
    (参考: Python: Debugging Google App Engine Apps Locally)
  • appengine-monkey r35 を GAE 1.1.3 で利用しようとすると、"import site" でエラーが発生しますが、 paste-deploy.py の い "import site; site = reload(site)" を sys.path 設定の後に持ってくると動作します。
タグ:Python appengine
posted by junya at 02:47 | Comment(0) | TrackBack(0) | 日記 | このブログの読者になる | 更新情報をチェックする
この記事へのコメント
コメントを書く
お名前:

メールアドレス:

ホームページアドレス:

コメント:

認証コード: [必須入力]


※画像の中の文字を半角で入力してください。
この記事へのトラックバックURL
http://blog.seesaa.jp/tb/107099367

この記事へのトラックバック
×

この広告は1年以上新しい記事の投稿がないブログに表示されております。