Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·206 lines (184 loc) · 8.15 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·206 lines (184 loc) · 8.15 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env bash
# synth-city setup — installs synth-city + open-synth-miner in one step.
#
# Usage:
# ./setup.sh # interactive defaults
# ./setup.sh --osm-path ../open-synth-miner # existing checkout
# ./setup.sh --no-venv # skip virtualenv (e.g. Docker)
# ./setup.sh --with-openclaw # also install OpenClaw skill
#
# What it does:
# 1. Creates a Python virtualenv (unless --no-venv)
# 2. Clones open-synth-miner if not found locally
# 3. Installs open-synth-miner + synth-city in editable mode
# 4. Copies .env.example → .env if .env doesn't exist
# 5. Optionally installs the OpenClaw skill
#
# Requirements: Python 3.10+, git, uv (or pip)
set -euo pipefail
# ---- defaults ---------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OSM_PATH=""
VENV_DIR="$SCRIPT_DIR/.venv"
SKIP_VENV=false
WITH_DEV=false
WITH_OPENCLAW=false
# ---- parse args -------------------------------------------------------------
while [[ $# -gt 0 ]]; do
case "$1" in
--osm-path) OSM_PATH="$2"; shift 2 ;;
--venv-dir) VENV_DIR="$2"; shift 2 ;;
--no-venv) SKIP_VENV=true; shift ;;
--dev) WITH_DEV=true; shift ;;
--with-openclaw) WITH_OPENCLAW=true; shift ;;
-h|--help)
echo "Usage: ./setup.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --osm-path PATH Path to existing open-synth-miner checkout"
echo " --venv-dir PATH Virtualenv location (default: .venv)"
echo " --no-venv Skip virtualenv creation (use current Python)"
echo " --dev Also install dev dependencies (pytest, ruff, mypy)"
echo " --with-openclaw Install the OpenClaw skill after setup"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1" >&2
exit 1
;;
esac
done
# ---- helpers ----------------------------------------------------------------
info() { echo -e "\033[1;34m==>\033[0m $*"; }
ok() { echo -e "\033[1;32m==>\033[0m $*"; }
warn() { echo -e "\033[1;33m==>\033[0m $*"; }
fail() { echo -e "\033[1;31mERROR:\033[0m $*" >&2; exit 1; }
# ---- banner -----------------------------------------------------------------
cat << 'BANNER'
|
--+--
|
_ / \ _
| | _ | | _ | |
_ | | | | | | | | | | _
| | | | _ | | _ | | _ | | _ | | | |
| | | | | | | | | | | | | | | | | | | | | |
_ | | | | | | _ | | _ | | _| |_ | | _ | | _ | | | | | | _
| |_| |__| |__| |_| || || |_| |_| |_| |_| || || |_| |_| |__| |_| |
| _ _ _ _ | || || _ _ |---| _ _ | || || _ _ _ _ |
| | | | | | | | | | || || | | | | | | | | | | | || || | | | | | | | | |
| |_| |_| |_| |_| | || || |_| |_| | | |_| |_| | || || |_| |_| |_| |_| |
| _ _ _ _ | || || _ _ | | _ _ | || || _ _ _ _ |
| | | | | | | | | | || || | | | | | | | | | | | || || | | | | | | | | |
| |_| |_| |_| |_| |_||_|| |_| |_| |___| |_| |_| |_||_|| |_| |_| |_| |_| |
|_______________________________________________________________________|
| |
| S Y N T H C I T Y [ AGENTIC MINING FOR SN50 ] |
|_______________________________________________________________________|
_____ __ __ _ _ _______ _ _ _____ _____ _______ __ __
/ ____|\ \ / /| \ | ||__ __|| | | | / ____||_ _||__ __|\ \ / /
| (___ \ \_/ / | \| | | | | |__| | | | | | | | \ \_/ /
\___ \ \ / | . ` | | | | __ | | | | | | | \ /
____) | | | | |\ | | | | | | | | |____ _| |_ | | | |
|_____/ |_| |_| \_| |_| |_| |_| \_____||_____| |_| |_|
BANNER
# ---- pre-flight checks -----------------------------------------------------
info "Checking prerequisites..."
command -v python3 >/dev/null 2>&1 || fail "python3 not found. Install Python 3.10+."
command -v git >/dev/null 2>&1 || fail "git not found."
PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$(echo "$PYTHON_VERSION" | cut -d. -f1)
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
if [[ "$PYTHON_MAJOR" -lt 3 ]] || { [[ "$PYTHON_MAJOR" -eq 3 ]] && [[ "$PYTHON_MINOR" -lt 10 ]]; }; then
fail "Python 3.10+ required, found $PYTHON_VERSION"
fi
ok "Python $PYTHON_VERSION"
# ---- install uv if missing ---------------------------------------------------
if ! command -v uv >/dev/null 2>&1; then
info "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
ok "uv $(uv --version)"
# ---- virtualenv -------------------------------------------------------------
if [[ "$SKIP_VENV" == false ]]; then
if [[ ! -d "$VENV_DIR" ]]; then
info "Creating virtualenv at $VENV_DIR..."
uv venv "$VENV_DIR"
else
info "Virtualenv already exists at $VENV_DIR"
fi
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
ok "Activated virtualenv: $(which python)"
else
info "Skipping virtualenv (--no-venv)"
fi
# ---- open-synth-miner ------------------------------------------------------
if [[ -z "$OSM_PATH" ]]; then
# Try sibling directory first
if [[ -d "$SCRIPT_DIR/../open-synth-miner" ]]; then
OSM_PATH="$(cd "$SCRIPT_DIR/../open-synth-miner" && pwd)"
info "Found open-synth-miner at $OSM_PATH"
else
OSM_PATH="$SCRIPT_DIR/../open-synth-miner"
info "Cloning open-synth-miner..."
git clone https://github.com/tensorlink-dev/open-synth-miner.git "$OSM_PATH"
OSM_PATH="$(cd "$OSM_PATH" && pwd)"
fi
fi
if [[ ! -d "$OSM_PATH" ]]; then
fail "open-synth-miner not found at $OSM_PATH"
fi
ok "open-synth-miner: $OSM_PATH"
# ---- install open-synth-miner ----------------------------------------------
info "Installing open-synth-miner (editable)..."
if [[ -f "$OSM_PATH/pyproject.toml" ]] || [[ -f "$OSM_PATH/setup.py" ]]; then
uv pip install -e "$OSM_PATH" --quiet
else
# Fallback: add to path if no setup file
warn "No pyproject.toml or setup.py in open-synth-miner — adding to PYTHONPATH"
export PYTHONPATH="${OSM_PATH}:${PYTHONPATH:-}"
fi
# ---- install synth-city -----------------------------------------------------
info "Installing synth-city (editable)..."
if [[ "$WITH_DEV" == true ]]; then
uv pip install -e "$SCRIPT_DIR[dev]" --quiet
else
uv pip install -e "$SCRIPT_DIR" --quiet
fi
ok "synth-city installed"
# ---- .env -------------------------------------------------------------------
if [[ ! -f "$SCRIPT_DIR/.env" ]]; then
info "Creating .env from template..."
cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env"
warn "Edit .env to add your API keys (CHUTES_API_KEY, etc.)"
else
info ".env already exists — skipping"
fi
# ---- OpenClaw skill ---------------------------------------------------------
if [[ "$WITH_OPENCLAW" == true ]]; then
info "Installing OpenClaw skill..."
python "$SCRIPT_DIR/integrations/openclaw/setup.py"
fi
# ---- summary ----------------------------------------------------------------
echo ""
ok "Setup complete!"
echo ""
echo " synth-city: $SCRIPT_DIR"
echo " open-synth-miner: $OSM_PATH"
if [[ "$SKIP_VENV" == false ]]; then
echo " virtualenv: $VENV_DIR"
echo ""
echo " Activate with: source $VENV_DIR/bin/activate"
fi
echo ""
echo " Quick start:"
echo " python main.py sweep # baseline sweep"
echo " python main.py pipeline # full agent pipeline"
echo " python main.py bridge # start HTTP bridge"
echo ""
if grep -q "^CHUTES_API_KEY=$" "$SCRIPT_DIR/.env" 2>/dev/null; then
warn "Don't forget to edit .env with your API keys!"
fi