|
24 | 24 | def install(package: str): |
25 | 25 | """Install a package with `uv` and add it to pyproject.toml.""" |
26 | 26 |
|
| 27 | + from agentstack.cli.spinner import Spinner |
| 28 | + |
27 | 29 | def on_progress(line: str): |
28 | 30 | if RE_UV_PROGRESS.match(line): |
29 | | - log.info(line.strip()) |
| 31 | + spinner.clear_and_log(line.strip(), 'info') |
30 | 32 |
|
31 | 33 | def on_error(line: str): |
32 | 34 | log.error(f"uv: [error]\n {line.strip()}") |
33 | | - |
34 | | - log.info(f"Installing {package}") |
35 | | - _wrap_command_with_callbacks( |
36 | | - [get_uv_bin(), 'add', '--python', '.venv/bin/python', package], |
37 | | - on_progress=on_progress, |
38 | | - on_error=on_error, |
39 | | - ) |
| 35 | + |
| 36 | + with Spinner(f"Installing {package}") as spinner: |
| 37 | + _wrap_command_with_callbacks( |
| 38 | + [get_uv_bin(), 'add', '--python', '.venv/bin/python', package], |
| 39 | + on_progress=on_progress, |
| 40 | + on_error=on_error, |
| 41 | + ) |
40 | 42 |
|
41 | 43 |
|
42 | 44 | def install_project(): |
43 | 45 | """Install all dependencies for the user's project.""" |
44 | 46 |
|
| 47 | + from agentstack.cli.spinner import Spinner |
| 48 | + |
45 | 49 | def on_progress(line: str): |
46 | 50 | if RE_UV_PROGRESS.match(line): |
47 | | - log.info(line.strip()) |
| 51 | + spinner.clear_and_log(line.strip(), 'info') |
48 | 52 |
|
49 | 53 | def on_error(line: str): |
50 | 54 | log.error(f"uv: [error]\n {line.strip()}") |
51 | 55 |
|
52 | 56 | try: |
53 | | - result = _wrap_command_with_callbacks( |
54 | | - [get_uv_bin(), 'pip', 'install', '--python', '.venv/bin/python', '.'], |
55 | | - on_progress=on_progress, |
56 | | - on_error=on_error, |
57 | | - ) |
58 | | - if result is False: |
59 | | - log.info("Retrying uv installation with --no-cache flag...") |
60 | | - _wrap_command_with_callbacks( |
61 | | - [get_uv_bin(), 'pip', 'install', '--no-cache', '--python', '.venv/bin/python', '.'], |
| 57 | + with Spinner(f"Installing project dependencies.") as spinner: |
| 58 | + result = _wrap_command_with_callbacks( |
| 59 | + [get_uv_bin(), 'pip', 'install', '--python', '.venv/bin/python', '.'], |
62 | 60 | on_progress=on_progress, |
63 | 61 | on_error=on_error, |
64 | 62 | ) |
| 63 | + if result is False: |
| 64 | + spinner.clear_and_log("Retrying uv installation with --no-cache flag...", 'info') |
| 65 | + _wrap_command_with_callbacks( |
| 66 | + [get_uv_bin(), 'pip', 'install', '--no-cache', '--python', '.venv/bin/python', '.'], |
| 67 | + on_progress=on_progress, |
| 68 | + on_error=on_error, |
| 69 | + ) |
65 | 70 | except Exception as e: |
66 | 71 | log.error(f"Installation failed: {str(e)}") |
67 | 72 | raise |
|
0 commit comments