2021-07-15 19:09:18 +02:00
|
|
|
from babel.messages import frontend as babel
|
2019-11-13 15:56:29 +01:00
|
|
|
from glob import glob
|
|
|
|
|
|
2020-10-17 14:19:20 +02:00
|
|
|
from setuptools import find_namespace_packages, setup
|
2020-02-20 12:00:53 +00:00
|
|
|
|
2021-07-15 19:09:18 +02:00
|
|
|
from setuptools.command.install import install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InstallWithBabelCompile(install):
|
|
|
|
|
"""from this stackoverflow question
|
|
|
|
|
https://stackoverflow.com/questions/40051076/compile-translation-files-when-calling-setup-py-install
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
from babel.messages.frontend import compile_catalog
|
|
|
|
|
|
|
|
|
|
compiler = compile_catalog(self.distribution)
|
|
|
|
|
option_dict = self.distribution.get_option_dict("compile_catalog")
|
|
|
|
|
compiler.domain = [option_dict["domain"][1]]
|
|
|
|
|
compiler.directory = option_dict["directory"][1]
|
|
|
|
|
compiler.run()
|
|
|
|
|
super().run()
|
|
|
|
|
|
|
|
|
|
|
2020-09-30 11:42:30 +02:00
|
|
|
with open("requirements.txt") as f:
|
|
|
|
|
install_reqs = f.read().strip().split("\n")
|
2020-02-20 12:00:53 +00:00
|
|
|
|
2020-10-11 11:48:55 -05:00
|
|
|
# Filter out comments/hashes
|
|
|
|
|
reqs = []
|
|
|
|
|
for req in install_reqs:
|
|
|
|
|
if req.startswith("#") or req.startswith(" --hash="):
|
|
|
|
|
continue
|
|
|
|
|
reqs.append(str(req).rstrip(" \\"))
|
2020-02-20 12:00:53 +00:00
|
|
|
|
2019-11-13 15:56:29 +01:00
|
|
|
setup(
|
2021-07-15 19:09:18 +02:00
|
|
|
package_data={
|
|
|
|
|
"": [
|
|
|
|
|
"translations/*/LC_MESSAGES/messages.mo",
|
|
|
|
|
]
|
|
|
|
|
},
|
2020-02-20 12:00:53 +00:00
|
|
|
# take METADATA.in into account, include that stuff as well (static/templates)
|
|
|
|
|
install_requires=reqs,
|
2021-07-15 19:09:18 +02:00
|
|
|
cmdclass={
|
|
|
|
|
"install": InstallWithBabelCompile,
|
|
|
|
|
# The rest is convenience but not strictly necessary for the automation:
|
|
|
|
|
"compile_catalog": babel.compile_catalog,
|
|
|
|
|
"extract_messages": babel.extract_messages,
|
|
|
|
|
"init_catalog": babel.init_catalog,
|
|
|
|
|
"update_catalog": babel.update_catalog,
|
|
|
|
|
},
|
2020-02-20 12:00:53 +00:00
|
|
|
)
|