[meld] build_helpers: Support compiling gsettings schemas, and add an opt-out



commit 6c8a5beaeaca0902c40a9ea88604b314b09a50a7
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu Mar 6 07:46:52 2014 +1000

    build_helpers: Support compiling gsettings schemas, and add an opt-out

 README                |   13 +++++++++++++
 meld/build_helpers.py |   26 ++++++++++++++++++++++++++
 setup.py              |    1 +
 3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/README b/README
index 0c110a6..6306462 100644
--- a/README
+++ b/README
@@ -40,6 +40,19 @@ distribution, and can be installed on OSX using MacPorts/Fink/etc. See the wiki
 for options for getting Meld working on Windows.
 
 
+Building
+--------
+
+Meld uses standard distutils for building. It supports anything that distutils
+supports, and little else.
+
+Additional hacks are added to make life easier for packagers where required,
+such as:
+
+* The NO_COMPILE_SCHEMAS schemas environment variable will, if set to 1, stop
+  Meld from compiling gsettings schemas post-install.
+
+
 Contacting
 ----------
 
diff --git a/meld/build_helpers.py b/meld/build_helpers.py
index 1c2009b..6474402 100644
--- a/meld/build_helpers.py
+++ b/meld/build_helpers.py
@@ -22,6 +22,7 @@ from __future__ import print_function
 
 import distutils.cmd
 import distutils.command.build
+import distutils.command.install_data
 import distutils.dir_util
 import glob
 import os.path
@@ -273,3 +274,28 @@ class build_i18n(distutils.cmd.Command):
                         self.spawn(cmd)
                     files_merged.append(file_merged)
                 self.distribution.data_files.append((target, files_merged))
+
+
+class install_data(distutils.command.install_data.install_data):
+
+    user_options = [
+        ("no-compile-schemas", None,
+         "Don't compile gsettings schemas post-install"),
+    ]
+    boolean_options = ["no-compile-schemas"]
+
+    def initialize_options(self):
+        distutils.command.install_data.install_data.initialize_options(self)
+        self.no_compile_schemas = None
+
+    def finalize_options(self):
+        distutils.command.install_data.install_data.finalize_options(self)
+        if self.no_compile_schemas is None:
+            self.no_compile_schemas = bool(os.environ['NO_COMPILE_SCHEMAS'])
+
+    def run(self):
+        distutils.command.install_data.install_data.run(self)
+        if not self.no_compile_schemas:
+            gschema_path = build_data.gschemas[0][0]
+            gschema_install = os.path.join(self.install_dir, gschema_path)
+            self.spawn(["glib-compile-schemas", gschema_install])
diff --git a/setup.py b/setup.py
index 858fcb9..946ce7d 100644
--- a/setup.py
+++ b/setup.py
@@ -59,5 +59,6 @@ setup(
         "build_help": meld.build_helpers.build_help,
         "build_icons": meld.build_helpers.build_icons,
         "build_data": meld.build_helpers.build_data,
+        "install_data": meld.build_helpers.install_data,
     }
 )


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]