admin管理员组文章数量:1356272
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.
本文标签: pygobjectHow to determine actual version of GObject bindings using APIStack Overflow
版权声明:本文标题:pygobject - How to determine actual version of GObject bindings using API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744003831a2574340.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论