[meld/build-updates: 11/26] Change conf.py to single-source version from meson.build
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/build-updates: 11/26] Change conf.py to single-source version from meson.build
- Date: Sun, 11 Sep 2022 02:17:15 +0000 (UTC)
commit b4a72b630283ca993bb37fc07fed51cd11259a05
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Sep 11 08:18:17 2022 +1000
Change conf.py to single-source version from meson.build
meld/conf.py.in | 26 +++++++++++++++++++++-----
meld/meson.build | 2 ++
2 files changed, 23 insertions(+), 5 deletions(-)
---
diff --git a/meld/conf.py.in b/meld/conf.py.in
index e622f905..e78f7ee7 100644
--- a/meld/conf.py.in
+++ b/meld/conf.py.in
@@ -1,10 +1,8 @@
-
import os
+import re
import sys
from pathlib import Path
-
-__package__ = "meld"
-__version__ = "3.23.0"
+from typing import Tuple
APPLICATION_NAME = 'Meld'
APPLICATION_ID = 'org.gnome.Meld'
@@ -25,6 +23,9 @@ if CONFIGURED == 'True':
LOCALEDIR = '@localedir@'
PROFILE = '@profile@'
+ __package__ = '@project@'
+ __version__ = '@version@'
+
# Flag enabling some workarounds if data dir isn't installed in standard prefix
DATADIR_IS_UNINSTALLED = False
PYTHON_REQUIREMENT_TUPLE = (3, 6)
@@ -39,6 +40,18 @@ _ = no_translation
ngettext = no_translation
+def project_version_from_meson(meson_path: Path) -> Tuple[str, str]:
+ project_line = meson_path.read_text().splitlines()[0]
+ meson_project = re.match(
+ r"project\('(?P<project>\w+)', version : '(?P<version>[0-9.]+)'.*",
+ project_line,
+ )
+ if not meson_project:
+ raise RuntimeError("Couldn't parse version from meson.build")
+
+ return meson_project.group("project"), meson_project.group("version")
+
+
def frozen():
global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED
@@ -50,9 +63,12 @@ def frozen():
def uninstalled():
- global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED
+ global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED, __package__, __version__
melddir = Path(__file__).resolve().parent.parent
+ meson_path = melddir / "meson.build"
+
+ __package__, __version__ = project_version_from_meson(meson_path)
DATADIR = melddir / "data"
LOCALEDIR = melddir / "build" / "mo"
diff --git a/meld/meson.build b/meld/meson.build
index cd19b15a..24a43de2 100644
--- a/meld/meson.build
+++ b/meld/meson.build
@@ -87,6 +87,8 @@ endforeach
# Install the executable file
app_config = {
'profile': profile,
+ 'project': meson.project_name(),
+ 'version': meson.project_version(),
'application_id': application_id,
'resource_base_id': resource_base_id,
'localedir': prefix / localedir,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]