Re: Extending g-ir bindings
- From: David Nečas <yeti physics muni cz>
- To: python-hackers-list gnome org
- Subject: Re: Extending g-ir bindings
- Date: Sun, 2 Oct 2011 19:11:55 +0200
On Sun, Oct 02, 2011 at 04:32:38PM +0300, Paul Colomiets wrote:
> If the only problem is the import. Than you can try:
>
> import gi.overrides
> gi.overrrides.__path__.append('/path/to/your/modules')
>
> Then `from gi.overrides import whatever` will search for the
> `/path/to/your/modules/whatever.py`.
Thanks, this at least makes importing possible. To make it work
automatically, i.e. permit doing just
from gi.repository import MyModule
provided that the modules are in path, gi/__init__.py needs to do
something like
import gi.overrides, sys, os.path
for pythondir in sys.path:
odir = os.path.join(pythondir, 'gi', 'overrides')
if odir not in gi.overrides.__path__:
gi.overrides.__path__.append(os.path.join(pythondir, 'gi', 'overrides'))
But this is ugly on several levels, starting from fixing the search path
using the snapshot of sys.path in a specific instant.
Yeti
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]