57 lines
2.1 KiB
Diff
57 lines
2.1 KiB
Diff
From ebf3218eef81897b536521e2140bdd9176f3ace3 Mon Sep 17 00:00:00 2001
|
|
From: lkk12014402 <kaokao.lv@intel.com>
|
|
Date: Tue, 8 Apr 2025 07:13:20 +0000
|
|
Subject: [PATCH 3/3] update build script
|
|
|
|
---
|
|
hatch_build.py | 23 ++++++++++++++++++-----
|
|
1 file changed, 18 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/hatch_build.py b/hatch_build.py
|
|
index 8ddaf0749..e15d6e99d 100644
|
|
--- a/hatch_build.py
|
|
+++ b/hatch_build.py
|
|
@@ -3,21 +3,34 @@ 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")
|
|
+ stderr.write(">>> Building DCAI小智 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"
|
|
+ "NodeJS `npm` is required for building DCAI小智 but it was not found"
|
|
)
|
|
+ stderr.write("### Installing onnxruntime-node\n")
|
|
+ subprocess.run([npm, "install", "onnxruntime-node", "--onnxruntime-node-install-cuda=skip"], check=True) # noqa: S603
|
|
+
|
|
+ stderr.write("### Installing huggingface/transformers.js\n")
|
|
+ subprocess.run([npm, "i", "@huggingface/transformers"], check=True) # noqa: S603
|
|
+
|
|
+ ort_version = "1.20.1"
|
|
+ ort_url = f"https://github.com/microsoft/onnxruntime/releases/download/v{ort_version}/onnxruntime-linux-x64-gpu-{ort_version}.tgz"
|
|
+
|
|
+ stderr.write(f"### Downloading onnxruntime binaries from {ort_url}\n")
|
|
+ subprocess.run(["curl", "-L", ort_url, "-o", f"onnxruntime-linux-x64-gpu-{ort_version}.tgz"], check=True) # noqa: S603
|
|
+
|
|
stderr.write("### npm install\n")
|
|
subprocess.run([npm, "install"], 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
|
|
--
|
|
2.34.1
|
|
|