forked from cryptoadvance/specter-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·51 lines (41 loc) · 1.53 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from babel.messages import frontend as babel
from glob import glob
from setuptools import find_namespace_packages, setup
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()
with open("requirements.txt") as f:
install_reqs = f.read().strip().split("\n")
# Filter out comments/hashes
reqs = []
for req in install_reqs:
if req.startswith("#") or req.startswith(" --hash="):
continue
reqs.append(str(req).rstrip(" \\"))
setup(
package_data={
"": [
"translations/*/LC_MESSAGES/messages.mo",
]
},
# take METADATA.in into account, include that stuff as well (static/templates)
install_requires=reqs,
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,
},
)