Debian Codegraph @

setup.py

raw ◀ ▶
1 Debian patch touch this file
1 # -*- coding: utf-8 -*-
2
3 import distutils.cmd
4 import os
5 import subprocess
6 from io import open
7
8 from setuptools import setup
9
10
11 class WebpackBuildCommand(distutils.cmd.Command):
12
13 description = "Generate static assets"
14
15 user_options = []
16
17 def initialize_options(self):
18 pass
19
20 def finalize_options(self):
21 pass
22
23 def run(self):
24 if not 'CI' in os.environ and not 'TOX_ENV_NAME' in os.environ:
25 subprocess.run(['npm', 'install'], check=True)
26 subprocess.run(['node_modules/.bin/webpack', '--config', 'webpack.prod.js'], check=True)
27
28
29 class WebpackDevelopCommand(distutils.cmd.Command):
30
31 description = "Run Webpack dev server"
32
33 user_options = []
34
35 def initialize_options(self):
36 pass
37
38 def finalize_options(self):
39 pass
40
41 def run(self):
42 subprocess.run(
43 ["node_modules/.bin/webpack-dev-server", "--open", "--config", "webpack.dev.js"],
44 check=True
45 )
46
47
48 class UpdateTranslationsCommand(distutils.cmd.Command):
49
50 description = "Run all localization commands"
51
52 user_options = []
53 sub_commands = [
54 ('extract_messages', None),
55 ('update_catalog', None),
56 ('transifex', None),
57 ('compile_catalog', None),
58 ]
59
60 def initialize_options(self):
61 pass
62
63 def finalize_options(self):
64 pass
65
66 def run(self):
67 for cmd_name in self.get_sub_commands():
68 self.run_command(cmd_name)
69
70
71 class TransifexCommand(distutils.cmd.Command):
72
73 description = "Update translation files through Transifex"
74
75 user_options = []
76
77 def initialize_options(self):
78 pass
79
80 def finalize_options(self):
81 pass
82
83 def run(self):
84 subprocess.run(['tx', 'push', '--source'], check=True)
85 subprocess.run(['tx', 'pull', '--mode', 'onlyreviewed', '-f', '-a'], check=True)
86
87
88 setup(
89 version='3.1.0',
90 cmdclass={
91 'update_translations': UpdateTranslationsCommand,
92 'transifex': TransifexCommand,
93 },
94 )