setup: add a way to force the setup to translate (or fail) stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 06 Nov 2024 16:32:15 +0100
branchstable
changeset 52198 2c4283c9fa93
parent 52197 c32b17e8f414
child 52199 d22b6d6e02e1
setup: add a way to force the setup to translate (or fail) we add the `MERCURIAL_SETUP_FORCE_TRANSLATIONS` variable that is intended to make sure we don't stop building the translation silently.
contrib/heptapod-ci.yml
setup.py
--- a/contrib/heptapod-ci.yml	Wed Nov 06 16:37:10 2024 +0100
+++ b/contrib/heptapod-ci.yml	Wed Nov 06 16:32:15 2024 +0100
@@ -47,6 +47,7 @@
   variables:
     WHEEL_TYPE: ""
     FLAVOR: ""
+    MERCURIAL_SETUP_FORCE_TRANSLATIONS: "1"
   before_script:
     - echo "python used, $PYTHON"
     - $PYTHON --version
--- a/setup.py	Wed Nov 06 16:37:10 2024 +0100
+++ b/setup.py	Wed Nov 06 16:32:15 2024 +0100
@@ -464,6 +464,14 @@
     description = "build translations (.mo files)"
 
     def run(self):
+        result = self._run()
+        if (
+            not result
+            and os.environ.get('MERCURIAL_SETUP_FORCE_TRANSLATIONS') == '1'
+        ):
+            raise DistutilsExecError("failed to build translations")
+
+    def _run(self):
         try:
             from shutil import which as find_executable
         except ImportError:
@@ -475,12 +483,12 @@
                 "could not find msgfmt executable, no translations "
                 "will be built"
             )
-            return
+            return False
 
         podir = 'i18n'
         if not os.path.isdir(podir):
             self.warn("could not find %s/ directory" % podir)
-            return
+            return False
 
         join = os.path.join
         for po in os.listdir(podir):
@@ -496,6 +504,7 @@
                 cmd.append('-c')
             self.mkpath(join('mercurial', modir))
             self.make_file([pofile], mobuildfile, spawn, (cmd,))
+        return True
 
 
 class hgdist(Distribution):