Skip to content

Commit 2125d5e

Browse files
authored
Compatibility with Python 3.12. (#1271)
Inspired by ioi-2024@0f044fd Also update CI and Dockerfile to Ubuntu 24.04.
1 parent d39de6b commit 2125d5e

File tree

22 files changed

+179
-69
lines changed

22 files changed

+179
-69
lines changed

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
# syntax=docker/dockerfile:1
2-
FROM ubuntu:20.04
2+
FROM ubuntu:24.04
33

44
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
55
build-essential \
66
cgroup-lite \
77
cppreference-doc-en-html \
88
fp-compiler \
99
git \
10-
haskell-platform \
10+
ghc \
1111
libcap-dev \
1212
libcups2-dev \
1313
libffi-dev \
1414
libpq-dev \
1515
libyaml-dev \
1616
mono-mcs \
1717
openjdk-8-jdk-headless \
18-
php7.4-cli \
18+
php-cli \
1919
postgresql-client \
2020
python3-pip \
21-
python3.8 \
22-
python3.8-dev \
21+
python3.12 \
22+
python3.12-dev \
2323
rustc \
24+
shared-mime-info \
2425
sudo \
2526
wait-for-it \
2627
zip
@@ -38,8 +39,8 @@ COPY --chown=cmsuser:cmsuser requirements.txt dev-requirements.txt /home/cmsuser
3839

3940
WORKDIR /home/cmsuser/cms
4041

41-
RUN sudo pip3 install -r requirements.txt
42-
RUN sudo pip3 install -r dev-requirements.txt
42+
RUN sudo pip3 install --break-system-packages -r requirements.txt
43+
RUN sudo pip3 install --break-system-packages -r dev-requirements.txt
4344

4445
COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms
4546

cms/io/web_service.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121

2222
import logging
2323

24+
import collections
25+
try:
26+
collections.MutableMapping
27+
except:
28+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
29+
collections.MutableMapping = collections.abc.MutableMapping
30+
2431
try:
2532
import tornado4.wsgi as tornado_wsgi
2633
except ImportError:

cms/server/admin/handlers/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
from datetime import datetime, timedelta
3535
from functools import wraps
3636

37+
import collections
38+
try:
39+
collections.MutableMapping
40+
except:
41+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
42+
collections.MutableMapping = collections.abc.MutableMapping
43+
3744
try:
3845
import tornado4.web as tornado_web
3946
except ImportError:

cms/server/admin/handlers/contestannouncement.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
2727
"""
2828

29+
import collections
30+
try:
31+
collections.MutableMapping
32+
except:
33+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
34+
collections.MutableMapping = collections.abc.MutableMapping
35+
2936
try:
3037
import tornado4.web as tornado_web
3138
except ImportError:

cms/server/admin/handlers/contestquestion.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727

2828
import logging
2929

30+
import collections
31+
try:
32+
collections.MutableMapping
33+
except:
34+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
35+
collections.MutableMapping = collections.abc.MutableMapping
36+
3037
try:
3138
import tornado4.web as tornado_web
3239
except ImportError:

cms/server/admin/handlers/contestuser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131

3232
import logging
3333

34+
import collections
35+
try:
36+
collections.MutableMapping
37+
except:
38+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
39+
collections.MutableMapping = collections.abc.MutableMapping
40+
3441
try:
3542
import tornado4.web as tornado_web
3643
except ImportError:

cms/server/admin/handlers/dataset.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
import re
3333
import zipfile
3434

35+
import collections
36+
try:
37+
collections.MutableMapping
38+
except:
39+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
40+
collections.MutableMapping = collections.abc.MutableMapping
41+
3542
try:
3643
import tornado4.web as tornado_web
3744
except ImportError:

cms/server/admin/handlers/task.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
import logging
3030
import traceback
3131

32+
import collections
33+
try:
34+
collections.MutableMapping
35+
except:
36+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
37+
collections.MutableMapping = collections.abc.MutableMapping
38+
3239
try:
3340
import tornado4.web as tornado_web
3441
except ImportError:

cms/server/contest/handlers/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
import logging
3333
import traceback
3434

35+
import collections
36+
try:
37+
collections.MutableMapping
38+
except:
39+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
40+
collections.MutableMapping = collections.abc.MutableMapping
41+
3542
try:
3643
import tornado4.web as tornado_web
3744
except ImportError:

cms/server/contest/handlers/communication.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929

3030
import logging
3131

32+
import collections
33+
try:
34+
collections.MutableMapping
35+
except:
36+
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
37+
collections.MutableMapping = collections.abc.MutableMapping
38+
3239
try:
3340
import tornado4.web as tornado_web
3441
except ImportError:

0 commit comments

Comments
 (0)