Skip to content

Commit

Permalink
Migrate to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
flofriday committed Dec 21, 2024
1 parent 460eedb commit df53b34
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ jobs:
git pull
npm install
npx tailwindcss --minify -i app/templates/template.css -o app/static/style.css
source .venv/bin/activate
python -m pip install -r requirements.txt
uv sync
systemctl --user restart bettercal.service
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ COPY . .
RUN npm install
RUN npx tailwindcss -i app/templates/template.css -o app/static/style.css

FROM python:3.13 as pythonbuild
FROM python:3.12-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

WORKDIR /app
COPY --from=tailwindbuild /app .
RUN pip install -r requirements.txt
RUN uv sync

ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
ENTRYPOINT ["uv", "run", "--", "gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ enriches them with more information before returning it to the client.

## Build it yourself

You first need to install python3.13 and node.
You first need to install node and uv.

```bash
npm install
npx tailwindcss -i app/templates/template.css -o app/static/style.css
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
flask --app app run --debug
uv run -- flask app run --debug
```

The server should now start at http://localhost:5000
Expand All @@ -62,7 +59,7 @@ for development comfort.
You can run all tests with:

```bash
python -m pytest
uv run pytest
```

## Build with Docker
Expand Down
4 changes: 2 additions & 2 deletions bettercal.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ After=network.target

[Service]
WorkingDirectory=/home/bettercal/better-tiss-calendar/
ExecStart=/bin/bash -c 'source /home/bettercal/better-tiss-calendar/.venv/bin/activate; gunicorn -w 5 --bind localhost:5003 app:app'
ExecStart=uv run -- gunicorn -w 5 --bind localhost:5003 app:app
Restart=always

[Install]
WantedBy=default.target
WantedBy=default.target
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
[project]
name = "better-tiss-calendar"
version = "0.0.1"
dependencies = ["Flask", "gunicorn", "requests", "icalendar"]
requires-python = ">=3.13"
authors = [{ name = "flofriday" }]
description = "A better TISS calendar"
readme = "README.md"
license = { file = "LICENSE.txt" }

[tool.pytest.ini_options]
testpaths = ["tests"]
pythonpath = ["."]

[tool.coverage.run]
branch = true
source = ["app"]

[tool.ruff.lint]
select = ["E", "F", "UP", "B", "SIM", "I"]

[dependency-groups]
dev = ["pytest-mock>=3.14.0", "pytest>=8.3.4"]
28 changes: 0 additions & 28 deletions requirements.txt

This file was deleted.

315 changes: 315 additions & 0 deletions uv.lock

Large diffs are not rendered by default.

0 comments on commit df53b34

Please sign in to comment.