Re: how to set PYTHONPATH to allow overrides in extra directories?



Or, here's a simpler test case without reference to gedit.  (I have pygobject 3.9.1, by the way.)

1. Create files ~/test/gi/__init__.py and ~/test/gi/overrides/__init__.py, each containing

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

2. Run these commands:

$ export PYTHONPATH=~/test
$ python3
Python 3.3.2 (default, May 21 2013, 21:07:13) 
[GCC 4.8.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import foo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gi/repository/__init__.py", line 25, in <module>
    from ..importer import DynamicImporter
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 28, in <module>
    from .module import DynamicModule
  File "/usr/lib/python3/dist-packages/gi/module.py", line 37, in <module>
    from .overrides import registry
  File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 5, in <module>
    from gi import PyGIDeprecationWarning
ImportError: cannot import name PyGIDeprecationWarning

adam

On Sat, May 25, 2013 at 2:10 PM, Adam Dingle <adam medovina org> wrote:
gedit installs a file Gedit.py whch contains overrides for GObject introspection.  I've built and installed gedit locally (in /home/adam/local), and I have Gedit.py at

  /home/adam/local/lib64/python3/dist-packages/gi/overrrides/Gedit.py

I'm trying to get Python to recognize this overrides file.  According to this bug which was closed last August, it should be possible:

  https://bugzilla.gnome.org/show_bug.cgi?id=680913

Following the instructions at https://bugzilla.gnome.org/show_bug.cgi?id=680913#c24, I've done the following:

- My PYTHONPATH is /home/adam/local/lib64/python3/dist-packages .
- I've created these files:

  /home/adam/local/lib64/python3/dist-packages/gi/__init__.py
  /home/adam/local/lib64/python3/dist-packages/gi/overrrides/__init__.py

Both of these files contain this text exactly:

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

But now when I run gedit and try to enable a plugin which uses Python I see this:

Traceback (most recent call last):
  File "/home/adam/local/lib64/gedit/plugins/quickopen/__init__.py", line 20, in <module>
    from .popup import Popup
  File "/home/adam/local/lib64/gedit/plugins/quickopen/popup.py", line 23, in <module>
    from gi.repository import Gio, GObject, Pango, Gtk, Gdk, Gedit
  File "/usr/lib/python3/dist-packages/gi/repository/__init__.py", line 25, in <module>
    from ..importer import DynamicImporter
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 28, in <module>
    from .module import DynamicModule
  File "/usr/lib/python3/dist-packages/gi/module.py", line 37, in <module>
    from .overrides import registry
  File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 5, in <module>
    from gi import PyGIDeprecationWarning
ImportError: cannot import name PyGIDeprecationWarning

This error does not occur when PYTHONPATH is not set.

What am I doing wrong?  Any clue?

adam


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]