forked from mamolinux/battery-monitor
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
44 lines (34 loc) · 1.29 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
import glob
import os
import subprocess
from setuptools import setup
with open("src/BatteryMonitor/VERSION", "w") as f:
try:
version = (subprocess.check_output(["dpkg-parsechangelog",
"--show-field", "Version"])).decode().strip("\n")
except:
raise RuntimeError('No version found in debian/changelog')
if '~' in version:
version = version.split('~')[0]
f.write("%s" % version)
gschema_dir_suffix = 'share/glib-2.0/schemas'
data_files = [('share/applications', glob.glob("data/applications/*.desktop")),
('share/icons/hicolor/scalable/apps', glob.glob("data/icons/*")),
(gschema_dir_suffix, glob.glob("data/schema/*.xml"))
]
def create_mo_files():
po_files = glob.glob("po/*.po")
prefix = 'battery-monitor'
for po_file in po_files:
po_name = os.path.splitext(os.path.split(po_file)[1])[0]
replace_txt = "%s-" % prefix
lang = po_name.replace(replace_txt, '')
os.makedirs("data/locale/%s" % lang, exist_ok=True)
mo = "data/locale/%s/%s.mo" % (lang, prefix)
subprocess.run(['msgfmt', '-o', str(mo), po_file], check=True)
mo_file = map(lambda i: ('share/locale/%s/LC_MESSAGES' % lang, [i+'/%s.mo' % prefix]), glob.glob('data/locale/%s' % lang))
data_files.extend(mo_file)
create_mo_files()
setup(data_files=data_files,
# cmdclass = {'install_data': install_data}
)