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?
- If I check
Gio._version
the answer is2.0
- If I use
gi.require_version('Gio', '2.78')
before the import I get the errorNamespace Gio is already loaded with version 2.0
- My
/usr/lib/x86_64-linux-gnu/pkgconfig/gio-2.0.pc
says2.80
but I'm not sure that users will have a.PC
file to check.
Any solution, besides checking that the required functions are in the module directory?
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?
- If I check
Gio._version
the answer is2.0
- If I use
gi.require_version('Gio', '2.78')
before the import I get the errorNamespace Gio is already loaded with version 2.0
- My
/usr/lib/x86_64-linux-gnu/pkgconfig/gio-2.0.pc
says2.80
but I'm not sure that users will have a.PC
file to check.
Any solution, besides checking that the required functions are in the module directory?
Share Improve this question asked Mar 29 at 20:54 xenoidxenoid 9,0264 gold badges28 silver badges52 bronze badges1 Answer
Reset to default 1For GLib specifically part of its API is GLib.MAJOR_VERSION
, GLib.MINOR_VERSION
, and GLib.MICRO_VERSION
: https://docs.gtk./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.