Skip to content

Commit

Permalink
⬆️ Upgrades to Django 5.0 and Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftriplett committed Mar 2, 2024
1 parent 1bee6f1 commit 748ac38
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 80 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
name: Tests with Python

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 1
path: ./src/github.com/${{ github.repository }}-git

- name: Set up Python 3.10
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
cache: 'pip'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_language_version:
python: python3.10
python: python3.12

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
19 changes: 12 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,37 @@
# Base/builder layer
# ------------------------------------------------------------

FROM python:3.10-slim-buster AS builder
FROM python:3.12-slim-bookworm AS builder

ENV PATH /venv/bin:/bin:/usr/bin:/usr/local/bin
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONPATH /srv
ENV PYTHONUNBUFFERED 1

COPY requirements/requirements.txt /tmp/requirements.txt

# add ",sharing=locked" if release should block until builder is complete
RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=pip \
pip install --upgrade pip pip-tools && \
pip install -r /tmp/requirements.txt
python -m pip install --upgrade pip uv

RUN python -m uv venv /venv

RUN --mount=type=cache,target=/root/.cache,sharing=locked,id=pip \
. /venv/bin/activate && \
uv pip install -r /tmp/requirements.txt

# ------------------------------------------------------------
# Dev/testing layer
# ------------------------------------------------------------

FROM builder AS release

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY . /src/

WORKDIR /src/

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["python", "-m", "manage", "runserver", "0.0.0.0:8000"]

# ------------------------------------------------------------
# TODO: Add Production notes
Expand Down
35 changes: 31 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
set dotenv-load := false

compose := "docker compose run --rm --no-deps utility"
manage := compose + " python -m manage"

@_default:
just --list

@build *ARGS:
docker compose build {{ ARGS }}

# opens a console
@console:
{{ compose }} /bin/bash

@fmt:
just --fmt --unstable

@lint:
python -m pre_commit run --all-files

@lock *ARGS:
docker compose run \
--no-deps \
--rm \
web \
bash -c "uv pip compile {{ ARGS }} ./requirements/requirements.in \
--resolver=backtracking \
--output-file ./requirements/requirements.txt"

@logs +ARGS="":
docker compose logs {{ ARGS }}

@pip-compile *ARGS:
python -m pip install --upgrade pip pip-tools
python -m pip install --upgrade -r requirements/requirements.in
pip-compile {{ ARGS }} \
python -m pip install --upgrade pip uv
python -m uv pip install --upgrade -r requirements/requirements.in
python -m pip compile {{ ARGS }} \
--resolver=backtracking \
requirements/requirements.in

@pip-compile-upgrade:
just pip-compile --upgrade

@pre-commit:
pre-commit run --config=.pre-commit-config.yaml --all-files
python -m pre_commit run --config=.pre-commit-config.yaml --all-files
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.black]
target-version = ["py310"]
target-version = ["py312"]

[tool.coverage.run]
omit = [
Expand Down Expand Up @@ -54,5 +54,5 @@ line-length = 120
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"
# Assume Python 3.12.
target-version = "py312"
2 changes: 1 addition & 1 deletion requirements/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
django-click
Django<5.0
Django<5.1
environs[django]
psycopg2-binary
whitenoise
Expand Down
94 changes: 34 additions & 60 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,91 +1,65 @@
#
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --resolver=backtracking requirements/requirements.in
#
asgiref==3.6.0
# This file was autogenerated by uv via the following command:
# uv pip compile ./requirements/requirements.in --resolver=backtracking --output-file ./requirements/requirements.txt
asgiref==3.7.2
# via django
attrs==22.2.0
# via pytest
cfgv==3.3.1
cfgv==3.4.0
# via pre-commit
click==8.1.3
click==8.1.7
# via django-click
coverage[toml]==7.2.3
# via
# coverage
# pytest-cov
distlib==0.3.6
coverage==7.4.3
# via pytest-cov
distlib==0.3.8
# via virtualenv
dj-database-url==1.3.0
dj-database-url==2.1.0
# via environs
dj-email-url==1.0.6
# via environs
django==4.2.7
django==5.0.2
# via
# -r requirements.in
# dj-database-url
# model-bakery
django-cache-url==3.4.4
django-cache-url==3.4.5
# via environs
django-click==2.3.0
# via -r requirements.in
django-test-plus==2.2.1
# via -r requirements.in
environs[django]==9.5.0
# via -r requirements.in
exceptiongroup==1.1.3
# via pytest
filelock==3.11.0
django-test-plus==2.2.3
environs==10.3.0
filelock==3.13.1
# via virtualenv
identify==2.5.22
identify==2.5.35
# via pre-commit
iniconfig==2.0.0
# via pytest
marshmallow==3.19.0
marshmallow==3.21.0
# via environs
model-bakery==1.11.0
# via -r requirements.in
nodeenv==1.7.0
model-bakery==1.17.0
nodeenv==1.8.0
# via pre-commit
packaging==23.0
packaging==23.2
# via
# marshmallow
# pytest
platformdirs==3.2.0
platformdirs==4.2.0
# via virtualenv
pluggy==1.0.0
pluggy==1.4.0
# via pytest
pre-commit==3.2.2
# via -r requirements.in
psycopg2-binary==2.9.6
# via -r requirements.in
pytest==7.2.2
pre-commit==3.6.2
psycopg2-binary==2.9.9
pytest==8.0.2
# via
# -r requirements.in
# pytest-cov
# pytest-django
pytest-cov==4.0.0
# via -r requirements.in
pytest-django==4.5.2
# via -r requirements.in
python-dotenv==1.0.0
pytest-cov==4.1.0
pytest-django==4.8.0
python-dotenv==1.0.1
# via environs
pyyaml==6.0
pyyaml==6.0.1
# via pre-commit
sqlparse==0.4.3
setuptools==69.1.1
# via nodeenv
sqlparse==0.4.4
# via django
tomli==2.0.1
# via
# coverage
# pytest
typing-extensions==4.5.0
typing-extensions==4.10.0
# via dj-database-url
virtualenv==20.21.0
virtualenv==20.25.1
# via pre-commit
whitenoise==6.4.0
# via -r requirements.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
whitenoise==6.6.0

0 comments on commit 748ac38

Please sign in to comment.