mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
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). Migration guide is here [2] [1]: https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/320 [2]: https://docs.gtk.org/girepository/migrating-gi.html This commit adds suppport for importing with "gi.require_version("GIRepository", "3.0") and falling back to the existing "GIRepository 2.0" if not found.
This commit is contained in:
parent
778a979714
commit
ac70ea7403
1 changed files with 16 additions and 4 deletions
|
@ -24,8 +24,20 @@ from functools import cached_property
|
|||
|
||||
import gi # type: ignore
|
||||
|
||||
gi.require_version("GIRepository", "2.0")
|
||||
from gi.repository import GIRepository # 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
|
||||
|
||||
from . import typelib, xml_reader
|
||||
from .errors import CompileError, CompilerBugError
|
||||
|
@ -42,7 +54,7 @@ def add_typelib_search_path(path: str):
|
|||
|
||||
|
||||
def get_namespace(namespace: str, version: str) -> "Namespace":
|
||||
search_paths = [*GIRepository.Repository.get_search_path(), *_user_search_paths]
|
||||
search_paths = [*_repo.get_search_path(), *_user_search_paths]
|
||||
|
||||
filename = f"{namespace}-{version}.typelib"
|
||||
|
||||
|
@ -74,7 +86,7 @@ def get_available_namespaces() -> T.List[T.Tuple[str, str]]:
|
|||
return _available_namespaces
|
||||
|
||||
search_paths: list[str] = [
|
||||
*GIRepository.Repository.get_search_path(),
|
||||
*_repo.get_search_path(),
|
||||
*_user_search_paths,
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue