From 9429ac5f413a4b7e8e7ac849267975db42ee260f Mon Sep 17 00:00:00 2001 From: Peter Eisenmann Date: Fri, 29 Mar 2024 02:14:00 +0100 Subject: [PATCH] gir: use GLib to get gir base paths --- blueprintcompiler/gir.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/blueprintcompiler/gir.py b/blueprintcompiler/gir.py index cb73961..e57fe50 100644 --- a/blueprintcompiler/gir.py +++ b/blueprintcompiler/gir.py @@ -25,7 +25,8 @@ from functools import cached_property import gi # type: ignore gi.require_version("GIRepository", "2.0") -from gi.repository import GIRepository # type: ignore +gi.require_version("GLib", "2.0") +from gi.repository import GIRepository, GLib # type: ignore from . import typelib, xml_reader from .errors import CompileError, CompilerBugError @@ -64,11 +65,13 @@ def collect_gir_search_paths(): if _gir_search_paths_initalized: return + base_paths = [ + GLib.get_user_data_dir(), + *GLib.get_system_data_dirs(), + ] + global _gir_search_paths - if data_paths := os.environ.get("XDG_DATA_DIRS"): - _gir_search_paths += [ - os.path.join(path, "gir-1.0") for path in data_paths.split(os.pathsep) - ] + _gir_search_paths = [os.path.join(path, "gir-1.0") for path in base_paths] _gir_search_paths_initalized = True