最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

pygobject - How to determine actual version of GObject bindings using API - Stack Overflow

programmeradmin3浏览0评论

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 is 2.0
  • If I use gi.require_version('Gio', '2.78') before the import I get the error Namespace Gio is already loaded with version 2.0
  • My /usr/lib/x86_64-linux-gnu/pkgconfig/gio-2.0.pc says 2.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 is 2.0
  • If I use gi.require_version('Gio', '2.78') before the import I get the error Namespace Gio is already loaded with version 2.0
  • My /usr/lib/x86_64-linux-gnu/pkgconfig/gio-2.0.pc says 2.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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

For 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.

发布评论

评论列表(0)

  1. 暂无评论