chore(backend): 迁移包管理工具从 pip 到 uv
- 新增 pyproject.toml 替代 requirements.txt,合并 pytest.ini 配置 - 添加 greenlet、httpx[socks] 依赖修复运行时错误 - 添加 basedpyright + ruff 开发工具及配置 - 更新 Dockerfile 使用 uv 安装依赖 - 更新 CLAUDE.md 所有后端命令为 uv 前缀 - 删除 requirements.txt 和 pytest.ini Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -1,5 +1,7 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
@@ -8,9 +10,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpq-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements and install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
# Copy dependency files and install
|
||||
COPY pyproject.toml uv.lock ./
|
||||
RUN uv sync --frozen --no-dev --no-install-project
|
||||
|
||||
# Copy application code
|
||||
COPY app/ ./app/
|
||||
@@ -27,4 +29,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
|
||||
# Start application
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
[project]
|
||||
name = "kol-insight-backend"
|
||||
version = "0.1.0"
|
||||
description = "KOL Insight - KOL 数据查询与分析工具后端"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
# Web Framework
|
||||
"fastapi>=0.104.0",
|
||||
"uvicorn[standard]>=0.24.0",
|
||||
# Database
|
||||
"sqlalchemy>=2.0.0",
|
||||
"asyncpg>=0.29.0",
|
||||
"alembic>=1.12.0",
|
||||
"greenlet>=3.0.0",
|
||||
# HTTP Client
|
||||
"httpx[socks]>=0.25.0",
|
||||
# Data Validation
|
||||
"pydantic>=2.0.0",
|
||||
"pydantic-settings>=2.0.0",
|
||||
# Excel Export
|
||||
"openpyxl>=3.1.0",
|
||||
# Environment
|
||||
"python-dotenv>=1.0.0",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"pytest>=7.4.0",
|
||||
"pytest-asyncio>=0.21.0",
|
||||
"pytest-cov>=4.1.0",
|
||||
"basedpyright>=1.20.0",
|
||||
"ruff>=0.8.0",
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
asyncio_mode = "auto"
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
addopts = "-v --cov=app --cov-report=html --cov-report=term-missing"
|
||||
|
||||
[tool.basedpyright]
|
||||
typeCheckingMode = "basic"
|
||||
pythonVersion = "3.11"
|
||||
include = ["app"]
|
||||
exclude = [".venv", "**/__pycache__", "alembic", "tests"]
|
||||
extraPaths = ["app"]
|
||||
reportMissingTypeStubs = false
|
||||
reportUnknownMemberType = false
|
||||
reportUnknownArgumentType = false
|
||||
reportGeneralTypeIssues = false
|
||||
reportOptionalMemberAccess = "warning"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 150
|
||||
target-version = "py311"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle 错误
|
||||
"F", # Pyflakes 错误(未定义变量、未使用导入等)
|
||||
"B", # bugbear 安全警告
|
||||
"I", # import 排序
|
||||
]
|
||||
ignore = ["E501"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"!app/**" = ["E", "F", "B", "I"]
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "double"
|
||||
indent-style = "space"
|
||||
line-ending = "auto"
|
||||
@@ -1,5 +0,0 @@
|
||||
[pytest]
|
||||
testpaths = tests
|
||||
asyncio_mode = auto
|
||||
asyncio_default_fixture_loop_scope = function
|
||||
addopts = -v --cov=app --cov-report=html --cov-report=term-missing
|
||||
@@ -1,27 +0,0 @@
|
||||
# Web Framework
|
||||
fastapi>=0.104.0
|
||||
uvicorn[standard]>=0.24.0
|
||||
|
||||
# Database
|
||||
sqlalchemy>=2.0.0
|
||||
asyncpg>=0.29.0
|
||||
alembic>=1.12.0
|
||||
|
||||
# HTTP Client
|
||||
httpx>=0.25.0
|
||||
|
||||
# Data Validation
|
||||
pydantic>=2.0.0
|
||||
pydantic-settings>=2.0.0
|
||||
|
||||
# Excel Export
|
||||
openpyxl>=3.1.0
|
||||
|
||||
# Testing
|
||||
pytest>=7.4.0
|
||||
pytest-asyncio>=0.21.0
|
||||
pytest-cov>=4.1.0
|
||||
httpx>=0.25.0
|
||||
|
||||
# Development
|
||||
python-dotenv>=1.0.0
|
||||
Generated
+1207
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user