python-3.xgtk3apt-getcentos8dnf

Installing gir1.2-gtk-3.0 on Centos


On Ubuntu there is a package for installing gir1.2-gtk-3.0:

sudo apt install gir1.2-gtk-3.0

Centos 'dnf provides gir1*' results in error: No Matches found

The package can be found on https://github.com/roojs/gir-1.2-gtk-3.0, but there is no installation script, only files with extension *.gir

How can it be installed manually?

The installation is necessary to avoid:

gi.require_version("Gtk", "3.0") Python: Namespace Gtk not available

Other packages gobject-introspection, python3-gi are alredy installed


Solution

  • The gir1.2-* packages are for Debian and Debian-derived distributions.

    The introspection data that is consumed by the Python bindings is provided by typelib files, for instance:

    /usr/lib64/girepository-1.0/Gtk-3.0.typelib
    

    These files are provided by the library package, on CentOS, alongside the actual shared library. For instance, the Gtk-3.0.typelib file is provided by the gtk3 package.

    The GIR files are XML descriptions of the API that are only used when generating the introspection data; they are provided by the devel package, on CentOS. For instance, the Gtk-3.0.gir file is provided by the gtk3-devel package.

    If pygobject cannot find the typelib file, it's likely that you've installed it in some non-standard location. You must use the GI_TYPELIB_PATH environment variable to list all the locations where the typelib data might be found, as a colon-separated list of paths.