Files
Classic298 d67c707027 fix: Docker, frontend CI and pip builds fail when the ONNX runtime GPU download times out (#33917)
Installing the frontend dependencies makes the onnxruntime-node package download its GPU binaries from GitHub releases, and the whole install fails whenever that download times out. Neither the frontend build nor the Docker image uses those binaries (the image only ships the built frontend), so the Docker build, the frontend CI and building the Python package now skip that download with ONNXRUNTIME_NODE_INSTALL_CUDA=skip. The regular CPU binaries are part of the npm package and are not affected.
2026-11-08 20:00:07 +09:00

25 lines
1.0 KiB
Python

# 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')
os.environ.setdefault('ONNXRUNTIME_NODE_INSTALL_CUDA', 'skip')
subprocess.run([npm, 'install', '--force'], check=True) # noqa: S603
stderr.write('\n### npm run build\n')
node_options = os.environ.get('NODE_OPTIONS', '')
if '--max-old-space-size' not in node_options:
os.environ['NODE_OPTIONS'] = f'{node_options} --max-old-space-size=8192'.strip()
subprocess.run([npm, 'run', 'build'], check=True) # noqa: S603