pygobjectgobject

How to determine actual version of GObject bindings using API


I'm writing a Python script that uses a "recent" functionality in the Gio library.

How can I check that on the users system the library is recent enough?

Any solution, besides checking that the required functions are in the module directory?


Solution

  • For GLib specifically part of its API is GLib.MAJOR_VERSION, GLib.MINOR_VERSION, and GLib.MICRO_VERSION: https://docs.gtk.org/glib/version.html

    There might be a pygobject function for this but I didn't see one.

    As you found out most of the gi methods relate to the API version, not library version. So like Gtk 3.0 vs 4.0.

    I'll also add for dynamic languages you would sometimes check at runtime what is available, hasattr(GLib, 'some_new_method_i_want'), instead of checking for version numbers.