|
5 | 5 | _ "embed" |
6 | 6 | "encoding/json" |
7 | 7 | "fmt" |
8 | | - "log" |
9 | 8 | "os" |
10 | 9 | "os/exec" |
11 | 10 | "path/filepath" |
@@ -218,14 +217,11 @@ func RunBootstrapNewAgent(ctx context.Context, arguments string) (string, string |
218 | 217 | meta.Steps = append(meta.Steps, "Created pyproject.toml") |
219 | 218 |
|
220 | 219 | // Initialize uv project or fallback to venv |
221 | | - log.Printf("Initializing virtual environment for agent: %s", agentName) |
222 | 220 | if err := initializeVenv(agentDir); err != nil { |
223 | | - log.Printf("Failed to initialize venv for %s: %v", agentName, err) |
224 | 221 | meta.Error = fmt.Sprintf("failed to initialize virtual environment: %v", err) |
225 | 222 | mb, _ := json.Marshal(meta) |
226 | 223 | return fmt.Sprintf("Error: %s", meta.Error), string(mb) |
227 | 224 | } |
228 | | - log.Printf("Virtual environment initialized successfully for agent: %s", agentName) |
229 | 225 | meta.Steps = append(meta.Steps, "Initialized virtual environment and installed dependencies") |
230 | 226 |
|
231 | 227 | // Update agents.yaml |
@@ -302,65 +298,41 @@ func initializeVenv(agentDir string) error { |
302 | 298 |
|
303 | 299 | // Step 1: Create virtual environment |
304 | 300 | // Try uv first |
305 | | - log.Printf("Attempting to create venv with uv in %s", agentDir) |
306 | 301 | cmd := exec.Command("uv", "venv", ".venv") |
307 | 302 | cmd.Dir = agentDir |
308 | | - uvOutput, uvErr := cmd.CombinedOutput() |
| 303 | + _, uvErr := cmd.CombinedOutput() |
309 | 304 | uvAvailable := uvErr == nil |
310 | 305 |
|
311 | 306 | if !uvAvailable { |
312 | | - log.Printf("uv not available, falling back to python3 -m venv") |
313 | 307 | // Fallback to python -m venv |
314 | 308 | cmd = exec.Command("python3", "-m", "venv", ".venv") |
315 | 309 | cmd.Dir = agentDir |
316 | 310 | output, err := cmd.CombinedOutput() |
317 | 311 | if err != nil { |
318 | | - log.Printf("Failed to create venv: %v, output: %s", err, string(output)) |
319 | 312 | return fmt.Errorf("failed to create venv: %w (output: %s)", err, string(output)) |
320 | 313 | } |
321 | | - log.Printf("Virtual environment created with python3 -m venv") |
322 | | - } else { |
323 | | - log.Printf("Virtual environment created with uv") |
324 | | - if len(uvOutput) > 0 { |
325 | | - log.Printf("uv output: %s", string(uvOutput)) |
326 | | - } |
327 | 314 | } |
328 | 315 |
|
329 | 316 | // Step 2: Install agent as editable package (makes opperator/ importable) |
330 | 317 | if uvAvailable { |
331 | 318 | // Use uv pip install with --python flag |
332 | | - log.Printf("Installing agent package with uv pip install") |
333 | 319 | cmd = exec.Command("uv", "pip", "install", "-e", agentDir, "--python", venvPython) |
334 | | - output, err := cmd.CombinedOutput() |
| 320 | + _, err := cmd.CombinedOutput() |
335 | 321 | if err != nil { |
336 | | - log.Printf("uv pip install failed: %v, output: %s, trying pip fallback", err, string(output)) |
337 | 322 | // If uv pip install fails, try pip fallback |
338 | 323 | cmd = exec.Command(venvPython, "-m", "pip", "install", "-e", agentDir) |
339 | 324 | output, err := cmd.CombinedOutput() |
340 | 325 | if err != nil { |
341 | | - log.Printf("pip install failed: %v, output: %s", err, string(output)) |
342 | 326 | return fmt.Errorf("failed to install agent package: %w (output: %s)", err, string(output)) |
343 | 327 | } |
344 | | - log.Printf("Agent package installed with pip") |
345 | | - } else { |
346 | | - log.Printf("Agent package installed with uv pip") |
347 | | - if len(output) > 0 { |
348 | | - log.Printf("uv pip output: %s", string(output)) |
349 | | - } |
350 | 328 | } |
351 | 329 | } else { |
352 | 330 | // Use pip directly |
353 | | - log.Printf("Installing agent package with pip") |
354 | 331 | cmd = exec.Command(venvPython, "-m", "pip", "install", "-e", agentDir) |
355 | 332 | output, err := cmd.CombinedOutput() |
356 | 333 | if err != nil { |
357 | | - log.Printf("pip install failed: %v, output: %s", err, string(output)) |
358 | 334 | return fmt.Errorf("failed to install agent package: %w (output: %s)", err, string(output)) |
359 | 335 | } |
360 | | - log.Printf("Agent package installed with pip") |
361 | | - if len(output) > 0 { |
362 | | - log.Printf("pip output: %s", string(output)) |
363 | | - } |
364 | 336 | } |
365 | 337 |
|
366 | 338 | return nil |
|
0 commit comments