From e9ae3afb295ecee249d868b12b437847080449cb Mon Sep 17 00:00:00 2001 From: Sander Schaminee Date: Mon, 23 Sep 2024 15:31:02 +0200 Subject: [PATCH] Fix doc build (meta module import) --- docs/source/conf.py | 6 +++--- geocatbridge/utils/meta.py | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7c592b3..ba7b1da 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -53,7 +53,7 @@ # General information about the project. company = 'GeoCat' -author = meta.getProperty('author') +author = meta.getAuthor() project = meta.getLongAppName() app_name = meta.getAppName() short_name = meta.getShortAppName() @@ -247,8 +247,8 @@ .. |plugin_name| replace:: {app_name} for QGIS .. |gui_name| replace:: :guilabel:`{app_name}` .. |publisher| replace:: {company} -.. |app_url| replace:: `{app_name} <{meta.getProperty('homepage')}>`__ -.. |min_qgis_ver| replace:: {meta.getProperty('qgisMinimumVersion')} +.. |app_url| replace:: `{app_name} <{meta.getHomeUrl()}>`__ +.. |min_qgis_ver| replace:: {meta.getQqisMinimumVersion()} .. |path_to_settings| replace:: :menuselection:`[path_to_settings]` """ diff --git a/geocatbridge/utils/meta.py b/geocatbridge/utils/meta.py index 473d382..162c20d 100644 --- a/geocatbridge/utils/meta.py +++ b/geocatbridge/utils/meta.py @@ -2,8 +2,6 @@ from pathlib import Path from re import compile -from qgis.core import Qgis - #: GeoCat Bridge plugin namespace PLUGIN_NAMESPACE = "geocatbridge" @@ -130,6 +128,12 @@ def getLongAppNameWithCurrentVersion() -> str: def getCurrentQgisVersion() -> str: """ Returns the current QGIS version string. """ + try: + # Lazy import to prevent crashes when running outside QGIS environment + from qgis.core import Qgis + except (ImportError, ModuleNotFoundError): + return "QGIS version unknown" + version = Qgis().version() revision = Qgis().QGIS_DEV_VERSION if revision: