From 0c540b5a358fc038428387c1c874a5adac0702da Mon Sep 17 00:00:00 2001 From: jim800121chen Date: Wed, 25 Mar 2026 19:34:57 +0800 Subject: [PATCH] feat: bundle Linux KneronPLUS wheel in installer - Add scripts/linux/ directory for Linux-specific KneronPLUS wheel - installer/app.go: add Linux case to wheel selection (scripts/linux/) - build-installer-linux.sh: search ~/Downloads/KL520Web/package/ubuntu/ and kneron_plus source dir for KneronPLUS*.whl - Makefile: add Linux wheel copy to installer-payload target Without the kp module, devices can be scanned (via pyusb fallback) but cannot connect, load models, or run inference. Co-Authored-By: Claude Opus 4.6 (1M context) --- edge-ai-platform/Makefile | 6 ++++++ edge-ai-platform/installer/app.go | 15 ++++++++++---- .../scripts/build-installer-linux.sh | 20 ++++++++++++++++--- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/edge-ai-platform/Makefile b/edge-ai-platform/Makefile index 3a88170..280a656 100644 --- a/edge-ai-platform/Makefile +++ b/edge-ai-platform/Makefile @@ -141,6 +141,12 @@ installer-payload: build-server-tray ## Stage payload files for GUI installer cp "$$MACOS_WHL" installer/payload/scripts/macos/; \ echo " KneronPLUS macOS wheel bundled."; \ fi + @mkdir -p installer/payload/scripts/linux + @LINUX_WHL="$$(find ~/Downloads/KL520Web/package/ubuntu -name 'KneronPLUS*.whl' 2>/dev/null | head -1)"; \ + if [ -n "$$LINUX_WHL" ]; then \ + cp "$$LINUX_WHL" installer/payload/scripts/linux/; \ + echo " KneronPLUS Linux wheel bundled."; \ + fi @# Copy WinUSB driver files (for Windows installer) @mkdir -p installer/payload/drivers/amd64 cp server/scripts/drivers/kneron_winusb.inf installer/payload/drivers/ diff --git a/edge-ai-platform/installer/app.go b/edge-ai-platform/installer/app.go index 10474ff..7beeb12 100644 --- a/edge-ai-platform/installer/app.go +++ b/edge-ai-platform/installer/app.go @@ -457,16 +457,23 @@ func (inst *Installer) setupPythonVenv(installDir string) error { } // Install KneronPLUS SDK wheel if bundled in payload. - // On macOS, prefer the macOS-specific wheel (v2.0.0 with .dylib); - // on Windows, prefer the Windows wheel (v3.1.2 with .dll). + // Each platform has its own wheel with platform-specific native libraries: + // macOS: scripts/macos/KneronPLUS*.whl (v2.0.0 with .dylib) + // Linux: scripts/linux/KneronPLUS*.whl (v2.0.0/v3.1.2 with .so) + // Windows: scripts/KneronPLUS*.whl (v3.1.2 with .dll) scriptsDir := filepath.Join(installDir, "scripts") var kpWheel string - if runtime.GOOS == "darwin" { - // macOS wheels are stored in scripts/macos/ subdirectory + switch runtime.GOOS { + case "darwin": macMatches, _ := filepath.Glob(filepath.Join(scriptsDir, "macos", "KneronPLUS*.whl")) if len(macMatches) > 0 { kpWheel = macMatches[0] } + case "linux": + linuxMatches, _ := filepath.Glob(filepath.Join(scriptsDir, "linux", "KneronPLUS*.whl")) + if len(linuxMatches) > 0 { + kpWheel = linuxMatches[0] + } } if kpWheel == "" { // Fallback: pick any KneronPLUS wheel in scripts/ (Windows or generic) diff --git a/edge-ai-platform/scripts/build-installer-linux.sh b/edge-ai-platform/scripts/build-installer-linux.sh index 8650133..3116053 100755 --- a/edge-ai-platform/scripts/build-installer-linux.sh +++ b/edge-ai-platform/scripts/build-installer-linux.sh @@ -111,13 +111,27 @@ cp scripts/kneron_detect.py installer/payload/scripts/ cp server/scripts/firmware/KL520/*.bin installer/payload/scripts/firmware/KL520/ 2>/dev/null || true cp server/scripts/firmware/KL720/*.bin installer/payload/scripts/firmware/KL720/ 2>/dev/null || true -# Copy KneronPLUS wheel if available -kp_wheel=$(find "$REPO_ROOT" -maxdepth 2 -name 'KneronPLUS*linux*.whl' 2>/dev/null | head -1) +# Copy KneronPLUS wheel if available (Linux-specific) +mkdir -p installer/payload/scripts/linux +kp_wheel="" +# Search order: KL520Web ubuntu package → kneron_plus source zip extract → repo root +for search_dir in \ + "$HOME/Downloads/KL520Web/package/ubuntu" \ + "$REPO_ROOT/kneron_plus/python/package/ubuntu" \ + "$REPO_ROOT"; do + found=$(find "$search_dir" -maxdepth 1 -name 'KneronPLUS*.whl' 2>/dev/null | head -1) + if [ -n "$found" ]; then + kp_wheel="$found" + break + fi +done + if [ -n "$kp_wheel" ]; then - cp "$kp_wheel" installer/payload/scripts/ + cp "$kp_wheel" installer/payload/scripts/linux/ info "KneronPLUS wheel bundled: $(basename "$kp_wheel")" else warn "KneronPLUS wheel not found, skipping." + warn " Expected in: ~/Downloads/KL520Web/package/ubuntu/" fi file_count=$(find installer/payload -type f | wc -l)