Skip to content

Commit 53c4e7d

Browse files
committed
chore: replace poetry with uv
Migrate the project from Poetry to uv for dependency management and environment handling. This includes updating the build system, configuration files, and CI/CD workflows. - Replace `pyproject.toml` Poetry configuration with PEP 621 `[project]` and PEP 735 `[dependency-groups]` metadata. - Update `Dockerfile` to use `uv` for installing dependencies. - Update GitHub Actions workflow to use `astral-sh/setup-uv`. - Update documentation (README, MIGRATION_STATUS, UPGRADE_PLAN) to reflect `uv sync` and `uv run` commands. - Update all test scripts, examples, and internal error messages to use `uv` instead of `poetry`. - Switch build backend from `poetry-core` to `hatchling`.
1 parent 7495174 commit 53c4e7d

14 files changed

Lines changed: 2910 additions & 3204 deletions

.github/workflows/ci.yml

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,33 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v5
21-
with:
22-
python-version: ${{ matrix.python-version }}
23-
24-
- name: Install Poetry
25-
uses: snok/install-poetry@v1
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v5
2621
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
22+
enable-cache: true
2923

30-
- name: Load cached venv
31-
id: cached-poetry-dependencies
32-
uses: actions/cache@v4
33-
with:
34-
path: .venv
35-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
3626

3727
- name: Install dependencies
38-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
39-
run: poetry install --no-interaction --no-root
40-
41-
- name: Install project
42-
run: poetry install --no-interaction
28+
run: uv sync --locked --python ${{ matrix.python-version }}
4329

4430
- name: Run linting
45-
run: poetry run black --check src tests
31+
run: uv run black --check src tests
4632

4733
- name: Type checking
48-
run: poetry run mypy src --ignore-missing-imports
34+
run: uv run mypy src --ignore-missing-imports
4935
continue-on-error: true
5036

5137
- name: Security scan
52-
run: poetry run bandit -r src/ -ll -x tests
38+
run: uv run bandit -r src/ -ll -x tests
5339

5440
- name: Dependency vulnerability scan
55-
run: poetry run safety check || true
41+
run: uv run safety check || true
5642
continue-on-error: true
5743

5844
- name: Run tests
59-
run: poetry run pytest tests/ -v --cov=src --cov-report=xml --cov-report=term-missing
45+
run: uv run pytest tests/ -v --cov=src --cov-report=xml --cov-report=term-missing
6046

6147
- name: Upload coverage to Codecov
6248
if: matrix.python-version == '3.11'

Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
FROM python:3.12-slim
22

3-
# Install system deps (curl for Poetry installer)
4-
RUN apt-get update && apt-get install -y \
5-
curl \
6-
&& rm -rf /var/lib/apt/lists/*
3+
# Install uv by copying its static binaries from the official image (pinned tag).
4+
COPY --from=ghcr.io/astral-sh/uv:0.11.19 /uv /uvx /bin/
75

8-
# Install Poetry globally
9-
RUN curl -sSL https://install.python-poetry.org | python3 -
10-
11-
# Add Poetry to PATH
12-
ENV PATH="/root/.local/bin:${PATH}"
6+
# Copy files into the container as the root user by default.
7+
ENV UV_LINK_MODE=copy
138

149
# Note: Claude Code CLI is bundled with claude-agent-sdk >= 0.1.8
1510
# No separate Node.js/npm installation required
@@ -20,11 +15,13 @@ COPY . /app
2015
# Set working directory
2116
WORKDIR /app
2217

23-
# Install Python dependencies with Poetry
24-
RUN poetry install --no-root
18+
# Install Python dependencies with uv into a project-local virtual environment.
19+
# `--locked` fails the build if uv.lock is out of date with pyproject.toml (rather than
20+
# silently using a stale lock); `--no-dev` skips dev-only tooling.
21+
RUN uv sync --locked --no-dev
2522

2623
# Expose the port (default 8000)
2724
EXPOSE 8000
2825

2926
# Run the app with Uvicorn (development mode with reload; switch to --no-reload for prod)
30-
CMD ["poetry", "run", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
27+
CMD ["uv", "run", "uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

0 commit comments

Comments
 (0)