From 544638bf423a0ff526bef2cac055f293760708a4 Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 15 Nov 2022 23:50:08 +0100 Subject: [PATCH] Add support for Python3.11 --- .github/workflows/github_action_test_suite.yml | 2 +- docs/source/Setup/Installation-Git.md | 6 +++--- evennia/VERSION_REQS.txt | 4 ++-- evennia/commands/default/building.py | 2 +- .../base_systems/building_menu/building_menu.py | 16 +++++++++------- .../random_string_generator.py | 2 +- evennia/server/evennia_launcher.py | 12 ++++++------ evennia/utils/evmenu.py | 10 +++++----- requirements_extra.txt | 4 ++-- 9 files changed, 30 insertions(+), 28 deletions(-) diff --git a/.github/workflows/github_action_test_suite.yml b/.github/workflows/github_action_test_suite.yml index 43bd78036c..63ad1bcb4b 100644 --- a/.github/workflows/github_action_test_suite.yml +++ b/.github/workflows/github_action_test_suite.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.9', '3.10'] + python-version: ['3.9', '3.10', '3.11'] TESTING_DB: ['sqlite3', 'postgresql', 'mysql'] steps: diff --git a/docs/source/Setup/Installation-Git.md b/docs/source/Setup/Installation-Git.md index 00c3fc89de..383c03abc8 100644 --- a/docs/source/Setup/Installation-Git.md +++ b/docs/source/Setup/Installation-Git.md @@ -19,11 +19,11 @@ the 0.9.5 version. To install 1.0-dev, you need to add a step `git checkout deve 3 and 4 below. ``` -1. Install Python, GIT and python-virtualenv. Start a Console/Terminal. +1. Install Python and GIT. Start a Console/Terminal. 2. `cd` to some place you want to do your development (like a folder `/home/anna/muddev/` on Linux or a folder in your personal user directory on Windows). 3. `git clone https://github.com/evennia/evennia.git` (a new folder `evennia` is created) -4. `python3.10 -m venv evenv` (a new folder `evenv` is created) +4. `python3.11 -m venv evenv` (a new folder `evenv` is created) 5. `source evenv/bin/activate` (Linux, Mac), `evenv\Scripts\activate` (Windows) 6. `pip install -e evennia` 7. `evennia --init mygame` @@ -42,7 +42,7 @@ install the requirements: ``` sudo apt-get update -sudo apt-get install python3.10 python3.10-venv python3.10-dev gcc +sudo apt-get install python3.11 python3.11-venv python3.11-dev gcc ``` You should make sure to *not* be `root` after this step, running as `root` is a security risk. Now create a folder where you want to do all your Evennia diff --git a/evennia/VERSION_REQS.txt b/evennia/VERSION_REQS.txt index 772831adff..5a73a1ed31 100644 --- a/evennia/VERSION_REQS.txt +++ b/evennia/VERSION_REQS.txt @@ -4,7 +4,7 @@ # `value = number` and only specific names supported by the handler. PYTHON_MIN = 3.9 -PYTHON_MAX_TESTED = 3.11 +PYTHON_MAX_TESTED = 3.11.0.0 TWISTED_MIN = 20.3.0 DJANGO_MIN = 4.0.2 -DJANGO_LT = 4.1 +DJANGO_MAX_TESTED = 4.1 diff --git a/evennia/commands/default/building.py b/evennia/commands/default/building.py index c43dbfd8c5..4fb540c83c 100644 --- a/evennia/commands/default/building.py +++ b/evennia/commands/default/building.py @@ -3460,7 +3460,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS): if not scripts: scripts = ScriptDB.objects.filter(db_obj=obj).exclude( - db_typeclass_paths__in=self.hide_script_paths + db_typeclass_path__in=self.hide_script_paths ) if scripts.count() > 1: diff --git a/evennia/contrib/base_systems/building_menu/building_menu.py b/evennia/contrib/base_systems/building_menu/building_menu.py index c559d8bdba..b1bfdfff0b 100644 --- a/evennia/contrib/base_systems/building_menu/building_menu.py +++ b/evennia/contrib/base_systems/building_menu/building_menu.py @@ -122,7 +122,7 @@ heavily-documented code below. """ -from inspect import getargspec +from inspect import getfullargspec from textwrap import dedent from django.conf import settings @@ -209,9 +209,9 @@ def _call_or_get(value, menu=None, choice=None, string=None, obj=None, caller=No if callable(value): # Check the function arguments kwargs = {} - spec = getargspec(value) + spec = getfullargspec(value) args = spec.args - if spec.keywords: + if spec.varkw: kwargs.update(dict(menu=menu, choice=choice, string=string, obj=obj, caller=caller)) else: if "menu" in args: @@ -292,8 +292,9 @@ def menu_quit(caller, menu): """ if caller is None or menu is None: log_err( - "The function `menu_quit` was called with missing " - "arguments: caller={}, menu={}".format(caller, menu) + "The function `menu_quit` was called with missing arguments: caller={}, menu={}".format( + caller, menu + ) ) if caller.cmdset.has(BuildingMenuCmdSet): @@ -835,8 +836,9 @@ class BuildingMenu: if key and key in self.cmds: raise ValueError( - "A conflict exists between {} and {}, both use " - "key or alias {}".format(self.cmds[key], title, repr(key)) + "A conflict exists between {} and {}, both use key or alias {}".format( + self.cmds[key], title, repr(key) + ) ) if attr: diff --git a/evennia/contrib/utils/random_string_generator/random_string_generator.py b/evennia/contrib/utils/random_string_generator/random_string_generator.py index 83fb864935..526c522fdd 100644 --- a/evennia/contrib/utils/random_string_generator/random_string_generator.py +++ b/evennia/contrib/utils/random_string_generator/random_string_generator.py @@ -188,7 +188,7 @@ class RandomStringGenerator: """ self.total = 1 self.elements = [] - tree = re.sre_parse.parse(regex).data + tree = re._parser.parse(regex).data # note - sre_parse removed in py3.11 # `tree` contains a list of elements in the regular expression for element in tree: # `element` is also a list, the first element is a string diff --git a/evennia/server/evennia_launcher.py b/evennia/server/evennia_launcher.py index 0641f567ad..1c7dd1f401 100644 --- a/evennia/server/evennia_launcher.py +++ b/evennia/server/evennia_launcher.py @@ -95,7 +95,7 @@ PYTHON_MIN = None PYTHON_MAX_TESTED = None TWISTED_MIN = None DJANGO_MIN = None -DJANGO_LT = None +DJANGO_MAX_TESTED = None with open(os.path.join(EVENNIA_LIB, "VERSION_REQS.txt")) as fil: for line in fil.readlines(): @@ -110,8 +110,8 @@ with open(os.path.join(EVENNIA_LIB, "VERSION_REQS.txt")) as fil: TWISTED_MIN = value[0] if value else "0" elif key == "DJANGO_MIN": DJANGO_MIN = value[0] if value else "0" - elif key == "DJANGO_LT": - DJANGO_LT = value[0] if value else "100" + elif key == "DJANGO_MAX_TESTED": + DJANGO_MAX_TESTED = value[0] if value else "100" try: sys.path[1] = EVENNIA_ROOT @@ -1307,12 +1307,12 @@ def check_main_evennia_dependencies(): if LooseVersion(dversion) < LooseVersion(DJANGO_MIN): print( ERROR_DJANGO_MIN.format( - dversion=dversion_main, django_min=DJANGO_MIN, django_lt=DJANGO_LT + dversion=dversion_main, django_min=DJANGO_MIN, django_lt=DJANGO_MAX_TESTED ) ) error = True - elif LooseVersion(DJANGO_LT) <= LooseVersion(dversion_main): - print(NOTE_DJANGO_NEW.format(dversion=dversion_main, django_rec=DJANGO_LT)) + elif LooseVersion(DJANGO_MAX_TESTED) <= LooseVersion(dversion_main): + print(NOTE_DJANGO_NEW.format(dversion=dversion_main, django_rec=DJANGO_MAX_TESTED)) except ImportError: print(ERROR_NODJANGO) error = True diff --git a/evennia/utils/evmenu.py b/evennia/utils/evmenu.py index 5223ac1199..2ee0163e06 100644 --- a/evennia/utils/evmenu.py +++ b/evennia/utils/evmenu.py @@ -266,7 +266,7 @@ import inspect import re from ast import literal_eval from fnmatch import fnmatch -from inspect import getargspec, isfunction +from inspect import getfullargspec, isfunction from math import ceil from django.conf import settings @@ -741,10 +741,10 @@ class EvMenu: """ try: try: - nargs = len(getargspec(callback).args) + nargs = len(getfullargspec(callback).args) except TypeError: raise EvMenuError("Callable {} doesn't accept any arguments!".format(callback)) - supports_kwargs = bool(getargspec(callback).keywords) + supports_kwargs = bool(getfullargspec(callback).varkw) if nargs <= 0: raise EvMenuError("Callable {} doesn't accept any arguments!".format(callback)) @@ -1285,7 +1285,7 @@ def list_node(option_generator, select=None, pagesize=10): else: if callable(select): try: - if bool(getargspec(select).keywords): + if bool(getfullargspec(select).varkw): return select( caller, selection, available_choices=available_choices, **kwargs ) @@ -1368,7 +1368,7 @@ def list_node(option_generator, select=None, pagesize=10): # add data from the decorated node decorated_options = [] - supports_kwargs = bool(getargspec(func).keywords) + supports_kwargs = bool(getfullargspec(func).varkw) try: if supports_kwargs: text, decorated_options = func(caller, raw_string, **kwargs) diff --git a/requirements_extra.txt b/requirements_extra.txt index 1067281805..8ebe9723f5 100644 --- a/requirements_extra.txt +++ b/requirements_extra.txt @@ -21,7 +21,7 @@ ipython >= 7.19.0 django-extensions >= 3.1.0 # xyzroom contrib -scipy<1.9 +scipy == 1.9.3 # Git contrib -gitpython >= 3.1.27 \ No newline at end of file +gitpython >= 3.1.27