Fix setup command venv recreation logic

When user declined venv recreation, setup was still printing
"Setting up virtual environment..." before checking if it existed,
making it appear that recreation was proceeding anyway.

Changes:
- Check for existing venv before printing any messages
- Show " Using existing virtual environment" when user declines
- Show "🐍 Recreating..." only when actually recreating
- Show "🐍 Setting up..." only for new venv creation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vijay Janapa Reddi
2025-12-01 12:11:19 -05:00
parent 244ac44a3e
commit aae2ac16bf

View File

@@ -141,16 +141,18 @@ class SetupCommand(BaseCommand):
def create_virtual_environment(self) -> bool:
"""Create a virtual environment for Tiny🔥Torch development."""
self.console.print("🐍 Setting up virtual environment...")
venv_path = self.config.project_root / ".venv"
if venv_path.exists():
if not Confirm.ask(f"Virtual environment already exists at {venv_path}. Recreate?"):
self.console.print("[green]✅ Using existing virtual environment[/green]")
return True
self.console.print("🐍 Recreating virtual environment...")
import shutil
shutil.rmtree(venv_path)
else:
self.console.print("🐍 Setting up virtual environment...")
try:
# Detect Apple Silicon and force arm64 if needed