Compare commits

..

2 commits

Author SHA1 Message Date
Jordan Petridis
719c2ce5c6 Merge branch 'alatiera/bump-gi-requirment' into 'main'
Port to libgirepository-2.0

See merge request jwestman/blueprint-compiler!218
2024-12-10 01:37:10 +00:00
Jordan Petridis
54164305a3
Port to libgirepository-2.0
pygobject 3.52 has switched [1] to using libgirepository-2.0 which
comes from glib itself now, rather than the 1.0 which came from
gobject-introspection.

This means that it fails to load the incompatible "GIRepository 2.0"
and thus must be ported to 3.0 (which is provided by
libgirepository-2.0).

This also means that we have to bump the minimum version of glib to
2.80

Migration guide is here [2]

[1]: https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/320
[2]: https://docs.gtk.org/girepository/migrating-gi.html
2024-11-17 12:13:03 +02:00
2 changed files with 9 additions and 16 deletions

View file

@ -24,20 +24,8 @@ from functools import cached_property
import gi # type: ignore
try:
gi.require_version("GIRepository", "3.0")
from gi.repository import GIRepository # type: ignore
_repo = GIRepository.Repository()
except ValueError:
# We can remove this once we can bump the minimum dependencies
# to glib 2.80 and pygobject 3.52
# dependency('glib-2.0', version: '>= 2.80.0')
# dependency('girepository-2.0', version: '>= 2.80.0')
gi.require_version("GIRepository", "2.0")
from gi.repository import GIRepository # type: ignore
_repo = GIRepository.Repository
gi.require_version("GIRepository", "3.0")
from gi.repository import GIRepository # type: ignore
from . import typelib, xml_reader
from .errors import CompileError, CompilerBugError
@ -54,7 +42,8 @@ def add_typelib_search_path(path: str):
def get_namespace(namespace: str, version: str) -> "Namespace":
search_paths = [*_repo.get_search_path(), *_user_search_paths]
repo = GIRepository.Repository()
search_paths = [*repo.get_search_path(), *_user_search_paths]
filename = f"{namespace}-{version}.typelib"
@ -85,8 +74,9 @@ def get_available_namespaces() -> T.List[T.Tuple[str, str]]:
if len(_available_namespaces):
return _available_namespaces
repo = GIRepository.Repository()
search_paths: list[str] = [
*_repo.get_search_path(),
*repo.get_search_path(),
*_user_search_paths,
]

View file

@ -7,6 +7,9 @@ datadir = join_paths(prefix, get_option('datadir'))
py = import('python').find_installation('python3')
dependency('glib-2.0', version: '>= 2.80.0')
dependency('girepository-2.0', version: '>= 2.80.0')
subdir('docs')
configure_file(