| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 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 |