diff --git a/Dockerfile b/Dockerfile index 699e279344..63f767f995 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ openjdk-8-jdk-headless \ php7.4-cli \ postgresql-client \ - python2 \ python3-pip \ python3.8 \ python3.8-dev \ diff --git a/cms/conf.py b/cms/conf.py index 9ccc2b8e74..87ca680ec1 100644 --- a/cms/conf.py +++ b/cms/conf.py @@ -167,7 +167,7 @@ def __init__(self): # the prefix (or real_prefix to accommodate virtualenvs). bin_path = os.path.join(os.getcwd(), sys.argv[0]) bin_name = os.path.basename(bin_path) - bin_is_python = bin_name in ["ipython", "python", "python2", "python3"] + bin_is_python = bin_name in ["ipython", "python", "python3"] bin_in_installed_path = bin_path.startswith(sys.prefix) or ( hasattr(sys, 'real_prefix') and bin_path.startswith(sys.real_prefix)) diff --git a/cms/grading/languages/python2_cpython.py b/cms/grading/languages/python2_cpython.py deleted file mode 100644 index bc55df1f26..0000000000 --- a/cms/grading/languages/python2_cpython.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 - -# Contest Management System - http://cms-dev.github.io/ -# Copyright © 2016-2018 Stefano Maggiolo -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -"""Python programming language, version 2, definition.""" - -import os - -from cms.grading import CompiledLanguage - - -__all__ = ["Python2CPython"] - - -class Python2CPython(CompiledLanguage): - """This defines the Python programming language, version 2 (more - precisely, the subversion of Python 2 available on the system, - usually 2.7) using the default interpeter in the system. - - """ - - MAIN_FILENAME = "__main__.pyc" - - @property - def name(self): - """See Language.name.""" - return "Python 2 / CPython" - - @property - def source_extensions(self): - """See Language.source_extensions.""" - return [".py"] - - @property - def executable_extension(self): - """See Language.executable_extension.""" - return ".zip" - - def get_compilation_commands(self, - source_filenames, executable_filename, - for_evaluation=True): - """See Language.get_compilation_commands.""" - - commands = [] - files_to_package = [] - commands.append(["/usr/bin/python2", "-m", "compileall", "."]) - for idx, source_filename in enumerate(source_filenames): - basename = os.path.splitext(os.path.basename(source_filename))[0] - pyc_filename = "%s.pyc" % basename - # The file with the entry point must be in first position. - if idx == 0: - commands.append(["/bin/mv", pyc_filename, self.MAIN_FILENAME]) - files_to_package.append(self.MAIN_FILENAME) - else: - files_to_package.append(pyc_filename) - - commands.append(["/usr/bin/zip", executable_filename] - + files_to_package) - - return commands - - def get_evaluation_commands( - self, executable_filename, main=None, args=None): - """See Language.get_evaluation_commands.""" - args = args if args is not None else [] - return [["/usr/bin/python2", executable_filename] + args] diff --git a/cmsranking/Config.py b/cmsranking/Config.py index e7d624f328..da0511aa33 100644 --- a/cmsranking/Config.py +++ b/cmsranking/Config.py @@ -61,7 +61,7 @@ def __init__(self): # TODO: move to cmscommon as it is used both here and in cms/conf.py bin_path = os.path.join(os.getcwd(), sys.argv[0]) bin_name = os.path.basename(bin_path) - bin_is_python = bin_name in ["ipython", "python", "python2", "python3"] + bin_is_python = bin_name in ["ipython", "python", "python3"] bin_in_installed_path = bin_path.startswith(sys.prefix) or ( hasattr(sys, 'real_prefix') and bin_path.startswith(sys.real_prefix)) diff --git a/cmstestsuite/Tests.py b/cmstestsuite/Tests.py index 7cf8416ac9..2cf440d4af 100644 --- a/cmstestsuite/Tests.py +++ b/cmstestsuite/Tests.py @@ -48,20 +48,19 @@ LANG_JAVA = "Java / JDK" LANG_PASCAL = "Pascal / fpc" LANG_PHP = "PHP" -LANG_PYTHON = "Python 2 / CPython" LANG_PYTHON3 = "Python 3 / CPython" LANG_RUST = "Rust" LANG_C_SHARP = "C# / Mono" ALL_LANGUAGES = ( LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_C, LANG_HS, LANG_JAVA, LANG_PASCAL, - LANG_PHP, LANG_PYTHON, LANG_PYTHON3, LANG_RUST, LANG_C_SHARP + LANG_PHP, LANG_PYTHON3, LANG_RUST, LANG_C_SHARP ) NON_INTERPRETED_LANGUAGES = ( LANG_C, LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_PASCAL ) COMPILED_LANGUAGES = ( LANG_C, LANG_CPP, LANG_CPP14, LANG_CPP17, LANG_PASCAL, LANG_JAVA, - LANG_PYTHON, LANG_PYTHON3, LANG_HS, LANG_RUST, LANG_C_SHARP + LANG_PYTHON3, LANG_HS, LANG_RUST, LANG_C_SHARP ) ALL_TESTS = [ diff --git a/cmstestsuite/tasks/batch_fileio_managed/code/checker b/cmstestsuite/tasks/batch_fileio_managed/code/checker index a508bed8be..d8fcdb6c56 100644 --- a/cmstestsuite/tasks/batch_fileio_managed/code/checker +++ b/cmstestsuite/tasks/batch_fileio_managed/code/checker @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -17,11 +16,11 @@ try: f = io.open(output_file, 'rb') line = f.readline().strip() more = f.readline() - if line == '%s %d' % (solution_word, number) and more == '': + if line == b'%s %d' % (solution_word, number) and more == b'': print("1.0") print("Correcto", file=sys.stderr) else: - assert more == '' + assert more == b'' print("0.0") print("Plain wrong", file=sys.stderr) except: diff --git a/cmstestsuite/tasks/communication_fifoio_stubbed/code/manager b/cmstestsuite/tasks/communication_fifoio_stubbed/code/manager index 935e8d85be..18b19bdcf8 100644 --- a/cmstestsuite/tasks/communication_fifoio_stubbed/code/manager +++ b/cmstestsuite/tasks/communication_fifoio_stubbed/code/manager @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -17,28 +16,28 @@ correct = True # Speak the to program a few times, check what it does, and output the last # line. -for i in range(10,20) + [0]: +for i in list(range(10, 20)) + [0]: x = i + input_value # Write a question to the candidate executable. - fifo_to_user.write("%d\n" % x) + fifo_to_user.write(b"%d\n" % x) # Read their response. l = fifo_from_user.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % x: + if l.strip() != b'correct %d' % x: correct = False break correct = correct and (int(l.split()[1]) == x) else: # Tell stub to exit. - fifo_to_user.write("0\n") + fifo_to_user.write(b"0\n") # This file exists just for convenience. -io.open("output.txt", "wb").write(l + "\n") +io.open("output.txt", "wb").write(l + b"\n") # This is the final score. if correct: diff --git a/cmstestsuite/tasks/communication_many_fifoio_stubbed/code/manager b/cmstestsuite/tasks/communication_many_fifoio_stubbed/code/manager index 6de8de3262..469d70edfe 100644 --- a/cmstestsuite/tasks/communication_many_fifoio_stubbed/code/manager +++ b/cmstestsuite/tasks/communication_many_fifoio_stubbed/code/manager @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -20,44 +19,44 @@ correct = True # Speak the to program a few times, check what it does, and output the last # line. -for i in range(10, 20) + [0]: +for i in list(range(10, 20)) + [0]: x = i + input_value # Write a question to the candidate executable. - fifo_to_user1.write("%d\n" % x) + fifo_to_user1.write(b"%d\n" % x) # Read their response. l = fifo_from_user1.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % x: + if l.strip() != b'correct %d' % x: correct = False break correct = correct and (int(l.split()[1]) == x) # Write a question to the candidate executable. - fifo_to_user2.write("%d\n" % x) + fifo_to_user2.write(b"%d\n" % x) # Read their response. l = fifo_from_user2.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % (-x): + if l.strip() != b'correct %d' % (-x): correct = False break correct = correct and (int(l.split()[1]) == -x) else: # Tell stub to exit. - fifo_to_user1.write("0\n") - fifo_to_user2.write("0\n") + fifo_to_user1.write(b"0\n") + fifo_to_user2.write(b"0\n") # This file exists just for convenience. -io.open("output.txt", "wb").write(l + "\n") +io.open("output.txt", "wb").write(l + b"\n") # This is the final score. if correct: diff --git a/cmstestsuite/tasks/communication_many_stdio_stubbed/code/manager b/cmstestsuite/tasks/communication_many_stdio_stubbed/code/manager index b2f9f66e43..c2652e3577 100644 --- a/cmstestsuite/tasks/communication_many_stdio_stubbed/code/manager +++ b/cmstestsuite/tasks/communication_many_stdio_stubbed/code/manager @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -22,44 +21,44 @@ correct = True # Speak the to program a few times, check what it does, and output the last # line. -for i in range(10, 20) + [0]: +for i in list(range(10, 20)) + [0]: x = i + input_value # Write a question to the candidate executable. - fifo_to_user1.write("%d\n" % x) + fifo_to_user1.write(b"%d\n" % x) # Read their response. l = fifo_from_user1.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % x: + if l.strip() != b'correct %d' % x: correct = False break correct = correct and (int(l.split()[1]) == x) # Write a question to the candidate executable. - fifo_to_user2.write("%d\n" % x) + fifo_to_user2.write(b"%d\n" % x) # Read their response. l = fifo_from_user2.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % (-x): + if l.strip() != b'correct %d' % (-x): correct = False break correct = correct and (int(l.split()[1]) == -x) else: # Tell stub to exit. - fifo_to_user1.write("0\n") - fifo_to_user2.write("0\n") + fifo_to_user1.write(b"0\n") + fifo_to_user2.write(b"0\n") # This file exists just for convenience. -io.open("output.txt", "wb").write(l + "\n") +io.open("output.txt", "wb").write(l + b"\n") # This is the final score. if correct: diff --git a/cmstestsuite/tasks/communication_stdio/code/manager b/cmstestsuite/tasks/communication_stdio/code/manager index 27e68c024d..cca1157f28 100644 --- a/cmstestsuite/tasks/communication_stdio/code/manager +++ b/cmstestsuite/tasks/communication_stdio/code/manager @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -19,28 +18,28 @@ correct = True # Speak the to program a few times, check what it does, and output the last # line. -for i in range(10,20) + [0]: +for i in list(range(10, 20)) + [0]: x = i + input_value # Write a question to the candidate executable. - fifo_to_user.write("%d\n" % x) + fifo_to_user.write(b"%d\n" % x) # Read their response. l = fifo_from_user.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % x: + if l.strip() != b'correct %d' % x: correct = False break correct = correct and (int(l.split()[1]) == x) else: # Tell stub to exit. - fifo_to_user.write("0\n") + fifo_to_user.write(b"0\n") # This file exists just for convenience. -io.open("output.txt", "wb").write(l + "\n") +io.open("output.txt", "wb").write(l + b"\n") # This is the final score. if correct: diff --git a/cmstestsuite/tasks/communication_stdio_stubbed/code/manager b/cmstestsuite/tasks/communication_stdio_stubbed/code/manager index 27e68c024d..cca1157f28 100644 --- a/cmstestsuite/tasks/communication_stdio_stubbed/code/manager +++ b/cmstestsuite/tasks/communication_stdio_stubbed/code/manager @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys @@ -19,28 +18,28 @@ correct = True # Speak the to program a few times, check what it does, and output the last # line. -for i in range(10,20) + [0]: +for i in list(range(10, 20)) + [0]: x = i + input_value # Write a question to the candidate executable. - fifo_to_user.write("%d\n" % x) + fifo_to_user.write(b"%d\n" % x) # Read their response. l = fifo_from_user.readline() # EOF? - if l == '': + if l == b'': correct = False break # These are the only things we expect from our stub. - if l.strip() != 'correct %d' % x: + if l.strip() != b'correct %d' % x: correct = False break correct = correct and (int(l.split()[1]) == x) else: # Tell stub to exit. - fifo_to_user.write("0\n") + fifo_to_user.write(b"0\n") # This file exists just for convenience. -io.open("output.txt", "wb").write(l + "\n") +io.open("output.txt", "wb").write(l + b"\n") # This is the final score. if correct: diff --git a/cmstestsuite/tasks/outputonly_comparator/code/checker b/cmstestsuite/tasks/outputonly_comparator/code/checker index 4380aa75ae..c1e89a5eae 100644 --- a/cmstestsuite/tasks/outputonly_comparator/code/checker +++ b/cmstestsuite/tasks/outputonly_comparator/code/checker @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys diff --git a/cmstestsuite/tasks/twosteps_comparator/code/checker b/cmstestsuite/tasks/twosteps_comparator/code/checker index 4380aa75ae..c1e89a5eae 100644 --- a/cmstestsuite/tasks/twosteps_comparator/code/checker +++ b/cmstestsuite/tasks/twosteps_comparator/code/checker @@ -1,6 +1,5 @@ -#!/usr/bin/python2 -sS +#!/usr/bin/python3 -sS -from __future__ import print_function import io import sys diff --git a/codecov/.gitkeep b/codecov/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/Configuring a contest.rst b/docs/Configuring a contest.rst index 820b922afd..ca8b1509ad 100644 --- a/docs/Configuring a contest.rst +++ b/docs/Configuring a contest.rst @@ -225,7 +225,7 @@ Language details * Pascal support is provided by ``fpc``, and submissions are optimized with ``-O2``. -* Python submissions are executed using the system Python interpreter (you need to have ``/usr/bin/python2`` or ``/usr/bin/python3``, respectively). +* Python submissions are executed using the system Python interpreter (you need to have ``/usr/bin/python3``). * PHP submissions are interpreted by ``/usr/bin/php``. diff --git a/docs/Installation.rst b/docs/Installation.rst index 9ad179c2db..7693d5e3c5 100644 --- a/docs/Installation.rst +++ b/docs/Installation.rst @@ -34,7 +34,7 @@ Then you require the compilation and execution environments for the languages yo * `Free Pascal `_ (for Pascal, with executable ``fpc``); -* `Python `_ >= 2.7 (for Python, with executable ``python2`` or ``python3``; in addition you will need ``zip``); +* `Python `_ >= 3.8 (for Python, with executable ``python3``; in addition you will need ``zip``); * `PHP `_ >= 5 (for PHP, with executable ``php``); @@ -63,7 +63,7 @@ On Ubuntu 20.04, one will need to run the following script to satisfy all depend libffi-dev python3-pip # Optional - sudo apt-get install nginx-full python2.7 php7.4-cli php7.4-fpm \ + sudo apt-get install nginx-full python3.8 php7.4-cli php7.4-fpm \ phppgadmin texlive-latex-base a2ps haskell-platform rustc mono-mcs The above commands provide a very essential Pascal environment. Consider installing the following packages for additional units: `fp-units-base`, `fp-units-fcl`, `fp-units-misc`, `fp-units-math` and `fp-units-rtl`. @@ -86,7 +86,7 @@ On Arch Linux, unofficial AUR packages can be found: `cms