Ninjaclasher/dmoj-docker

`migrate` script fails because Python 3.7 doesn't support type hinting

powergee opened this issue · 0 comments

Hello,

First of all, thank you for starting this project. I'm using these docker configuration for my project, and it is much more convenient to deply online judge frontend.

I found an error while generating the schema for the DB by /dmoj/scripts/migrate.

Current Problem

  • migrate fails with ImportError
    While executing migrate, it fails with ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py). I googled it, and found that Python 3.7, which is installed by apt-get install python3, doesn't support type hinting by default.

    Error messages
      Traceback (most recent call last):
        File "manage.py", line 17, in <module>
          execute_from_command_line(sys.argv)
        File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
          utility.execute()
        File "/usr/local/lib/python3.7/dist-packages/django/core/management/__init__.py", line 357, in execute
          django.setup()
        File "/usr/local/lib/python3.7/dist-packages/django/__init__.py", line 24, in setup
          apps.populate(settings.INSTALLED_APPS)
        File "/usr/local/lib/python3.7/dist-packages/django/apps/registry.py", line 114, in populate
          app_config.import_models()
        File "/usr/local/lib/python3.7/dist-packages/django/apps/config.py", line 211, in import_models
          self.models_module = import_module(models_module_name)
        File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
        File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
        File "<frozen importlib._bootstrap>", line 983, in _find_and_load
        File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 728, in exec_module
        File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
        File "/site/judge/models/__init__.py", line 4, in <module>
          from judge.models.comment import Comment, CommentLock, CommentVote
        File "/site/judge/models/comment.py", line 16, in <module>
          from judge.models.contest import Contest
        File "/site/judge/models/contest.py", line 14, in <module>
          from judge.models.problem import Problem
        File "/site/judge/models/problem.py", line 18, in <module>
          from judge.models.profile import Organization, Profile
        File "/site/judge/models/profile.py", line 9, in <module>
          import webauthn
        File "/usr/local/lib/python3.7/dist-packages/webauthn/__init__.py", line 1, in <module>
          from .registration.generate_registration_options import generate_registration_options
        File "/usr/local/lib/python3.7/dist-packages/webauthn/registration/generate_registration_options.py", line 3, in <module>
          from webauthn.helpers import generate_challenge
        File "/usr/local/lib/python3.7/dist-packages/webauthn/helpers/__init__.py", line 11, in <module>
          from .options_to_json import options_to_json  # noqa: F401
        File "/usr/local/lib/python3.7/dist-packages/webauthn/helpers/options_to_json.py", line 3, in <module>
          from .structs import (
        File "/usr/local/lib/python3.7/dist-packages/webauthn/helpers/structs.py", line 2, in <module>
          from typing import List, Literal, Optional
      ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
    

Suggestion

How about changing the image of base from debian:buster-slim to python:3.8-slim-buster?