From e6fe2ef6bb7eb579be9277baf305891b4566fd9a Mon Sep 17 00:00:00 2001 From: Cory Francis Myers Date: Tue, 31 Aug 2021 15:48:52 -0700 Subject: [PATCH] overrides "setup.py sdist" command to compile translation catalogs first --- setup.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/setup.py b/setup.py index e6e35fa0d..781dc45fc 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,8 @@ import os +import subprocess import setuptools +from setuptools.command.sdist import sdist with open("README.md", "r") as fh: long_description = fh.read() @@ -12,6 +14,20 @@ for name in os.listdir("./securedrop_client/resources/images/"): package_resources.append(os.path.join("./securedrop_client/resources/images", name)) + +class SdistWithTranslationCatalogs(sdist): + def run(self): + """Call out to `make compile-translation-catalogs`, then run the rest of + the rest of the normal `sdist` routine. + """ + + cmd = ["make", "compile-translation-catalogs"] + if subprocess.call(cmd) != 0: + raise EnvironmentError(f"error calling {cmd}") + + super().run() + + setuptools.setup( name="securedrop-client", version="0.5.0", @@ -35,4 +51,9 @@ "Operating System :: OS Independent", ), entry_points={"console_scripts": ["sd-client = securedrop_client.app:run"]}, + # Override "sdist" to compile gettext gettext POs to MOs for inclusion in + # built distributions. + cmdclass={"sdist": SdistWithTranslationCatalogs}, + package_data={"": ["locale/*/*/*.mo", "locale/*/*/*.po"]}, + setup_requires=["babel"], )