-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·171 lines (140 loc) · 4.44 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·171 lines (140 loc) · 4.44 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
set -e
CYAN='\033[1;36m'
MAGENTA='\033[1;35m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
RED='\033[1;31m'
BOLD='\033[1m'
NC='\033[0m'
INSTALL_DIR="${INSTALL_DIR:-Text_Loom}"
fail() {
echo -e "${RED}✗${NC} $1" >&2
exit 1
}
step() {
echo -e "${GREEN}▶${NC} $1"
}
ok() {
echo -e "${GREEN}✓${NC} $1"
}
warn() {
echo -e "${YELLOW}⚠${NC} $1"
}
header() {
echo -e "${CYAN}${BOLD}"
echo "╔══════════════════════════════════════╗"
echo "║ Text Loom Installer v1.0 ║"
echo "╚══════════════════════════════════════╝"
echo -e "${NC}"
}
require() {
command -v "$1" >/dev/null 2>&1 || fail "$1 not found - install it and retry"
}
check_prerequisites() {
step "Checking prerequisites..."
require git
ok "git found"
require python3
local version major minor
version=$(python3 -c 'import sys; v=sys.version_info; print(f"{v.major}.{v.minor}")')
major=${version%.*}
minor=${version#*.}
[ "$major" -ge 3 ] && [ "$minor" -ge 8 ] || fail "Python 3.8+ required (found $version)"
ok "Python $version detected"
if command -v node >/dev/null 2>&1; then
local node_version node_major
node_version=$(node -v | sed 's/v//')
node_major=${node_version%%.*}
if [ "$node_major" -ge 18 ]; then
ok "Node.js $node_version detected"
require npm
ok "npm found"
NODE_AVAILABLE=true
else
warn "Node.js $node_version found (18+ recommended for GUI)"
NODE_AVAILABLE=false
fi
else
warn "Node.js not found - GUI mode will not be available"
warn "Install Node.js 18+ to enable GUI: https://nodejs.org/"
NODE_AVAILABLE=false
fi
}
clone_repo() {
step "Cloning Text_Loom repository..."
if [ -d "$INSTALL_DIR" ]; then
local timestamp
timestamp=$(date +%Y%m%d_%H%M%S)
warn "Directory exists - installing to ${INSTALL_DIR}_${timestamp}"
INSTALL_DIR="${INSTALL_DIR}_${timestamp}"
fi
git clone https://github.com/kleer001/Text_Loom.git "$INSTALL_DIR" || fail "Clone failed"
ok "Repository cloned"
}
setup_venv() {
step "Setting up virtual environment..."
cd "$INSTALL_DIR" || fail "Cannot cd to $INSTALL_DIR"
python3 -m venv .venv || fail "venv creation failed"
# shellcheck disable=SC1091
source .venv/bin/activate
step "Upgrading pip..."
pip install --upgrade pip --quiet
step "Installing dependencies..."
[ -f requirements.txt ] || fail "requirements.txt not found"
pip install -r requirements.txt --quiet || fail "Dependency install failed"
pip install -e . --quiet || fail "Package install failed"
ok "Dependencies installed"
}
setup_gui() {
if [ "$NODE_AVAILABLE" = true ]; then
step "Installing GUI dependencies..."
cd src/GUI || fail "Cannot cd to src/GUI"
npm install --quiet || fail "GUI npm install failed"
step "Building GUI..."
npm run build --quiet || fail "GUI build failed"
cd ../..
ok "GUI setup complete"
else
warn "Skipping GUI setup (Node.js not available)"
fi
}
create_activation_helper() {
step "Creating activation helper..."
cat > activate.sh << 'EOL'
#!/bin/bash
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/.venv/bin/activate"
export PYTHONPATH="$SCRIPT_DIR/src:$PYTHONPATH"
echo "Text_Loom environment activated!"
echo "Run: ./text_loom"
EOL
chmod +x activate.sh
ok "Activation helper created"
}
next_steps() {
echo
echo -e "${MAGENTA}${BOLD}Installation Complete!${NC}"
echo
echo -e "${CYAN}Quick start:${NC}"
echo -e " ${GREEN}cd $INSTALL_DIR && source activate.sh && ./text_loom${NC}"
echo
echo -e "${CYAN}Available modes:${NC}"
echo -e " ${GREEN}./text_loom -t${NC} ${YELLOW}Terminal UI${NC}"
echo -e " ${GREEN}./text_loom -r${NC} ${YELLOW}Python REPL${NC}"
echo -e " ${GREEN}./text_loom -g${NC} ${YELLOW}Web GUI${NC}"
echo -e " ${GREEN}./text_loom -b${NC} ${YELLOW}Batch mode${NC}"
echo
echo -e "${MAGENTA}${BOLD}Set up LLM API keys before using Query nodes${NC}"
echo
}
main() {
header
check_prerequisites
clone_repo
setup_venv
setup_gui
create_activation_helper
next_steps
}
main