[MacPorts] #40179: Can't import gi.repository after installing gtk3
#40179: Can't import gi.repository after installing gtk3 ---------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Keywords: gi.repository | Port: gtk3 ---------------------------+-------------------------------- After failing to get gtk3 to work, as a hail mark pass, I completely uninstalled MacPorts per section 2.5 of the guide, then reinstalled MacPorts from the source tarball. After that, I only port installed two ports: python27 and gtk3 +x11. That worked without any reported problems. I then coded this simple program which ran okay, but note that it does not use the new gobject-introspection Way of doing things with gtk3: import gobject from gobject import GObject class MyClass(GObject): prop = gobject.property(type=int) def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender) inst = MyClass() inst.connect("notify", cb) inst.prop = 42 Next, I coded the following program which does use the gobject- introspection Way. But it fails indicating an import error for the 'from gi.repository import GObject' statement. Why does installing the gtk3 port on my mac end up with python not being able to find gi.repository? from gi.repository import GObject class MyClass(GObject.GObject): prop = GObject.property(type=int) def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender) inst = MyClass() inst.connect("notify", cb) inst.prop = 42 -- Ticket URL: <https://trac.macports.org/ticket/40179> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: new Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: | Keywords: Port: gtk3 | ------------------------+-------------------------------- Changes (by ryandesign@…): * keywords: gi.repository => * cc: cal@… (added) Old description:
After failing to get gtk3 to work, as a hail mark pass, I completely uninstalled MacPorts per section 2.5 of the guide, then reinstalled MacPorts from the source tarball. After that, I only port installed two ports: python27 and gtk3 +x11. That worked without any reported problems. I then coded this simple program which ran okay, but note that it does not use the new gobject-introspection Way of doing things with gtk3:
import gobject from gobject import GObject
class MyClass(GObject): prop = gobject.property(type=int)
def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender)
inst = MyClass() inst.connect("notify", cb) inst.prop = 42
Next, I coded the following program which does use the gobject- introspection Way. But it fails indicating an import error for the 'from gi.repository import GObject' statement. Why does installing the gtk3 port on my mac end up with python not being able to find gi.repository?
from gi.repository import GObject
class MyClass(GObject.GObject):
prop = GObject.property(type=int)
def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender)
inst = MyClass() inst.connect("notify", cb) inst.prop = 42
New description: After failing to get gtk3 to work, as a hail mark pass, I completely uninstalled MacPorts per section 2.5 of the guide, then reinstalled MacPorts from the source tarball. After that, I only port installed two ports: python27 and gtk3 +x11. That worked without any reported problems. I then coded this simple program which ran okay, but note that it does not use the new gobject-introspection Way of doing things with gtk3: {{{ import gobject from gobject import GObject class MyClass(GObject): prop = gobject.property(type=int) def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender) inst = MyClass() inst.connect("notify", cb) inst.prop = 42 }}} Next, I coded the following program which does use the gobject- introspection Way. But it fails indicating an import error for the 'from gi.repository import GObject' statement. Why does installing the gtk3 port on my mac end up with python not being able to find gi.repository? {{{ from gi.repository import GObject class MyClass(GObject.GObject): prop = GObject.property(type=int) def cb(sender, prop): print "property '%s' changed on %r." % (prop.name, sender) inst = MyClass() inst.connect("notify", cb) inst.prop = 42 }}} -- Comment: Remember to use WikiFormatting when writing in Trac. I'm Cc'ing the maintainer of gtk3; maybe he knows the answer to your question. -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:1> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: invalid | Keywords: Port: gtk3 | ------------------------+-------------------------------- Changes (by cal@…): * status: new => closed * resolution: => invalid Comment: You probably want the `py27-gobject3` port. -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:2> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: invalid | Keywords: Port: gtk3 | ------------------------+-------------------------------- Comment (by istlota@…): Replying to [comment:2 cal@…]:
You probably want the `py27-gobject3` port.
Thanks. It continues to amaze me how promptly MacPorts support responds to opened tickets, especially considering that I opened this ticket on a Sunday. 'port installed' confirmed that py27-gobject was installed instead of py27-gobject3. And, after I installed py27-gobject3, I am now able to correctly 'from gi.repository import Gtk'. But, note, we are still left with my initial question unanswered. Ergo, why did installing the gtk3 port on my mac end up with python not being able to find gi.repository? Note that I began by uninstalling MacPorts, then reinstalled it from the source tarball and only installed two ports [python27 and gtk3 +x11]. Which means gtk3 incorrectly installed py27-gobject when it needed to install py27-gobject3 to operate properly. To be more specific, gtk3 installed at-spi2-atk as a dependency, which installed dbus-python27 as a dependency, which installed p27-gobject as a dependency. Is this one of those catch-22s the entire industry is having to just accept for now due to having two Ways of binding Python to GTK [GTK2 and PyGtk vs. GTK3 and PyGObject] which can and often do break each other when both are used on the same machine? Or, can the gtk3 portfile, perhaps, be modified to install the appropriate flavor of gobject3 [py27-gobject3 in my case] as a dependency? -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:3> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: invalid | Keywords: Port: gtk3 | ------------------------+-------------------------------- Comment (by cal@…): Replying to [comment:3 istlota@…]:
Thanks. It continues to amaze me how promptly MacPorts support responds to opened tickets, especially considering that I opened this ticket on a Sunday.
I just happened to be at doing MacPorts-related stuff anyway. Replying to [comment:3 istlota@…]:
Ergo, why did installing the gtk3 port on my mac end up with python not being able to find gi.repository?
The software installed by the `gtk3` port does not need the python bindings from `py27-gobject3`. This is also the reason why there is no dependency from `gtk3` to `py27-gobject3` (also: if there was, which version of python should we depend on? There is `py{26,27,31,32,33}-gobject3`). Replying to [comment:3 istlota@…]:
Which means gtk3 incorrectly installed py27-gobject when it needed to install py27-gobject3 to operate properly. To be more specific, gtk3 installed at-spi2-atk as a dependency, which installed dbus-python27 as a dependency, which installed p27-gobject as a dependency.
First: `gtk3` does not need `py27-gobject3` to operate properly. Dependent software that uses the python bindings for Gtk might, but that software should declare a dependency on `py27-gobject3` then. I don't know (despite being the maintainer for this port) why `at- spi2-atk` needs `dbus-python27`. `dbus-python27` needs a dependency on `py27-gobject` (the gtk2 version), because it uses an old API provided by `py27-gobject` (but I just noticed the relevant file `./dbus/gobject_service.py` in the `dbus-python27` sources also supports using `py27-gobject3`). You could file a bug requesting to change the dependency to `py27-gobject3` instead of `py27-gobject`. But even this won't solve your original issue, because `gtk3 -x11 +quartz` doesn't pull in `at-spi2-atk` and thus doesn't have a transitive dependency on `py27-gobject3`. Replying to [comment:3 istlota@…]:
Is this one of those catch-22s the entire industry is having to just accept for now due to having two Ways of binding Python to GTK [GTK2 and PyGtk vs. GTK3 and PyGObject] which can and often do break each other when both are used on the same machine?
How do PyGtk and PyGObject break each other? I haven't noticed any problems with running both versions simultaneously. Replying to [comment:3 istlota@…]:
Or, can the gtk3 portfile, perhaps, be modified to install the appropriate flavor of gobject3 [py27-gobject3 in my case] as a dependency?
As explained above, this is not the correct way to fix this. Dependent software needs to depend on `py*-gobject3` if it needs the Gtk Python bindings. If you need them for a project outside MacPorts I'm afraid you will have to install them manually. -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:4> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: invalid | Keywords: Port: gtk3 | ------------------------+-------------------------------- Comment (by istlota@…): I see more clearly now why py27-gobject3, from a maintainer's perspective, should not be a dependency of gtk3. Still, from a user's perspective, his gtk3 code will need to import Gtk from gi.repository. Am I correct that py27-gobject3 is what creates my gi.repository dynamic binding from python to gtk3? -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:5> MacPorts <http://www.macports.org/> Ports system for OS X
#40179: Can't import gi.repository after installing gtk3 ------------------------+-------------------------------- Reporter: istlota@… | Owner: macports-tickets@… Type: defect | Status: closed Priority: Normal | Milestone: Component: ports | Version: 2.2.0 Resolution: invalid | Keywords: Port: gtk3 | ------------------------+-------------------------------- Comment (by cal@…): Replying to [comment:5 istlota@…]:
Am I correct that py27-gobject3 is what creates my gi.repository dynamic binding from python to gtk3?
Partially, yes. `py27-gobject3` provides the `gi.repository` to import from. What can be imported from `gi.repository` depends on what GObject- Introspection typelibs are available in `/opt/local/lib/girepository-1.0/`. The GObject typelib is created by the gobject-introspection port; other typelibs might be installed by different ports: e.g., the Gtk-3.0 typelib is installed by the gtk3 port. -- Ticket URL: <https://trac.macports.org/ticket/40179#comment:6> MacPorts <http://www.macports.org/> Ports system for OS X
participants (1)
-
MacPorts