"""安装依赖 - 仅使用预编译wheel"""
import subprocess
import sys

pip = r"C:\Users\simon\.workbuddy\binaries\python\envs\default\Scripts\pip.exe"

# 第1步：安装不依赖 pydantic-core 编译的包
result1 = subprocess.run(
    [pip, "install", "--only-binary", ":all:",
     "sqlalchemy>=2.0.0", "aiosqlite", "pytest", "pytest-asyncio",
     "httpx", "python-dotenv", "redis", "cryptography",
     "uvicorn", "python-multipart"],
    capture_output=True, text=True
)

# 第2步：安装 fastapi（会拉取 pydantic）
result2 = subprocess.run(
    [pip, "install", "--only-binary", ":all:", "fastapi"],
    capture_output=True, text=True
)

output = f"=== Step 1 (exit: {result1.returncode}) ===\n"
output += f"STDOUT: {result1.stdout[-1500:]}\n"
output += f"STDERR: {result1.stderr[-800:]}\n\n"
output += f"=== Step 2 (exit: {result2.returncode}) ===\n"
output += f"STDOUT: {result2.stdout[-1500:]}\n"
output += f"STDERR: {result2.stderr[-800:]}"

with open(r"C:\Users\simon\WorkBuddy\2026-05-21-16-57-26\install_wheels.txt", "w", encoding="utf-8") as f:
    f.write(output)
