-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhatch_build.py
More file actions
35 lines (28 loc) · 1.06 KB
/
hatch_build.py
File metadata and controls
35 lines (28 loc) · 1.06 KB
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
import logging
import os
import shutil
import subprocess
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
# Code in this function will run before building
super().initialize(version, build_data)
logger.info("Building node front-end")
yarn = shutil.which("yarn")
if yarn is None:
raise RuntimeError(
"NodeJS `yarn` is required for building Fed-BioMed front-end application"
)
os.chdir("fedbiomed_gui/ui")
try:
logger.info(
"### Yarn: Installation front-end dependencies to prepare build.\n"
)
subprocess.run([yarn, "install"], check=True)
logger.info("\n### Yarn: Building front-end application run.\n")
subprocess.run([yarn, "build"], check=True)
finally:
os.chdir("../../")