Passed
Push — develop ( a0fd1f...041457 )
by
unknown
01:45
created

build_hook.BuildHook.build_frontend()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
import subprocess
2
from pathlib import Path
3
4
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
5
6
7
class BuildHook(BuildHookInterface):
8
    def initialize(self, version: str, build_data) -> None:
9
        """Execute compilations when building the wheel."""
10
        super().initialize(version, build_data)
11
12
        self.build_frontend()
13
        self.compile_message_catalog()
14
15
    def compile_message_catalog(self):
16
        root_dir = Path(__file__).parent
17
        subprocess.run(
18
            [
19
                'pybabel',
20
                'compile',
21
                '--directory',
22
                'atramhasis/locale',
23
                '--domain',
24
                'atramhasis',
25
            ],
26
            cwd=root_dir,
27
            check=True,
28
        )
29
30
    def build_frontend(self):
31
        root_dir = Path(__file__).parent
32
        static = root_dir / 'atramhasis' / 'static'
33
        static_admin = static / 'admin'
34
        subprocess.run(['npm', 'install'], cwd=static, check=True)
35
        subprocess.run(['npm', 'install'], cwd=static_admin, check=True)
36
        subprocess.run(['grunt', '-v', 'build'], cwd=static_admin, check=True)
37