feat installer and download model on first launch

This commit is contained in:
fsylvain committed 2026-09-19 23:53:40 +02:00
1 parent 1648b44189
commit 5d4e19f24b
6 files changed
+358 -3

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
# PyInstaller spec for Dev Assist Chatbot.
#
# Build (from the repo root, in an environment with the CUDA 13.x toolkit
# installed - the toolkit is only needed at BUILD time, to copy its runtime
# DLLs into the bundle; end users only need an NVIDIA driver):
#
# uv run pyinstaller packaging/build.spec --noconfirm
#
# Output lands in dist/DevAssistChatbot/. That whole folder is the app -
# onedir rather than onefile, since unpacking a multi-GB bundle to a temp
# dir on every launch would make startup unusable.
import os
from pathlib import Path
from PyInstaller.utils.hooks import collect_submodules
PROJECT_ROOT = Path(SPECPATH).parent # noqa: F821 - injected by PyInstaller
VENV_SITE_PACKAGES = PROJECT_ROOT / ".venv" / "Lib" / "site-packages"
LLAMA_CPP_LIB = VENV_SITE_PACKAGES / "llama_cpp" / "lib"
if not LLAMA_CPP_LIB.is_dir():
raise SystemExit(
f"Expected llama_cpp's compiled libs at {LLAMA_CPP_LIB} - run this via "
"'uv run pyinstaller ...' from the repo root so the project venv is used."
)
CUDA_PATH = os.environ.get("CUDA_PATH")
if not CUDA_PATH:
raise SystemExit(
"CUDA_PATH is not set. Building requires the CUDA toolkit that "
"llama-cpp-python was compiled against, so its runtime DLLs can be "
"copied into the bundle (end users won't need the toolkit installed)."
)
CUDA_BIN = Path(CUDA_PATH) / "bin" / "x64"
# llama.cpp's ggml backend (ggml-cuda.dll etc.) is loaded dynamically at
# runtime, not linked at import time, so PyInstaller's static analysis can't
# discover it - every DLL in llama_cpp/lib/ has to be added explicitly. They
# all go into the same output folder so Windows' DLL search (which checks a
# loaded DLL's own directory for its dependencies) can resolve cublas from
# next to ggml-cuda.dll.
CUDA_RUNTIME_DLLS = [
"cudart64_13.dll",
"cublas64_13.dll",
"cublasLt64_13.dll",
"nvrtc64_130_0.dll",
"nvrtc-builtins64_134.dll",
]
binaries = [(str(dll), "llama_cpp/lib") for dll in LLAMA_CPP_LIB.glob("*.dll")]
for name in CUDA_RUNTIME_DLLS:
dll_path = CUDA_BIN / name
if not dll_path.is_file():
raise SystemExit(f"Expected CUDA runtime DLL not found: {dll_path}")
binaries.append((str(dll_path), "llama_cpp/lib"))
# ddgs picks its search backend (duckduckgo, bing, ...) via importlib at
# runtime rather than a static import, so PyInstaller won't find those
# engine modules on its own either.
hidden_imports = collect_submodules("ddgs") + ["pynvml"]
a = Analysis( # noqa: F821
[str(PROJECT_ROOT / "main.py")],
pathex=[str(PROJECT_ROOT)],
binaries=binaries,
datas=[],
hiddenimports=hidden_imports,
hookspath=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure) # noqa: F821
exe = EXE( # noqa: F821
pyz,
a.scripts,
[],
exclude_binaries=True,
name="DevAssistChatbot",
console=False,
)
coll = COLLECT( # noqa: F821
exe,
a.binaries,
a.zipfiles,
a.datas,
# UPX would try (slowly, and sometimes badly) to compress the ~650MB of
# CUDA runtime DLLs; skip it.
upx=False,
name="DevAssistChatbot",
)
+55
View File
@@ -0,0 +1,55 @@
; Inno Setup script for Dev Assist Chatbot.
;
; Build the app first (packaging/build.spec), then compile this with the
; Inno Setup Compiler (ISCC.exe) or the IDE, from the repo root:
;
; iscc packaging\installer.iss
;
; Output lands in packaging\Output\DevAssistChatbot-Setup.exe.
#define MyAppName "Dev Assist Chatbot"
#define MyAppVersion "0.1.0"
#define MyAppExeName "DevAssistChatbot.exe"
[Setup]
AppId={{A9F1D6C2-4B3E-4A7F-9C1D-3E5B7A2F8D41}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=Output
OutputBaseFilename=DevAssistChatbot-Setup
Compression=lzma2
SolidCompression=yes
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
WizardStyle=modern
[Tasks]
Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"
[Files]
Source: "..\dist\DevAssistChatbot\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; Optional: bundle the VC++ redistributable for machines that don't already
; have it (most Windows 11 installs do, via Windows Update or another app).
; Download it from https://aka.ms/vs/17/release/vc_redist.x64.exe, place it
; at packaging\redist\vc_redist.x64.exe, then uncomment these two lines and
; the matching [Run] entry below.
; Source: "redist\vc_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
; Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/install /quiet /norestart"; StatusMsg: "Installing Visual C++ runtime..."; Check: not VCRedistInstalled
Filename: "{app}\{#MyAppExeName}"; Description: "Launch {#MyAppName}"; Flags: nowait postinstall skipifsilent
[Code]
function VCRedistInstalled: Boolean;
begin
// Present once the VC++ 2015-2022 x64 runtime is installed (also true on
// most Windows 11 machines already, via Windows Update or another app).
Result := RegKeyExists(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64');
end;