-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
Β·112 lines (95 loc) Β· 3.96 KB
/
build.sh
File metadata and controls
executable file
Β·112 lines (95 loc) Β· 3.96 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
# Build script for AI Shell binaries
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
echo "π Building AI Shell binaries..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
if [ ! -f "pyproject.toml" ]; then
echo -e "${RED}β Error: pyproject.toml not found. Please run this script from the project root.${NC}"
exit 1
fi
BUILD_VENV="${ROOT_DIR}/.build-venv"
TIKTOKEN_CACHE_DIR="${AISH_BUILD_TIKTOKEN_CACHE_DIR:-build/tiktoken_cache}"
USE_UV=0
if command -v uv >/dev/null 2>&1; then
USE_UV=1
fi
if [ "$USE_UV" -eq 1 ]; then
echo -e "${BLUE}π¦ Syncing dependencies with uv...${NC}"
uv sync
PYTHON_RUN=(uv run python)
PYINSTALLER_RUN=(uv run --with pyinstaller pyinstaller)
else
if ! command -v python3 >/dev/null 2>&1; then
echo -e "${RED}β Error: neither uv nor python3 is available.${NC}"
exit 1
fi
echo -e "${BLUE}π¦ Creating local build virtualenv...${NC}"
python3 -m venv "$BUILD_VENV"
"$BUILD_VENV/bin/python" -m pip install --upgrade pip
"$BUILD_VENV/bin/python" -m pip install . pyinstaller
PYTHON_RUN=("$BUILD_VENV/bin/python")
PYINSTALLER_RUN=("$BUILD_VENV/bin/python" -m PyInstaller)
fi
# Clean previous builds
echo -e "${YELLOW}π§Ή Cleaning previous builds...${NC}"
rm -rf dist/ build/ *.spec.backup
if [ "${AISH_CLEAN_TIKTOKEN_CACHE:-0}" = "1" ]; then
echo -e "${YELLOW}π§Ή Removing cached tiktoken data...${NC}"
rm -rf "$TIKTOKEN_CACHE_DIR"
fi
echo -e "${BLUE}π§ Prefetching tiktoken cache...${NC}"
"${PYTHON_RUN[@]}" packaging/prefetch_tiktoken_cache.py --cache-dir "$TIKTOKEN_CACHE_DIR"
# Build using PyInstaller spec file
echo -e "${BLUE}π¨ Building binary with PyInstaller...${NC}"
"${PYINSTALLER_RUN[@]}" aish.spec
# Check if build was successful
if [ -f "dist/aish" ] && [ -f "dist/aish-sandbox" ]; then
echo -e "${GREEN}β
Binary built successfully!${NC}"
echo -e "${GREEN}π Location: dist/aish${NC}"
echo -e "${GREEN}π Location: dist/aish-sandbox${NC}"
# Get file sizes
SIZE_MAIN=$(du -h dist/aish | cut -f1)
SIZE_SANDBOX=$(du -h dist/aish-sandbox | cut -f1)
echo -e "${GREEN}π Size (aish): ${SIZE_MAIN}${NC}"
echo -e "${GREEN}π Size (aish-sandbox): ${SIZE_SANDBOX}${NC}"
# Make executable
chmod +x dist/aish dist/aish-sandbox
# Test the binaries
echo -e "${BLUE}π§ͺ Testing binaries...${NC}"
if ./dist/aish --help > /dev/null 2>&1; then
echo -e "${GREEN}β
Binary test passed!${NC}"
if ./dist/aish-sandbox --help > /dev/null 2>&1; then
echo -e "${GREEN}β
Sandbox binary test passed!${NC}"
else
echo -e "${YELLOW}β οΈ Sandbox binary has some issues but was built successfully${NC}"
fi
if command -v script >/dev/null 2>&1 && bash ./packaging/scripts/smoke-installed-aish.sh ./dist/aish > /dev/null 2>&1; then
echo -e "${GREEN}β
Interactive binary smoke passed!${NC}"
else
echo -e "${YELLOW}β οΈ Interactive binary smoke did not complete successfully${NC}"
fi
else
echo -e "${YELLOW}β οΈ Binary has some issues but was built successfully${NC}"
echo -e "${YELLOW} (This may be due to LiteLLM/tiktoken packaging complexity)${NC}"
fi
echo ""
echo -e "${YELLOW}π Usage:${NC}"
echo -e " ${GREEN}./dist/aish --help${NC} # Show help"
echo -e " ${GREEN}./dist/aish run${NC} # Start shell"
echo -e " ${GREEN}./dist/aish config${NC} # Show config"
echo ""
echo -e "${YELLOW}π¦ Deploy to Linux:${NC}"
echo -e " ${GREEN}scp dist/aish user@server:/usr/local/bin/${NC}"
echo -e " ${GREEN}ssh user@server 'chmod +x /usr/local/bin/aish'${NC}"
else
echo -e "${RED}β Build failed! Expected binaries not found (dist/aish, dist/aish-sandbox).${NC}"
exit 1
fi
echo -e "${GREEN}π Build completed successfully!${NC}"