Uv migration#152
Conversation
|
I'm fine with moving to Can you isolate that from the build backend change, it should be independent and I don't immediatly see a benefit of changing the build backend. I don't think |
- Remove manually-maintained requirements.txt, requirements-test.txt, requirements-mypy.txt (from pip-deepfreeze) - Add auto-generated uv.lock for deterministic dependency resolution - Add .python-version file for uv Python version management (3.13)
- Use ghcr.io/astral-sh/uv:latest as uv source - Use UV_SYSTEM_PYTHON=1 to install into system Python - Use uv sync with layer caching (--no-install-project first) - Remove ENV PYTHONPATH=/app since the package is now properly installed into site-packages
- Replace actions/setup-python with astral-sh/setup-uv - Use `uv sync` instead of pip install - Use `uv run` for pytest and mypy execution
- Replace pip-based setup with uv sync --extra test - Update run commands to use uv run
It was just to be "in sync" with the switch to UV; I have the impression that when we make this change we also switch to uv_build or hatchling as the build system ;) I will remove this part from the PR.
You're right, it's recommended to version the .python-version to indicate the "recommended" version, but since the Python version is very targeted by requires-python, it's unnecessary here. |
| version = "0.2" | ||
| description = "A simple Odoo runbot lookalike using kubernetes." |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
=======================================
Coverage 64.59% 64.59%
=======================================
Files 19 19
Lines 1257 1257
=======================================
Hits 812 812
Misses 445 445 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| COPY requirements.txt /tmp/requirements.txt | ||
| RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv | ||
| ENV UV_SYSTEM_PYTHON=1 |
There was a problem hiding this comment.
| ENV UV_SYSTEM_PYTHON=1 | |
| ENV UV_SYSTEM_PYTHON=1 | |
| ENV UV_COMPILE_BYTECODE=1 |
| COPY pyproject.toml uv.lock ./ | ||
| RUN uv sync --frozen --no-dev --no-install-project |
There was a problem hiding this comment.
| COPY pyproject.toml uv.lock ./ | |
| RUN uv sync --frozen --no-dev --no-install-project | |
| # Install dependencies | |
| RUN --mount=type=cache,target=/root/.cache/uv \ | |
| --mount=type=bind,source=uv.lock,target=uv.lock \ | |
| --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | |
| uv sync --locked --no-install-project |
Following uv's recommendation: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
|
|
||
| # Install the project | ||
| COPY src/ src/ | ||
| RUN uv sync --frozen --no-dev --no-editable |
There was a problem hiding this comment.
| RUN uv sync --frozen --no-dev --no-editable | |
| RUN uv sync --locked --no-dev |
Editable should be fine, and avoids a copy of the app files.
| RUN uv sync --frozen --no-dev --no-install-project | ||
|
|
||
| # Install the project | ||
| COPY src/ src/ |
There was a problem hiding this comment.
| COPY src/ src/ | |
| COPY src/ /app/ |
No need to change this
|
|
||
| EXPOSE 8000 | ||
|
|
||
| CMD [ "gunicorn", "-w", "1", "--bind", ":8000", "-k", "runboat.uvicorn.RunboatUvicornWorker", "--access-logfile=-", "runboat.app:app"] |
There was a problem hiding this comment.
| CMD [ "gunicorn", "-w", "1", "--bind", ":8000", "-k", "runboat.uvicorn.RunboatUvicornWorker", "--access-logfile=-", "runboat.app:app"] | |
| CMD [ "uv", "run", "gunicorn", "-w", "1", "--bind", ":8000", "-k", "runboat.uvicorn.RunboatUvicornWorker", "--access-logfile=-", "runboat.app:app"] |
I've not tested this but I suspect this is necessary
Switch from pip to uv