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.
--- 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):