Add support for Python3.11

This commit is contained in:
Griatch 2022-11-15 23:50:08 +01:00
parent c62bda9d77
commit 544638bf42
9 changed files with 30 additions and 28 deletions

View file

@ -18,7 +18,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
python-version: ['3.9', '3.10'] python-version: ['3.9', '3.10', '3.11']
TESTING_DB: ['sqlite3', 'postgresql', 'mysql'] TESTING_DB: ['sqlite3', 'postgresql', 'mysql']
steps: steps:

View file

@ -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. 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 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). `/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) 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) 5. `source evenv/bin/activate` (Linux, Mac), `evenv\Scripts\activate` (Windows)
6. `pip install -e evennia` 6. `pip install -e evennia`
7. `evennia --init mygame` 7. `evennia --init mygame`
@ -42,7 +42,7 @@ install the requirements:
``` ```
sudo apt-get update 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 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 security risk. Now create a folder where you want to do all your Evennia

View file

@ -4,7 +4,7 @@
# `value = number` and only specific names supported by the handler. # `value = number` and only specific names supported by the handler.
PYTHON_MIN = 3.9 PYTHON_MIN = 3.9
PYTHON_MAX_TESTED = 3.11 PYTHON_MAX_TESTED = 3.11.0.0
TWISTED_MIN = 20.3.0 TWISTED_MIN = 20.3.0
DJANGO_MIN = 4.0.2 DJANGO_MIN = 4.0.2
DJANGO_LT = 4.1 DJANGO_MAX_TESTED = 4.1

View file

@ -3460,7 +3460,7 @@ class CmdScripts(COMMAND_DEFAULT_CLASS):
if not scripts: if not scripts:
scripts = ScriptDB.objects.filter(db_obj=obj).exclude( 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: if scripts.count() > 1:

View file

@ -122,7 +122,7 @@ heavily-documented code below.
""" """
from inspect import getargspec from inspect import getfullargspec
from textwrap import dedent from textwrap import dedent
from django.conf import settings 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): if callable(value):
# Check the function arguments # Check the function arguments
kwargs = {} kwargs = {}
spec = getargspec(value) spec = getfullargspec(value)
args = spec.args args = spec.args
if spec.keywords: if spec.varkw:
kwargs.update(dict(menu=menu, choice=choice, string=string, obj=obj, caller=caller)) kwargs.update(dict(menu=menu, choice=choice, string=string, obj=obj, caller=caller))
else: else:
if "menu" in args: if "menu" in args:
@ -292,8 +292,9 @@ def menu_quit(caller, menu):
""" """
if caller is None or menu is None: if caller is None or menu is None:
log_err( log_err(
"The function `menu_quit` was called with missing " "The function `menu_quit` was called with missing arguments: caller={}, menu={}".format(
"arguments: caller={}, menu={}".format(caller, menu) caller, menu
)
) )
if caller.cmdset.has(BuildingMenuCmdSet): if caller.cmdset.has(BuildingMenuCmdSet):
@ -835,8 +836,9 @@ class BuildingMenu:
if key and key in self.cmds: if key and key in self.cmds:
raise ValueError( raise ValueError(
"A conflict exists between {} and {}, both use " "A conflict exists between {} and {}, both use key or alias {}".format(
"key or alias {}".format(self.cmds[key], title, repr(key)) self.cmds[key], title, repr(key)
)
) )
if attr: if attr:

View file

@ -188,7 +188,7 @@ class RandomStringGenerator:
""" """
self.total = 1 self.total = 1
self.elements = [] 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 # `tree` contains a list of elements in the regular expression
for element in tree: for element in tree:
# `element` is also a list, the first element is a string # `element` is also a list, the first element is a string

View file

@ -95,7 +95,7 @@ PYTHON_MIN = None
PYTHON_MAX_TESTED = None PYTHON_MAX_TESTED = None
TWISTED_MIN = None TWISTED_MIN = None
DJANGO_MIN = None DJANGO_MIN = None
DJANGO_LT = None DJANGO_MAX_TESTED = None
with open(os.path.join(EVENNIA_LIB, "VERSION_REQS.txt")) as fil: with open(os.path.join(EVENNIA_LIB, "VERSION_REQS.txt")) as fil:
for line in fil.readlines(): 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" TWISTED_MIN = value[0] if value else "0"
elif key == "DJANGO_MIN": elif key == "DJANGO_MIN":
DJANGO_MIN = value[0] if value else "0" DJANGO_MIN = value[0] if value else "0"
elif key == "DJANGO_LT": elif key == "DJANGO_MAX_TESTED":
DJANGO_LT = value[0] if value else "100" DJANGO_MAX_TESTED = value[0] if value else "100"
try: try:
sys.path[1] = EVENNIA_ROOT sys.path[1] = EVENNIA_ROOT
@ -1307,12 +1307,12 @@ def check_main_evennia_dependencies():
if LooseVersion(dversion) < LooseVersion(DJANGO_MIN): if LooseVersion(dversion) < LooseVersion(DJANGO_MIN):
print( print(
ERROR_DJANGO_MIN.format( 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 error = True
elif LooseVersion(DJANGO_LT) <= LooseVersion(dversion_main): elif LooseVersion(DJANGO_MAX_TESTED) <= LooseVersion(dversion_main):
print(NOTE_DJANGO_NEW.format(dversion=dversion_main, django_rec=DJANGO_LT)) print(NOTE_DJANGO_NEW.format(dversion=dversion_main, django_rec=DJANGO_MAX_TESTED))
except ImportError: except ImportError:
print(ERROR_NODJANGO) print(ERROR_NODJANGO)
error = True error = True

View file

@ -266,7 +266,7 @@ import inspect
import re import re
from ast import literal_eval from ast import literal_eval
from fnmatch import fnmatch from fnmatch import fnmatch
from inspect import getargspec, isfunction from inspect import getfullargspec, isfunction
from math import ceil from math import ceil
from django.conf import settings from django.conf import settings
@ -741,10 +741,10 @@ class EvMenu:
""" """
try: try:
try: try:
nargs = len(getargspec(callback).args) nargs = len(getfullargspec(callback).args)
except TypeError: except TypeError:
raise EvMenuError("Callable {} doesn't accept any arguments!".format(callback)) 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: if nargs <= 0:
raise EvMenuError("Callable {} doesn't accept any arguments!".format(callback)) raise EvMenuError("Callable {} doesn't accept any arguments!".format(callback))
@ -1285,7 +1285,7 @@ def list_node(option_generator, select=None, pagesize=10):
else: else:
if callable(select): if callable(select):
try: try:
if bool(getargspec(select).keywords): if bool(getfullargspec(select).varkw):
return select( return select(
caller, selection, available_choices=available_choices, **kwargs 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 # add data from the decorated node
decorated_options = [] decorated_options = []
supports_kwargs = bool(getargspec(func).keywords) supports_kwargs = bool(getfullargspec(func).varkw)
try: try:
if supports_kwargs: if supports_kwargs:
text, decorated_options = func(caller, raw_string, **kwargs) text, decorated_options = func(caller, raw_string, **kwargs)

View file

@ -21,7 +21,7 @@ ipython >= 7.19.0
django-extensions >= 3.1.0 django-extensions >= 3.1.0
# xyzroom contrib # xyzroom contrib
scipy<1.9 scipy == 1.9.3
# Git contrib # Git contrib
gitpython >= 3.1.27 gitpython >= 3.1.27