Skip to content

Commit 998f4b3

Browse files
committed
switch to uv
1 parent a5f985c commit 998f4b3

File tree

7 files changed

+606
-890
lines changed

7 files changed

+606
-890
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
*.egg-info/

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ jobs:
4242
uses: actions/setup-python@v5
4343
with:
4444
python-version: "3.12"
45-
- name: Setup poetry
46-
uses: abatilo/actions-poetry@v2
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v5
4747
with:
48-
poetry-version: "1.8.3"
48+
version: "0.5.18"
4949
- name: Install dependencies
50-
run: poetry install --with=test
50+
run: uv sync --group=test
5151
- name: Run pytest
52-
run: poetry run pytest --cov=teufa --cov-report=xml tests/
52+
run: uv run pytest --cov=teufa --cov-report=xml tests/
5353
env:
5454
DATABASE_URL: postgresql+psycopg://postgres:postgres@localhost:5432/postgres
5555
- name: Upload coverage reports to Codecov

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.mypy_cache/
22
.pytest_cache/
33
.ruff_cache/
4+
.venv
5+
*.egg-info/
46
notes.txt
57

Dockerfile

+14-29
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# syntax=docker/dockerfile:1
22

33
## base image
4-
FROM python:3.12-slim as base
4+
FROM python:3.12-slim AS base
55

66
ENV PYTHONUNBUFFERED=1 \
77
PYTHONDONTWRITEBYTECODE=1 \
8-
PIP_DISABLE_PIP_VERSION_CHECK=on \
9-
PIP_DEFAULT_TIMEOUT=100 \
10-
POETRY_VERSION="1.8.3" \
11-
POETRY_HOME="/opt/poetry" \
12-
POETRY_NO_INTERACTION=1 \
13-
VENV_PATH="/opt/venv" \
8+
VENV_PATH="/opt/app/.venv" \
149
APP_HOME="/opt/app"
15-
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
10+
ENV PATH="$VENV_PATH/bin:$PATH"
1611
ENV VIRTUAL_ENV=$VENV_PATH
1712

1813
RUN set -ex \
@@ -23,7 +18,7 @@ RUN set -ex \
2318

2419

2520
## builder-base image
26-
FROM base as builder-base
21+
FROM base AS builder-base
2722
RUN apt-get update && \
2823
apt-get install --no-install-recommends -y \
2924
curl \
@@ -32,32 +27,25 @@ RUN apt-get update && \
3227
python3-dev \
3328
&& rm -rf /var/lib/apt/lists/*
3429

35-
RUN --mount=type=cache,target=/root/.cache \
36-
curl -sSL https://install.python-poetry.org | python -
30+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
3731

3832
WORKDIR $APP_HOME
39-
COPY poetry.lock pyproject.toml ./
33+
COPY uv.lock pyproject.toml ./
4034

41-
RUN --mount=type=cache,target=/root/.cache \
42-
python -m venv $VENV_PATH && \
43-
poetry install --no-root --only=main
35+
RUN uv sync --frozen
4436

4537
COPY . .
46-
RUN --mount=type=cache,target=/root/.cache \
47-
poetry install --only-root
4838

4939

5040
## dev image
51-
FROM base as dev
41+
FROM base AS dev
5242

53-
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
54-
COPY --from=builder-base $VENV_PATH $VENV_PATH
5543
COPY --from=builder-base $APP_HOME $APP_HOME
44+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
5645

5746
WORKDIR $APP_HOME
5847

59-
RUN --mount=type=cache,target=/root/.cache \
60-
poetry install --with=dev && \
48+
RUN uv sync --frozen --dev && \
6149
rm -rf $APP_HOME
6250

6351
EXPOSE 8000
@@ -67,22 +55,19 @@ CMD ["server", "--dev"]
6755

6856

6957
## ci image
70-
FROM base as ci
58+
FROM base AS ci
7159

72-
COPY --from=builder-base $POETRY_HOME $POETRY_HOME
73-
COPY --from=builder-base $VENV_PATH $VENV_PATH
7460
COPY --from=builder-base $APP_HOME $APP_HOME
61+
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
7562

7663
WORKDIR $APP_HOME
7764

78-
RUN --mount=type=cache,target=/root/.cache \
79-
poetry install --with=test
65+
RUN uv sync --frozen --group=test
8066

8167

8268
## prod image
83-
FROM base as prod
69+
FROM base AS prod
8470

85-
COPY --from=builder-base $VENV_PATH $VENV_PATH
8671
COPY --from=builder-base /opt/app /opt/app
8772

8873
WORKDIR $APP_HOME

poetry.lock

-830
This file was deleted.

pyproject.toml

+30-26
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
[tool.poetry]
1+
[project]
22
name = "teufa"
33
version = "0.1.0"
44
description = ""
5-
license = "MIT"
6-
authors = ["Brian Rosner <[email protected]>"]
75
readme = "README.md"
8-
packages = [
9-
{ include = "teufa" },
6+
authors = [
7+
{name = "Brian Rosner", email = "[email protected]"},
8+
]
9+
license = {text = "MIT"}
10+
requires-python = "<4.0,>=3.12"
11+
dependencies = [
12+
"click<9.0.0,>=8.1.7",
13+
"gunicorn<23.0.0,>=22.0.0",
14+
"flask<4.0.0,>=3.0.3",
15+
"flask-sqlalchemy<4.0.0,>=3.1.1",
16+
"psycopg<4.0.0,>=3.1.19",
17+
"alembic<2.0.0,>=1.13.1",
18+
"pydantic<3.0.0,>=2.7.1",
19+
"flask-restful<1.0.0,>=0.3.10",
1020
]
1121

12-
[tool.poetry.dependencies]
13-
python = "^3.12"
14-
click = "^8.1.7"
15-
gunicorn = "^22.0.0"
16-
flask = "^3.0.3"
17-
flask-sqlalchemy = "^3.1.1"
18-
psycopg = "^3.1.19"
19-
alembic = "^1.13.1"
20-
pydantic = "^2.7.1"
21-
flask-restful = "^0.3.10"
22-
23-
[tool.poetry.scripts]
22+
[project.scripts]
2423
teufa = "teufa.cli:cli"
2524

26-
[tool.poetry.group.test.dependencies]
27-
pytest = "^8.2.0"
28-
pytest-cov = "^5.0.0"
25+
[dependency-groups]
26+
test = [
27+
"pytest<9.0.0,>=8.2.0",
28+
"pytest-cov<6.0.0,>=5.0.0",
29+
]
30+
dev = [
31+
"pydeps<2.0.0,>=1.12.20",
32+
"ruff<1.0.0,>=0.5.0",
33+
]
2934

30-
[tool.poetry.group.dev.dependencies]
31-
pydeps = "^1.12.20"
32-
ruff = "^0.5.0"
35+
[tool.uv]
36+
package = true
37+
default-groups = []
3338

34-
[build-system]
35-
requires = ["poetry-core"]
36-
build-backend = "poetry.core.masonry.api"
39+
[tool.setuptools]
40+
packages = ["teufa"]

0 commit comments

Comments
 (0)