https://github.com/0ad/0ad/commit/c2ec217eea6952c4877095969e11900b70c7cda3 https://bugs.gentoo.org/845987 From: s0600204 Date: Wed, 23 Feb 2022 20:30:38 +0000 Subject: [PATCH] Fix building spidermonkey on systems with python 3.10 Tested by: * Langbart - macOS 10.15.7: `homebrew`ed python 3.9.9 & 3.10.1 * andy5995 - Manjaro 21.2.3: python 3.10.2 * s0600204 - ArchLinux: python 3.10.2 Differential Revision: https://code.wildfiregames.com/D4437 git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@26475 3db68df2-c116-0410-a063-a993310a9797 --- /dev/null +++ b/libraries/source/spidermonkey/FixPythonCollectionABC.diff @@ -0,0 +1,87 @@ +--- a/python/mach/mach/config.py ++++ b/python/mach/mach/config.py +@@ -144,7 +144,7 @@ + return _ + + +-class ConfigSettings(collections.Mapping): ++class ConfigSettings(collections.abc.Mapping): + """Interface for configuration settings. + + This is the main interface to the configuration. +@@ -190,7 +190,7 @@ + will result in exceptions being raised. + """ + +- class ConfigSection(collections.MutableMapping, object): ++ class ConfigSection(collections.abc.MutableMapping, object): + """Represents an individual config section.""" + def __init__(self, config, name, settings): + object.__setattr__(self, '_config', config) +--- a/python/mach/mach/decorators.py ++++ b/python/mach/mach/decorators.py +@@ -159,7 +159,7 @@ + 'Conditions argument must take a list ' + \ + 'of functions. Found %s instead.' + +- if not isinstance(command.conditions, collections.Iterable): ++ if not isinstance(command.conditions, collections.abc.Iterable): + msg = msg % (command.name, type(command.conditions)) + raise MachError(msg) + +--- a/python/mach/mach/main.py ++++ b/python/mach/mach/main.py +@@ -16,7 +16,7 @@ + import sys + import traceback + import uuid +-from collections import Iterable ++from collections.abc import Iterable + + from six import string_types + +--- a/python/mozbuild/mozbuild/backend/configenvironment.py ++++ b/python/mozbuild/mozbuild/backend/configenvironment.py +@@ -9,7 +9,8 @@ + import sys + import json + +-from collections import Iterable, OrderedDict ++from collections import OrderedDict ++from collections.abc import Iterable + from types import ModuleType + + import mozpack.path as mozpath +--- a/python/mozbuild/mozbuild/makeutil.py ++++ b/python/mozbuild/mozbuild/makeutil.py +@@ -7,7 +7,7 @@ + import os + import re + import six +-from collections import Iterable ++from collections.abc import Iterable + + + class Makefile(object): +--- a/python/mozbuild/mozbuild/util.py ++++ b/python/mozbuild/mozbuild/util.py +@@ -782,7 +782,7 @@ + self._strings = StrictOrderingOnAppendList() + self._children = {} + +- class StringListAdaptor(collections.Sequence): ++ class StringListAdaptor(collections.abc.Sequence): + def __init__(self, hsl): + self._hsl = hsl + +--- a/testing/mozbase/manifestparser/manifestparser/filters.py ++++ b/testing/mozbase/manifestparser/manifestparser/filters.py +@@ -15,1 +15,2 @@ +-from collections import defaultdict, MutableSequence ++from collections import defaultdict ++from collections.abc import MutableSequence +--- a/third_party/python/pipenv/pipenv/vendor/jinja2/sandbox.py ++++ b/third_party/python/pipenv/pipenv/vendor/jinja2/sandbox.py +@@ -82,1 +82,1 @@ +-from collections import MutableSet, MutableMapping, MutableSequence ++from collections.abc import MutableSet, MutableMapping, MutableSequence --- /dev/null +++ b/libraries/source/spidermonkey/FixVirtualenvForPython310.diff @@ -0,0 +1,15 @@ +--- a/third_party/python/virtualenv/virtualenv.py ++++ b/third_party/python/virtualenv/virtualenv.py +@@ -1804,7 +1804,11 @@ + pass + else: + # noinspection PyProtectedMember +- if sysconfig._get_default_scheme() == "posix_local": ++ try: # Python >= 3.10 ++ default_scheme = sysconfig.get_default_scheme() ++ except: # Python < 3.10 ++ default_scheme = sysconfig._get_default_scheme() ++ if default_scheme == "posix_local": + local_path = os.path.join(home_dir, "local") + if not os.path.exists(local_path): + os.mkdir(local_path) --- a/libraries/source/spidermonkey/patch.sh +++ b/libraries/source/spidermonkey/patch.sh @@ -52,6 +60,11 @@ patch -p1 < ../FixMSVCRootedVoid.diff # so this patches it to an arbitrarily high Mac OS 11 patch -p1 < ../FixMacBuild.diff +# In python 3.3, the Collections' Abstract Base Classes were moved from `collections` to +# `collections.abc`, and aliases were set up for backwards compatibility. +# In python 3.10, these aliases were removed, requiring all code that used them to update. +patch -p1 < ../FixPythonCollectionABC.diff + # Fix FP access breaking compilation on RPI3+ # https://bugzilla.mozilla.org/show_bug.cgi?id=1526653 # https://bugzilla.mozilla.org/show_bug.cgi?id=1536491 diff --git a/libraries/source/spidermonkey/patch.sh b/libraries/source/spidermonkey/patch.sh index 2a3e165..5dde46f 100644 --- a/libraries/source/spidermonkey/patch.sh +++ b/libraries/source/spidermonkey/patch.sh @@ -2,6 +2,11 @@ # Apply patches if needed # This script gets called from build.sh. +# In python 3.10 `sysconfig._get_default_scheme()` was renamed to +# `sysconfig.get_default_scheme()`. This breaks the version of +# `virtualenv` bundled with the spidermonkey source code. +patch -p1 < ../FixVirtualenvForPython310.diff + # Mozglue symbols need to be linked against static builds. # https://bugzilla.mozilla.org/show_bug.cgi?id=1588340 patch -p1 < ../FixMozglue.diff