Python <--> d-bus <--> c++ woes

Kip Warner kip at thevertigo.com
Wed Mar 20 18:24:50 PDT 2013


On Thu, 2013-03-07 at 12:27 +0000, Simon McVittie wrote:
> C libraries for use from C/C++
> ==============================
> 
> libdbus (libdbus-1.so.3, pkg-config: dbus-1, C naming convention:
> dbus_foo()) is the library provided by the reference implementation of
> D-Bus.
> 
> dbus-glib (libdbus-glib-1.so.2, pkg-config: dbus-glib-1, C naming
> convention: dbus_g_foo()) is a deprecated GLib binding (wrapper) for
> libdbus. It's "the old way" to use D-Bus in GLib applications.
> 
> GDBus (part of GIO: libgio-2.0.so.0, pkg-config: gio-2.0, C naming
> convention: g_dbus_foo()) is a D-Bus library that can be used as an
> alternative to the combination of libdbus and dbus-glib. It's "the new
> way" to use D-Bus in GLib applications.
> 
> All three are written in C themselves, but can be used from C++.

Thanks a lot, Simon. That was incredibly useful. As I understand it, at
least in the context of Ubuntu Precise and later, if using the GDBus
bindings from Python3, an application should only need to rely on the
python3-gi package being installed, and not python3-dbus? I'm assuming
the latter is the legacy libdbus or dbus-glib bindings?

> gdbus (without the capital letters) is a command-line tool provided by
> GIO, which uses GDBus to do things on D-Bus. You might find it useful
> for debugging, but it's not directly relevant.

Useful to know anyways. Thank you.

> Python
> ======
> 
> dbus-python ("import dbus") is a wrapper around libdbus. It also
> contains a wrapper around part of dbus-glib ("import
> dbus.mainloop.glib"), which you need to use unless you have an
> alternative main-loop-integration module (like the one from Qt). It
> supports Python 3, but only if you have a very recent version.

That explains why Fedora has a package called "dbus-python" which I am
assuming is the same as "python-dbus" on Ubuntu? In any case, I imagine
I don't need either if I take your advice and go the GDBus route, which
I did.

> Still, switching from using a signal to using a method call would mean
> you always get feedback - either from the dbus-daemon, or from the app -
> on whether the C++ app is ready yet.

Ok, so the C++ application's D-Bus relevant code is here:


<https://bazaar.launchpad.net/~avaneya/avaneya/trunk/view/head:/Extras/Viking%20Lander%20Remastered/Extractor/Source/DBusInterface.cpp>

The Python application's D-Bus relevant code is here:


<https://bazaar.launchpad.net/~avaneya/avaneya/trunk/view/head:/Extras/Viking%20Lander%20Remastered/Launcher/Source/RecoveryPage.py>

How does it look? I hope I managed to implement your advice properly.

> On Debian/Ubuntu, the runtime library, libgio-2.0.so.0, is part of the
> libglib2.0-0 package. Gtk depends on GIO, so it's widely-installed
> (GNOME, XFCE and Firefox users will certainly have it).
> 
> Ubuntu has had a sufficiently recent version of GIO since 11.10.

Would you say that under Ubuntu, just checking to make sure python3-gi
is installed is sufficient? Like you said, it's installed by default
anyways.

Thanks a lot for your help =)

-- 
Kip Warner -- Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20130320/483a4f26/attachment.pgp>


More information about the dbus mailing list