diff setup.py @ 52164:2c4283c9fa93 stable

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 06 Nov 2024 16:32:15 +0100
parents d4b275587847
children 9048a0d782e1
line wrap: on
line diff
--- 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):