forked from open-webui/open-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhatch_build.py
More file actions
21 lines (18 loc) · 800 Bytes
/
hatch_build.py
File metadata and controls
21 lines (18 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# noqa: INP001
import os
import shutil
import subprocess
from sys import stderr
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
super().initialize(version, build_data)
stderr.write('>>> Building Open Webui frontend\n')
npm = shutil.which('npm')
if npm is None:
raise RuntimeError('NodeJS `npm` is required for building Open Webui but it was not found')
stderr.write('### npm install\n')
subprocess.run([npm, 'install', '--force'], check=True) # noqa: S603
stderr.write('\n### npm run build\n')
os.environ['APP_BUILD_HASH'] = version
subprocess.run([npm, 'run', 'build'], check=True) # noqa: S603