forked from theRealCarneiro/pulsemeeter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
49 lines (36 loc) · 1.32 KB
/
setup.py
File metadata and controls
49 lines (36 loc) · 1.32 KB
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
import os
from babel.messages import frontend as babel
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
IS_ZIP = os.environ.get("ZIP_BUILD") == "1"
def gather_data_files(source_dir, target_dir, pattern=''):
datafiles = []
for directory, _, filenames in os.walk(source_dir):
if filenames:
files = [os.path.join(directory, filename) for filename in filenames if pattern in filename]
datafiles.append((os.path.join(target_dir, directory), files))
return datafiles
class BuildWithTranslations(_build_py):
def run(self):
self.run_command("compile_catalog")
mo_files = gather_data_files('locale', 'share', '.mo')
self.distribution.data_files.extend(mo_files)
super().run()
DATA_FILES = [('share/licenses/pulsemeeter/', ['LICENSE']), ]
DATA_FILES += gather_data_files('share', '')
setup(
data_files=DATA_FILES,
cmdclass={
'build_py': BuildWithTranslations,
# 'build_zip': BuildWithTranslations,
'compile_catalog': babel.compile_catalog,
'extract_messages': babel.extract_messages,
'init_catalog': babel.init_catalog,
'update_catalog': babel.update_catalog
},
message_extractors={
'src': [
('**/*.py', 'python', None),
],
},
)