Avoid external venv or of fastapi-vue-setup itself leaking into target project. Cleaner and faster uv processing.

This commit is contained in:
2026-02-02 13:46:34 +00:00
parent c271f66615
commit c23401de88
+18 -21
View File
@@ -896,6 +896,9 @@ def cmd_setup(args: argparse.Namespace) -> int:
- Patching existing projects with integration files - Patching existing projects with integration files
- Updating already-patched projects - Updating already-patched projects
""" """
# Clear any existing virtual environment to avoid uv using the wrong one (warning)
os.environ.pop("VIRTUAL_ENV", None)
project_path = Path(args.project_dir) project_path = Path(args.project_dir)
# Handle both "." and "/path/to/project" # Handle both "." and "/path/to/project"
@@ -1111,27 +1114,6 @@ def cmd_setup(args: argparse.Namespace) -> int:
pyproject_path.write_text(new_content, "UTF-8", newline="\n") pyproject_path.write_text(new_content, "UTF-8", newline="\n")
print(f"✅ Updated {pyproject_path}") print(f"✅ Updated {pyproject_path}")
# === Add dependencies using uv ===
if dry_run:
print("[DRY RUN] Would run: uv add -U 'fastapi[standard]' fastapi-vue")
print("[DRY RUN] Would run: uv add -U --group dev httpx")
else:
print("📦 Adding dependencies...")
result = subprocess.run(
["uv", "add", "-U", "fastapi[standard]", "fastapi-vue"],
cwd=project_dir,
check=False,
)
if result.returncode != 0:
print("⚠️ Failed to add main dependencies")
result = subprocess.run(
["uv", "add", "-U", "--group", "dev", "httpx"],
cwd=project_dir,
check=False,
)
if result.returncode != 0:
print("⚠️ Failed to add dev dependencies")
# === Update .gitignore === # === Update .gitignore ===
gitignore_path = project_dir / ".gitignore" gitignore_path = project_dir / ".gitignore"
gitignore_entry = f"/{module_name}/frontend-build" gitignore_entry = f"/{module_name}/frontend-build"
@@ -1154,6 +1136,21 @@ def cmd_setup(args: argparse.Namespace) -> int:
gitignore_path.write_text(f"{gitignore_entry}\n", "UTF-8", newline="\n") gitignore_path.write_text(f"{gitignore_entry}\n", "UTF-8", newline="\n")
print("✅ Created .gitignore") print("✅ Created .gitignore")
# === Add dependencies using uv ===
uv_add_main = ["uv", "add", "-q", "-U", "--no-sync", "fastapi[standard]", "fastapi-vue"]
uv_add_dev = ["uv", "add", "-q", "-U", "--group", "dev", "httpx"]
if dry_run:
print(f"[DRY RUN] Would run: {' '.join(uv_add_main)}")
print(f"[DRY RUN] Would run: {' '.join(uv_add_dev)}")
else:
print("📦 Adding dependencies...")
result = subprocess.run(uv_add_main, cwd=project_dir, check=False)
if result.returncode != 0:
print("⚠️ Failed to add main dependencies")
result = subprocess.run(uv_add_dev, cwd=project_dir, check=False)
if result.returncode != 0:
print("⚠️ Failed to add dev dependencies")
print() print()
print("=" * 60) print("=" * 60)
print("✅ Setup complete!") print("✅ Setup complete!")