Skip to content

Commit

Permalink
overrides "setup.py sdist" command to compile translation catalogs first
Browse files Browse the repository at this point in the history
  • Loading branch information
cfm committed Sep 23, 2021
1 parent b87e6ac commit e6fe2ef
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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",
Expand All @@ -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"],
)

0 comments on commit e6fe2ef

Please sign in to comment.