build_hook   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A BuildHook.initialize() 0 10 1
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
        """Build frontend when building the wheel."""
10
        super().initialize(version, build_data)
11
12
        root_dir = Path(__file__).parent
13
        static = root_dir / "atramhasis" / "static"
14
        static_admin = static / "admin"
15
        subprocess.run(["npm", "install"], cwd=static, check=True)
16
        subprocess.run(["npm", "install"], cwd=static_admin, check=True)
17
        subprocess.run(["grunt", "-v", "build"], cwd=static_admin, check=True)
18