Skip to content

Commit

Permalink
Compatibility with Python 3.12.
Browse files Browse the repository at this point in the history
Inspired by ioi-2024@0f044fd
  • Loading branch information
veluca93 committed Nov 16, 2024
1 parent 98ad9a2 commit b99e2f0
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 57 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# syntax=docker/dockerfile:1
FROM ubuntu:20.04
FROM ubuntu:24.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
cgroup-lite \
cppreference-doc-en-html \
fp-compiler \
git \
haskell-platform \
ghc \
libcap-dev \
libcups2-dev \
libffi-dev \
libpq-dev \
libyaml-dev \
mono-mcs \
openjdk-8-jdk-headless \
php7.4-cli \
php-cli \
postgresql-client \
python2 \
python3-pip \
python3.8 \
python3.8-dev \
python3.12 \
python3.12-dev \
rustc \
shared-mime-info \
sudo \
wait-for-it \
zip
Expand All @@ -39,8 +39,8 @@ COPY --chown=cmsuser:cmsuser requirements.txt dev-requirements.txt /home/cmsuser

WORKDIR /home/cmsuser/cms

RUN sudo pip3 install -r requirements.txt
RUN sudo pip3 install -r dev-requirements.txt
RUN sudo pip3 install --break-system-packages -r requirements.txt
RUN sudo pip3 install --break-system-packages -r dev-requirements.txt

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

Expand Down
7 changes: 7 additions & 0 deletions cms/io/web_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@

import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.wsgi as tornado_wsgi
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
from datetime import datetime, timedelta
from functools import wraps

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/contestannouncement.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"""

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/contestquestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/contestuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@

import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
import re
import zipfile

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/admin/handlers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
import logging
import traceback

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
import logging
import traceback

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@

import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
import ipaddress
import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
import logging
import re

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@

import logging

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/tasksubmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
import logging
import re

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/contest/handlers/taskusertest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
import logging
import re

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
import tornado4.web as tornado_web
except ImportError:
Expand Down
7 changes: 7 additions & 0 deletions cms/server/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
from functools import wraps
from urllib.parse import quote, urlencode

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
from tornado4.web import RequestHandler
except ImportError:
Expand Down
10 changes: 5 additions & 5 deletions cmscontrib/loaders/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import imp
import logging
import os
import subprocess
Expand Down Expand Up @@ -145,10 +144,11 @@ def get_task(self, get_statement=True):
task_cms_conf = None
if os.path.exists(task_cms_conf_path):
logger.info("Found additional CMS options for task %s.", name)
with open(task_cms_conf_path, 'rb') as f:
task_cms_conf = imp.load_module('cms_conf', f,
task_cms_conf_path,
('.py', 'r', imp.PY_SOURCE))
import importlib.util
spec = importlib.util.spec_from_file_location(
'cms_conf', task_cms_conf_path)
task_cms_conf = importlib.util.module_from_spec(spec)
spec.loader.exec_module(task_cms_conf)
if task_cms_conf is not None and hasattr(task_cms_conf, "general"):
args.update(task_cms_conf.general)

Expand Down
7 changes: 7 additions & 0 deletions cmstestsuite/unit_tests/grading/ParameterTypesTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

import unittest

import collections
try:
collections.MutableMapping
except:
# Monkey-patch: Tornado 4.5.3 does not work on Python 3.11 by default
collections.MutableMapping = collections.abc.MutableMapping

try:
from tornado4.web import MissingArgumentError
except ImportError:
Expand Down
Loading

0 comments on commit b99e2f0

Please sign in to comment.