-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathquickstart.sh
More file actions
executable file
·207 lines (177 loc) · 9.66 KB
/
Copy pathquickstart.sh
File metadata and controls
executable file
·207 lines (177 loc) · 9.66 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
207
#!/bin/bash
# SageVDB Quickstart Script
# Sets up development environment and git hooks
set -e
# Colors
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
BLUE='\033[0;34m'
BOLD='\033[1m'
NC='\033[0m'
# Print banner
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BOLD}${BLUE} ____ __ ______ ____ ${NC}"
echo -e "${BOLD}${BLUE} / __/__ ___ ___ / / / __ / / __ )${NC}"
echo -e "${BOLD}${BLUE} _\\ \/ _ \/ _ \/ -_) / / / / / / / __ |${NC}"
echo -e "${BOLD}${BLUE}/___/\\___/\\_, /\\__/ /_/ /_/ /_/ /____/ ${NC}"
echo -e "${BOLD}${BLUE} /___/ ${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}${BOLD}SageVDB Quickstart Setup${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Detect project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$SCRIPT_DIR"
echo -e "${BLUE}📂 Project root: ${NC}$PROJECT_ROOT"
echo ""
# Step 1: Install git hooks
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW}${BOLD}Step 1: Installing Git Hooks${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
HOOKS_DIR="$PROJECT_ROOT/.git/hooks"
TEMPLATE_DIR="$PROJECT_ROOT/hooks"
if [ ! -d "$HOOKS_DIR" ]; then
echo -e "${RED}✗ Git repository not initialized${NC}"
echo -e "${YELLOW}Run: git init${NC}"
exit 1
fi
# Install pre-commit hook
if [ -f "$TEMPLATE_DIR/pre-commit" ]; then
cp "$TEMPLATE_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
chmod +x "$HOOKS_DIR/pre-commit"
echo -e "${GREEN}✓ Installed pre-commit hook${NC}"
else
echo -e "${YELLOW}⚠ pre-commit template not found, skipping${NC}"
fi
# Install pre-push hook
if [ -f "$TEMPLATE_DIR/pre-push" ]; then
cp "$TEMPLATE_DIR/pre-push" "$HOOKS_DIR/pre-push"
chmod +x "$HOOKS_DIR/pre-push"
echo -e "${GREEN}✓ Installed pre-push hook${NC}"
else
echo -e "${YELLOW}⚠ pre-push template not found, skipping${NC}"
fi
# Install post-commit hook
if [ -f "$TEMPLATE_DIR/post-commit" ]; then
cp "$TEMPLATE_DIR/post-commit" "$HOOKS_DIR/post-commit"
chmod +x "$HOOKS_DIR/post-commit"
echo -e "${GREEN}✓ Installed post-commit hook${NC}"
else
echo -e "${YELLOW}⚠ post-commit template not found, skipping${NC}"
fi
echo ""
# Step 2: Check dependencies
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW}${BOLD}Step 2: Checking Dependencies${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
# Check for CMake
if command -v cmake &> /dev/null; then
CMAKE_VERSION=$(cmake --version | head -n1 | cut -d' ' -f3)
echo -e "${GREEN}✓ CMake found: ${NC}v$CMAKE_VERSION"
else
echo -e "${RED}✗ CMake not found${NC}"
echo -e "${YELLOW} Install: sudo apt install cmake # or brew install cmake${NC}"
fi
# Check for C++ compiler
if command -v g++ &> /dev/null; then
GCC_VERSION=$(g++ --version | head -n1 | awk '{print $NF}')
echo -e "${GREEN}✓ g++ found: ${NC}v$GCC_VERSION"
elif command -v clang++ &> /dev/null; then
CLANG_VERSION=$(clang++ --version | head -n1 | awk '{print $NF}')
echo -e "${GREEN}✓ clang++ found: ${NC}v$CLANG_VERSION"
else
echo -e "${RED}✗ C++ compiler not found${NC}"
echo -e "${YELLOW} Install: sudo apt install build-essential # or xcode-select --install${NC}"
fi
# Check for Python
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version | awk '{print $2}')
echo -e "${GREEN}✓ Python found: ${NC}v$PYTHON_VERSION"
else
echo -e "${RED}✗ Python not found${NC}"
fi
# Check for sagepypi
if command -v sagepypi &> /dev/null; then
echo -e "${GREEN}✓ sagepypi found${NC}"
else
echo -e "${YELLOW}⚠ sagepypi not found${NC}"
echo -e "${YELLOW} Optional for PyPI publishing: pip install sagepypi${NC}"
fi
echo ""
# Step 3: Build instructions
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW}${BOLD}Step 3: Build Options${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}Would you like to build the project now?${NC}"
echo -e " ${GREEN}[y]${NC} Yes, configure and build"
echo -e " ${YELLOW}[n]${NC} No, I'll build manually later"
echo -n "Your choice [y/n]: "
read -r BUILD_NOW
if [[ "$BUILD_NOW" =~ ^[Yy]$ ]]; then
echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}🔨 Building SageVDB...${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
if [ -f "$PROJECT_ROOT/build.sh" ]; then
echo -e "${YELLOW}Using build.sh script...${NC}"
cd "$PROJECT_ROOT"
bash build.sh
else
echo -e "${YELLOW}Configuring with CMake...${NC}"
cmake -B "$PROJECT_ROOT/build" -S "$PROJECT_ROOT" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=ON
echo -e "${YELLOW}Building...${NC}"
cmake --build "$PROJECT_ROOT/build" -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
echo -e "${GREEN}✓ Build complete${NC}"
fi
else
echo -e "${YELLOW}Skipping build. To build later, run:${NC}"
echo -e " ${CYAN}./build.sh${NC}"
echo -e "${YELLOW}Or manually:${NC}"
echo -e " ${CYAN}cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON${NC}"
echo -e " ${CYAN}cmake --build build -j\$(nproc)${NC}"
fi
echo ""
# Step 4: Python package setup
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${YELLOW}${BOLD}Step 4: Python Package Setup (Optional)${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}Install Python package in development mode?${NC}"
echo -e " ${GREEN}[y]${NC} Yes, install with pip install -e ."
echo -e " ${YELLOW}[n]${NC} No, skip Python setup"
echo -n "Your choice [y/n]: "
read -r INSTALL_PY
if [[ "$INSTALL_PY" =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Installing in editable mode...${NC}"
cd "$PROJECT_ROOT"
pip install -e .
echo -e "${GREEN}✓ Python package installed${NC}"
else
echo -e "${YELLOW}Skipping Python package install${NC}"
fi
echo ""
# Summary
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}${BOLD}✓ Setup Complete!${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e "${BLUE}${BOLD}Next Steps:${NC}"
echo -e " ${CYAN}1.${NC} Run tests: ${CYAN}cd build && ctest --verbose${NC}"
echo -e " ${CYAN}2.${NC} Try examples: ${CYAN}python examples/python_persistence_example.py${NC}"
echo -e " ${CYAN}3.${NC} Read docs: ${CYAN}cat README.md${NC}"
echo ""
echo -e "${YELLOW}${BOLD}Git Hooks Installed:${NC}"
echo -e " ${GREEN}•${NC} pre-commit: Checks code quality before commits"
echo -e " ${GREEN}•${NC} post-commit: Auto-bumps version after commit"
echo -e " ${GREEN}•${NC} pre-push: Manages version updates and PyPI publishing"
echo ""
echo -e "${BLUE}${BOLD}Useful Commands:${NC}"
echo -e " ${CYAN}./build.sh${NC} - Quick rebuild"
echo -e " ${CYAN}sagepypi build .${NC} - Build distribution packages"
echo -e " ${CYAN}sagepypi build . --upload --no-dry-run${NC} - Build and publish to PyPI"
echo ""
echo -e "${GREEN}Happy coding! 🚀${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"