-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_executable.py
More file actions
77 lines (63 loc) · 2.31 KB
/
build_executable.py
File metadata and controls
77 lines (63 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
"""Build script to create executable from Vector Bot CLI."""
import importlib.util
import subprocess
import sys
from pathlib import Path
def build_executable():
"""Build executable using PyInstaller."""
# Install PyInstaller if not available
if importlib.util.find_spec("PyInstaller") is None:
print("Installing PyInstaller...")
subprocess.run([sys.executable, "-m", "pip", "install", "pyinstaller"], check=False)
# Create a simple entry point script
entry_script = Path("vector_bot_main.py")
entry_script.write_text("""
import sys
from pathlib import Path
# Add src to path for imports
sys.path.insert(0, str(Path(__file__).parent / "src"))
# Import and run the main CLI
from rag.cli import main
if __name__ == "__main__":
sys.exit(main())
""")
# PyInstaller command
cmd = [
"pyinstaller",
"--onefile",
"--name", "vector-bot",
"--add-data", "src/rag;rag",
"--add-data", "configs;configs",
"--add-data", ".env.example;.",
"--hidden-import", "llama_index.core",
"--hidden-import", "llama_index.llms.ollama",
"--hidden-import", "llama_index.embeddings.ollama",
"--hidden-import", "ollama",
"--hidden-import", "requests",
"--hidden-import", "rich",
"--hidden-import", "dotenv",
"--paths", "src",
"--clean",
str(entry_script)
]
print("Building executable...")
print(f"Command: {' '.join(cmd)}")
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
executable_path = Path("dist") / ("vector-bot.exe" if sys.platform == "win32" else "vector-bot")
print(f"OK Executable built successfully: {executable_path}")
print(f"Size: {executable_path.stat().st_size / (1024*1024):.1f} MB")
print("\nTo distribute:")
print(f"1. Copy {executable_path} to target system")
print("2. Ensure Ollama is installed and running on target system")
print("3. Run: ./vector-bot doctor")
# Clean up entry script
entry_script.unlink(missing_ok=True)
else:
print("ERROR Build failed:")
print(result.stderr)
return 1
return 0
if __name__ == "__main__":
sys.exit(build_executable())