Skip to content

Commit

Permalink
feat: poetry -> uv (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Dec 28, 2024
1 parent a185a24 commit 4248080
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 547 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"label": "Create superuser",
"type": "shell",
"command": "docker compose exec api poetry run python src/manage.py createsuperuser",
"command": "docker compose exec api uv run -- python src/manage.py createsuperuser",
"isBackground": false
}
]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ The general rule when it comes to dependencies is to have minimum of third party

### Backend dependencies

For dependency management in Django application we are using Poetry. When starting the project through the `docker compose` command, it is checked for new dependencies as well. In the case they are not installed, docker will install them before running development server.
For dependency management in Django application we are using `uv`. When starting the project through the `docker compose` command, it is checked for new dependencies as well. In the case they are not installed, docker will install them before running development server.

- **[djangorestframework](https://github.com/encode/django-rest-framework)** - REST API support
- **[djangorestframework-simplejwt](https://github.com/jazzband/djangorestframework-simplejwt)** - JWT auth for REST API
Expand All @@ -85,7 +85,7 @@ For dependency management in Django application we are using Poetry. When starti
Below, you can find a command to install new dependency into backend project.

```bash
docker compose exec api poetry add djangorestframework
docker compose exec api uv add djangorestframework
```

### Front end dependencies
Expand Down Expand Up @@ -168,7 +168,7 @@ openssl rand -base64 32
There are two ways how to create new user account in the backend. First option is to run managed command responsible for creating superuser. It is more or less required, if you want to have an access to the Django admin. After running the command below, it will be possible to log in on the front end part of the application.

```bash
docker compose exec api poetry run python src/manage.py createsuperuser
docker compose exec api uv run -- python src/manage.py createsuperuser
```

The second option how to create new user account is to register it on the front end. Turbo provides simple registration form. After account registration, it will be not possible to log in because account is inactive. Superuser needs to access Django admin and activate an account. This is a default behavior provided by Turbo, implementation of special way of account activation is currently out the scope of the project.
Expand Down
9 changes: 5 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM python:3.13-slim-bookworm

ENV PYTHONUNBUFFERED=1
ENV UV_PROJECT_ENVIRONMENT=/.venv

WORKDIR /app

COPY pyproject.toml poetry.lock ./
COPY pyproject.toml uv.lock ./

RUN pip install poetry && \
poetry config virtualenvs.create false && \
poetry install --no-root
RUN pip install uv && \
uv venv && \
uv sync

EXPOSE 8000
519 changes: 0 additions & 519 deletions backend/poetry.lock

This file was deleted.

30 changes: 12 additions & 18 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
[tool.poetry]
[project]
name = "backend"
requires-python = ">=3.13"
version = "0.1.0"
description = ""
authors = []
license = "MIT"

[tool.poetry.dependencies]
python = "^3.13"
django = "^5.1"
psycopg = { extras = ["binary"], version = "^3.2" }
djangorestframework = "^3.15"
djangorestframework-simplejwt = "^5.3"
drf-spectacular = "^0.28"
django-unfold = "^0.40"
dependencies = [
"django>=5.1",
"psycopg[binary]>=3.2",
"djangorestframework>=3.15",
"djangorestframework-simplejwt>=5.3",
"drf-spectacular>=0.28",
"django-unfold>=0.43.0",
]

[tool.ruff]
fix = true
line-length = 88

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
Expand All @@ -31,8 +30,3 @@ ignore = [
"B008", # do not perform function calls in argument defaults
"C901", # too complex
]
exclude = ["**/migrations"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion backend/src/backend/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
283 changes: 283 additions & 0 deletions backend/uv.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
timeout: 2s
retries: 10
api:
command: bash -c "poetry install && poetry run python src/manage.py migrate && poetry run python src/manage.py runserver 0.0.0.0:8000"
command: bash -c "uv sync && uv run -- python src/manage.py migrate && uv run -- python src/manage.py runserver 0.0.0.0:8000"
build:
context: backend
expose:
Expand Down

0 comments on commit 4248080

Please sign in to comment.