From d7e93a5f30223883e4ab0c34d8519fea7dbeaf70 Mon Sep 17 00:00:00 2001 From: s0600204 Date: Wed, 23 Feb 2022 21:30:38 +0100 Subject: [PATCH] Fix building spidermonkey on systems with python 3.10 Tested by: Langbart - macOS 10.15.7: homebrewed python 3.9.9 & 3.10.1 andy5995 - Manjaro 21.2.3: python 3.10.2 s0600204 - ArchLinux: python 3.10.2 Bug: https://wildfiregames.com/forum/topic/65901-christmas-testing-bundle/#comment-472056 Origin: upstream, commit:https://trac.wildfiregames.com/changeset/26475 Origin: https://code.wildfiregames.com/D4437 Bug-Debian: https://bugs.debian.org/1008075 Gbp-Pq: Name fix-build-mozjs-with-python-3.10.patch --- .../spidermonkey/FixPythonCollectionABC.diff | 87 +++++++++++++++++++ .../FixVirtualenvForPython310.diff | 15 ++++ libraries/source/spidermonkey/patch.sh | 13 +++ 3 files changed, 115 insertions(+) create mode 100644 libraries/source/spidermonkey/FixPythonCollectionABC.diff create mode 100644 libraries/source/spidermonkey/FixVirtualenvForPython310.diff diff --git a/libraries/source/spidermonkey/FixPythonCollectionABC.diff b/libraries/source/spidermonkey/FixPythonCollectionABC.diff new file mode 100644 index 0000000..536a534 --- /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 diff --git a/libraries/source/spidermonkey/FixVirtualenvForPython310.diff b/libraries/source/spidermonkey/FixVirtualenvForPython310.diff new file mode 100644 index 0000000..d023c63 --- /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) diff --git a/libraries/source/spidermonkey/patch.sh b/libraries/source/spidermonkey/patch.sh index 9059fd6..ca2b67c 100644 --- a/libraries/source/spidermonkey/patch.sh +++ b/libraries/source/spidermonkey/patch.sh @@ -19,6 +19,14 @@ patch -p1 < ../FixSharedArray.diff # (mentionned in the comments, no patch/commit found) patch -p1 < ../FixPublicExport.diff +# 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. +# +# It is assumed that the updated version fetched for macOS systems +# above does not have this problem. +patch -p1 < ../FixVirtualenvForPython310.diff + # Fix Rooted not working on VS17 # https://bugzilla.mozilla.org/show_bug.cgi?id=1679736 # (Landed in 85) @@ -34,6 +42,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 -- 2.30.2