python - gobject-introspection overrides cause import errors -


i using gobject-introspection in python2.7 on ubuntu raring , run import error while building packages. have isolated minimal set of steps replicate it:

  1. make local directory structure:

    gi:         __init__.py         overrides:                 __init__.py 
  2. put standard boilerplate

    from pkgutil import extend_path  __path__ = extend_path(__path__, __name__) print __path__, __name__ 

    in both __init__.py files.

  3. from directory containing local copy of gi, run following:

    python -c "from gi import repository" 
  4. i error message looks like:

    traceback (most recent call last):   file "<string>", line 1, in <module>   file "/usr/lib/python2.7/dist-packages/gi/repository/__init__.py", line 25, in         <module>     ..importer import dynamicimporter   file "/usr/lib/python2.7/dist-packages/gi/importer.py", line 28, in <module>     .module import dynamicmodule   file "/usr/lib/python2.7/dist-packages/gi/module.py", line 37, in <module>     .overrides import registry importerror: cannot import name registry 

any explanation? can't find decent documentation of intended behavior because gobject-introspection seems poorly documented project. appreciated!

from python documentation:

the __init__.py files required make python treat directories containing packages; done prevent directories common name, such string, unintentionally hiding valid modules occur later on module search path.

simply having __init__.py files accessible running directory, telling interpreter that implementation of gi module. usage of main gi module not go correctly.

now, why print error coming /usr/lib ? because gi found in local/gi, gi.repository found in /usr/lib/python2.7/dist-packages/gi/repository . running /usr/lib/python2.7/dist-packages/gi/repository/__init__.py. there, imports other submodules correctly, when tries import overrides finds local stub in gi/overrides. stub not define registry, have fail.

try , put registry='dumb_string' in gi/overrides/__init__.py , see error gone.


Comments