-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
hatch_build.py
37 lines (31 loc) · 1.02 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
import logging
import subprocess
from pathlib import Path
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
# update list in constants.py as well
JS_DEPS = [
"datatables/datatables.min.css",
"datatables/datatables.min.js",
]
class GetJsDepsHook(BuildHookInterface):
def initialize(self, version, build_data):
if self.deps_already_installed():
logger.info("JS dependencies are already installed, skipping it")
return
subprocess.run(
str(Path(self.root).joinpath("get_js_deps.sh")),
check=True,
)
return super().initialize(version, build_data)
def deps_already_installed(self) -> bool:
for dep in JS_DEPS:
if (
not Path(self.root)
.joinpath("gutebergtozim/templates")
.joinpath(dep)
.exists()
):
return False
return True