summaryrefslogtreecommitdiff
blob: 80991e3c7a6eff67757319aafac5bb239fdd9bd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
https://github.com/0ad/0ad/commit/c2ec217eea6952c4877095969e11900b70c7cda3
https://bugs.gentoo.org/845987

From: s0600204 <s0600204@3db68df2-c116-0410-a063-a993310a9797>
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