-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
254 lines (213 loc) · 6.88 KB
/
setup.ps1
File metadata and controls
254 lines (213 loc) · 6.88 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/env pwsh
<#
.SYNOPSIS
LogVeil Development Setup Script for Windows
.DESCRIPTION
This script sets up the LogVeil development environment on Windows.
It creates a virtual environment, installs dependencies, and configures
development tools.
.PARAMETER SkipVenv
Skip virtual environment creation (use system Python)
.PARAMETER DevMode
Install additional development dependencies
.PARAMETER QuickSetup
Run minimal setup without optional components
.EXAMPLE
.\setup.ps1
Standard setup with virtual environment
.EXAMPLE
.\setup.ps1 -DevMode
Setup with additional development tools
.EXAMPLE
.\setup.ps1 -QuickSetup
Minimal setup for quick testing
#>
param(
[switch]$SkipVenv,
[switch]$DevMode,
[switch]$QuickSetup
)
# Configuration
$ErrorActionPreference = "Stop"
$VenvDir = "venv"
# Colors for output
$ColorGreen = "Green"
$ColorYellow = "Yellow"
$ColorRed = "Red"
$ColorBlue = "Blue"
function Write-Status {
param([string]$Message, [string]$Color = "Blue")
Write-Host "🔧 $Message" -ForegroundColor $Color
}
function Write-Success {
param([string]$Message)
Write-Host "✅ $Message" -ForegroundColor $ColorGreen
}
function Write-Warning {
param([string]$Message)
Write-Host "⚠️ $Message" -ForegroundColor $ColorYellow
}
function Write-Error {
param([string]$Message)
Write-Host "❌ $Message" -ForegroundColor $ColorRed
}
function Test-PythonVersion {
try {
$pythonVersion = python --version 2>&1
if ($pythonVersion -match "Python (\d+)\.(\d+)") {
$major = [int]$matches[1]
$minor = [int]$matches[2]
if ($major -eq 3 -and $minor -ge 8) {
Write-Success "Python $($matches[0]) found"
return $true
}
}
Write-Error "Python 3.8+ required, found: $pythonVersion"
return $false
}
catch {
Write-Error "Python not found in PATH"
return $false
}
}
function New-VirtualEnvironment {
if ($SkipVenv) {
Write-Warning "Skipping virtual environment creation"
return
}
Write-Status "Creating virtual environment..."
if (Test-Path $VenvDir) {
Write-Warning "Virtual environment already exists, removing..."
Remove-Item -Recurse -Force $VenvDir
}
python -m venv $VenvDir
if ($LASTEXITCODE -ne 0) {
throw "Failed to create virtual environment"
}
Write-Success "Virtual environment created"
}
function Install-Dependencies {
Write-Status "Installing dependencies..."
if (-not $SkipVenv) {
& "$VenvDir\Scripts\Activate.ps1"
}
# Upgrade pip and core tools
python -m pip install --upgrade pip setuptools wheel
if ($LASTEXITCODE -ne 0) {
throw "Failed to upgrade pip"
}
# Install base requirements
if (Test-Path "requirements.txt") {
pip install -r requirements.txt
if ($LASTEXITCODE -ne 0) {
throw "Failed to install requirements"
}
}
# Install package in development mode
pip install -e .
if ($LASTEXITCODE -ne 0) {
throw "Failed to install LogVeil"
}
# Install development dependencies
if ($DevMode -or -not $QuickSetup) {
Write-Status "Installing development dependencies..."
pip install pytest pytest-cov black isort mypy flake8 pre-commit
if ($LASTEXITCODE -ne 0) {
Write-Warning "Some development dependencies failed to install"
}
}
Write-Success "Dependencies installed"
}
function Install-PreCommitHooks {
if ($QuickSetup) {
Write-Warning "Skipping pre-commit hooks (quick setup)"
return
}
try {
Write-Status "Installing pre-commit hooks..."
pre-commit install
Write-Success "Pre-commit hooks installed"
}
catch {
Write-Warning "Failed to install pre-commit hooks"
}
}
function Test-Installation {
Write-Status "Testing installation..."
try {
python -c "import logveil; print(f'LogVeil {logveil.__version__} installed successfully')"
Write-Success "LogVeil imported successfully"
}
catch {
Write-Error "Failed to import LogVeil"
throw
}
if (-not $QuickSetup) {
Write-Status "Running basic tests..."
python -m pytest tests/ -x --tb=short
if ($LASTEXITCODE -eq 0) {
Write-Success "Basic tests passed"
} else {
Write-Warning "Some tests failed, but installation appears successful"
}
}
}
function Show-NextSteps {
Write-Host ""
Write-Host "🎉 LogVeil development environment setup complete!" -ForegroundColor $ColorGreen
Write-Host ""
Write-Host "Next steps:" -ForegroundColor $ColorBlue
if (-not $SkipVenv) {
Write-Host " 1. Activate virtual environment:" -ForegroundColor $ColorBlue
Write-Host " $VenvDir\Scripts\Activate.ps1" -ForegroundColor White
}
Write-Host " 2. Run tests:" -ForegroundColor $ColorBlue
Write-Host " pytest" -ForegroundColor White
Write-Host " 3. Try the CLI:" -ForegroundColor $ColorBlue
Write-Host " python cli/logveil-agent.py sample_log.txt" -ForegroundColor White
Write-Host " 4. Start development server:" -ForegroundColor $ColorBlue
Write-Host " python -m logveil serve" -ForegroundColor White
Write-Host ""
Write-Host "Development commands:" -ForegroundColor $ColorBlue
Write-Host " Format code: black ." -ForegroundColor White
Write-Host " Run linting: flake8 ." -ForegroundColor White
Write-Host " Type checking: mypy ." -ForegroundColor White
Write-Host " Run benchmarks: python tools/testbench/benchmark.py" -ForegroundColor White
Write-Host ""
}
# Main execution
try {
Write-Host "LogVeil Development Setup" -ForegroundColor $ColorBlue
Write-Host "========================" -ForegroundColor $ColorBlue
Write-Host ""
# Check prerequisites
if (-not (Test-PythonVersion)) {
Write-Host "Please install Python 3.8+ and add it to PATH"
exit 1
}
# Check if Git is available
try {
git --version | Out-Null
Write-Success "Git found"
}
catch {
Write-Warning "Git not found - some features may not work"
}
# Setup steps
New-VirtualEnvironment
Install-Dependencies
Install-PreCommitHooks
Test-Installation
Show-NextSteps
Write-Success "Setup completed successfully!"
}
catch {
Write-Error "Setup failed: $($_.Exception.Message)"
Write-Host ""
Write-Host "Troubleshooting tips:" -ForegroundColor $ColorYellow
Write-Host " - Ensure Python 3.8+ is installed and in PATH"
Write-Host " - Run PowerShell as Administrator if permission issues occur"
Write-Host " - Check internet connection for package downloads"
Write-Host " - Try running with -QuickSetup for minimal installation"
exit 1
}