Skip to content

Commit c86c711

Browse files
committed
Move to uv for dependency management
1 parent 1c10b88 commit c86c711

File tree

10 files changed

+814
-342
lines changed

10 files changed

+814
-342
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*
22
!content/
3-
!requirements/
43
!src/
4+
!uv.lock
55
!.flaskenv
66
!gunicorn_conf.py
77
!LICENSE.txt

Dockerfile

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
FROM python:3.13 as build
2-
WORKDIR /opt
3-
RUN python -m venv --upgrade-deps venv
4-
COPY requirements requirements
5-
RUN venv/bin/pip install -r requirements/base.txt
1+
FROM python:3.13-slim AS builder
2+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
3+
WORKDIR /app
4+
RUN --mount=type=cache,target=/root/.cache/uv \
5+
--mount=type=bind,source=uv.lock,target=uv.lock \
6+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
7+
uv sync --frozen --no-install-project --no-editable --compile-bytecode
68

7-
FROM python:3.13-slim as deploy
8-
RUN useradd project
9-
USER project
9+
FROM python:3.13-slim
1010
EXPOSE 8000
11-
ENV PATH=/opt/venv/bin:$PATH \
12-
FLASK_APP=pallets
13-
USER root
14-
COPY --from=build /opt/venv /opt/venv
15-
WORKDIR /opt
16-
COPY --chown=1000:1000 . project
17-
RUN venv/bin/pip install -e project
18-
COPY gunicorn_conf.py .
19-
USER project
11+
WORKDIR /app
12+
COPY --from=builder /app/.venv /app/.venv
13+
ADD . /app
14+
ENV PATH=/app/.venv/bin:$PATH
15+
ENV FLASK_APP=pallets
16+
RUN --mount=type=cache,target=/root/.cache/uv \
17+
uv pip install -e .
2018
CMD ["gunicorn", "-c", "gunicorn_conf.py", "pallets:create_app()"]

pyproject.toml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ dependencies = [
1818
"mdit-py-plugins",
1919
"pygments",
2020
]
21+
[dependency-groups]
22+
dev = [
23+
"ruff",
24+
"tox",
25+
"tox-uv",
26+
"python-dotenv",
27+
"watchdog",
28+
]
29+
pre-commit= [
30+
"pre-commit",
31+
]
32+
typing= [
33+
"mypy",
34+
"pyright",
35+
"types-beautifulsoup4",
36+
"types-pygments",
37+
]
2138

2239
[project.urls]
2340
Home = "https://palletsprojects.com"
@@ -65,3 +82,46 @@ select = [
6582
[tool.ruff.lint.isort]
6683
force-single-line = true
6784
order-by-type = false
85+
86+
[tool.uv]
87+
default-groups = ["dev", "pre-commit", "typing"]
88+
89+
[tool.tox]
90+
envlist = ["style", "typing"]
91+
92+
[tool.tox.env.env_run_base]
93+
package = "wheel"
94+
wheel_build_env = ".pkg"
95+
constrain_package_deps = true
96+
use_frozen_constraints = true
97+
98+
[tool.tox.env.style]
99+
dependency_groups = ["pre-commit"]
100+
skip_install = true
101+
commands = [["pre-commit", "run", "--all-files"]]
102+
103+
[tool.tox.env.typing]
104+
dependency_groups = ["typing"]
105+
commands = [
106+
["mypy"],
107+
["pyright"]
108+
]
109+
110+
[tool.tox.env.update-actions]
111+
labels = ["update"]
112+
dependency_groups = ["gha-update"]
113+
commands = [["gha-update"]]
114+
115+
[tool.tox.env.update-pre_commit]
116+
labels = ["update"]
117+
dependency_groups = ["pre-commit"]
118+
skip_install = true
119+
commands = [["pre-commit", "autoupdate", "-j4"]]
120+
121+
[tool.tox.env.update-requirements]
122+
description = "update uv lock"
123+
labels = ["update"]
124+
dependency_groups = []
125+
no_default_groups = true
126+
skip_install = true
127+
commands = [["uv", "lock", {replace = "posargs", default = ["-U"], extend = true}]]

requirements/base.txt

Lines changed: 0 additions & 62 deletions
This file was deleted.

requirements/dev.in

Lines changed: 0 additions & 7 deletions
This file was deleted.

requirements/dev.txt

Lines changed: 0 additions & 179 deletions
This file was deleted.

requirements/typing.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)