2022-11-08 10:19:46 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2024-05-07 10:45:48 +08:00
|
|
|
import distutils.cmd
|
|
|
|
import os
|
|
|
|
import subprocess
|
2022-11-08 10:19:46 +08:00
|
|
|
from io import open
|
2024-05-07 10:45:48 +08:00
|
|
|
|
2022-11-08 10:19:46 +08:00
|
|
|
from setuptools import setup
|
2024-05-07 10:45:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
class WebpackBuildCommand(distutils.cmd.Command):
|
|
|
|
|
|
|
|
description = "Generate static assets"
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
if not 'CI' in os.environ and not 'TOX_ENV_NAME' in os.environ:
|
|
|
|
subprocess.run(['npm', 'install'], check=True)
|
|
|
|
subprocess.run(['node_modules/.bin/webpack', '--config', 'webpack.prod.js'], check=True)
|
|
|
|
|
|
|
|
|
|
|
|
class WebpackDevelopCommand(distutils.cmd.Command):
|
|
|
|
|
|
|
|
description = "Run Webpack dev server"
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
subprocess.run(
|
|
|
|
["node_modules/.bin/webpack-dev-server", "--open", "--config", "webpack.dev.js"],
|
|
|
|
check=True
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class UpdateTranslationsCommand(distutils.cmd.Command):
|
|
|
|
|
|
|
|
description = "Run all localization commands"
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
sub_commands = [
|
|
|
|
('extract_messages', None),
|
|
|
|
('update_catalog', None),
|
|
|
|
('transifex', None),
|
|
|
|
('compile_catalog', None),
|
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
for cmd_name in self.get_sub_commands():
|
|
|
|
self.run_command(cmd_name)
|
|
|
|
|
|
|
|
|
|
|
|
class TransifexCommand(distutils.cmd.Command):
|
|
|
|
|
|
|
|
description = "Update translation files through Transifex"
|
|
|
|
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
subprocess.run(['tx', 'push', '--source'], check=True)
|
|
|
|
subprocess.run(['tx', 'pull', '--mode', 'onlyreviewed', '-f', '-a'], check=True)
|
2022-11-08 10:19:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
setup(
|
2024-05-07 10:45:48 +08:00
|
|
|
version='2.0.0',
|
|
|
|
cmdclass={
|
|
|
|
'update_translations': UpdateTranslationsCommand,
|
|
|
|
'transifex': TransifexCommand,
|
2022-11-08 10:19:46 +08:00
|
|
|
},
|
|
|
|
)
|