Skip to content

Commit 164c840

Browse files
Fixed #1574 -- Added support for Python 3.12 (#1640)
1 parent 064bd53 commit 164c840

File tree

8 files changed

+27
-11
lines changed

8 files changed

+27
-11
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212
runs-on: ubuntu-24.04
1313
strategy:
1414
fail-fast: false
15+
matrix:
16+
# tox-gh-actions will only run the tox environments which match the currently
17+
# running python-version. See [gh-actions] in tox.ini for the mapping.
18+
python-version: ["3.8", "3.12"]
1519

1620
services:
1721
postgres:
@@ -27,14 +31,14 @@ jobs:
2731
- 5432:5432
2832

2933
steps:
30-
- uses: actions/checkout@v2
34+
- uses: actions/checkout@v4
3135
- name: Set up Python
3236
uses: actions/setup-python@v5
3337
with:
34-
python-version: "3.8"
38+
python-version: "${{ matrix.python-version }}"
3539
- name: Install dependencies
3640
run: |
37-
python -m pip install --upgrade pip setuptools coveralls "tox<5"
41+
python -m pip install --upgrade pip setuptools coveralls "tox<5" "tox-gh-actions<4"
3842
- name: Set up databases
3943
run: |
4044
PGPASSWORD="postgres" createuser -U postgres -d djangoproject --superuser -h localhost

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ repos:
1919
rev: "v3.17.0"
2020
hooks:
2121
- id: pyupgrade
22+
# TODO: Update to --py312 when dropping support for
23+
# Python 3.8
2224
args: [--py38-plus]
2325
- repo: https://github.com/adamchainz/django-upgrade
2426
rev: "1.21.0"

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pull official base image
2-
FROM python:3.8-slim-bullseye
2+
FROM python:3.12-slim-bookworm
33

44
# set work directory
55
WORKDIR /usr/src/app
@@ -17,7 +17,7 @@ RUN apt-get update \
1717
make \
1818
netcat-openbsd \
1919
npm \
20-
postgresql-client-13 \
20+
postgresql-client-15 \
2121
rsync \
2222
zlib1g \
2323
&& rm -rf /var/lib/apt/lists/*

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To run locally, you can either:
1515
Install and run locally from a virtual environment
1616
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1717

18-
#. Create a `Python 3.8+ virtualenv and activate it <https://docs.python.org/3/library/venv.html>`_
18+
#. Create a `Python Python 3.8 or 3.12 virtualenv and activate it <https://docs.python.org/3/library/venv.html>`_
1919

2020
#. Install dependencies::
2121

requirements/common.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ pykismet3==0.1.1
1919
requests==2.32.3
2020
sorl-thumbnail==12.10.0
2121
Sphinx==4.5.0
22-
stripe==2.56.0
22+
stripe==3.1.0

tox.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
[tox]
2-
envlist =py38-{tests,flake8,black,isort}
2+
envlist =py{38,312}-{tests,flake8,black,isort}
33
skipsdist = true
44

5+
[gh-actions]
6+
python =
7+
3.8: py38
8+
3.12: py312
9+
510
[testenv]
611
allowlist_externals = make
712
passenv = DJANGO_SETTINGS_MODULE

tracdb/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@
5050

5151
from django.db import models
5252

53-
_epoc = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
53+
try:
54+
_epoc = datetime.datetime(1970, 1, 1, tzinfo=datetime.UTC)
55+
except AttributeError:
56+
# TODO: Remove when dropping support for Python 3.8
57+
_epoc = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
5458

5559

5660
class time_property:

tracdb/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from django import db
44
from django.shortcuts import render
55

6+
from .models import _epoc
7+
68

79
def bouncing_tickets(request):
810
c = db.connections["trac"].cursor()
@@ -27,8 +29,7 @@ def bouncing_tickets(request):
2729

2830

2931
def ts2dt(ts):
30-
epoc = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
31-
return epoc + datetime.timedelta(microseconds=ts)
32+
return _epoc + datetime.timedelta(microseconds=ts)
3233

3334

3435
def dictfetchall(cursor):

0 commit comments

Comments
 (0)