-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
56 lines (42 loc) · 1.43 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
52
53
54
55
56
import distutils
import glob
import os
import subprocess
from distutils.cmd import Command
from distutils.command.build import build as _build
from setuptools import setup
from setuptools.command.install_lib import install_lib as _install_lib
from sphinx.setup_command import BuildDoc
BASE_DIR = os.path.dirname((os.path.abspath(__file__)))
class compile_translations(Command):
description = "Compile i18n translations using gettext."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
pattern = "django_logger/locale/*/LC_MESSAGES/django.po"
for file in glob.glob(pattern):
cmd = ["msgfmt", "-c"]
name, ext = os.path.splitext(file)
cmd += ["-o", "%s.mo" % name]
cmd += ["%s.po" % name]
self.announce(
"running command: %s" % " ".join(cmd), level=distutils.log.INFO
)
subprocess.check_call(cmd, cwd=BASE_DIR) # nosec
class build(_build):
sub_commands = [("compile_translations", None)] + _build.sub_commands
class install_lib(_install_lib):
def run(self):
self.run_command("compile_translations")
_install_lib.run(self)
setup(
#use_scm_version=True,
cmdclass={
"build": build,
"install_lib": install_lib,
"compile_translations": compile_translations,
'build_sphinx': BuildDoc,
})