-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathhatch_build.py
52 lines (45 loc) · 1.86 KB
/
hatch_build.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
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Name: hatch_build.py
Porpose: Defines code that will be executed at various stages
of the build process, see [tool.hatch.build.hooks.custom] on
pyproject.toml file.
Author: Gianluca Pernigotto <[email protected]>
Copyleft - 2024 Gianluca Pernigotto <[email protected]>
license: GPL3
Rev: July.22.2024
Code checker: flake8, pylint
This file is part of Videomass.
Videomass is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Videomass is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Videomass. If not, see <http://www.gnu.org/licenses/>.
"""
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from babel.messages.frontend import compile_catalog
class VideomassLanguageBuildHook(BuildHookInterface):
"""
Compile the translation files from their PO-format into
their binary representating MO-format using python `babel`
pluggin.
"""
def initialize(self, version, build_data):
"""
Compile catalog only if the target includes binary
distribution (wheel). Source distribution (sdist)
does not have to include MO files.
"""
if self.target_name == "wheel":
cmd = compile_catalog()
cmd.directory = "videomass/data/locale/"
cmd.domain = "videomass"
cmd.statistics = True
cmd.finalize_options()
cmd.run()