File: multiarch

package info (click to toggle)
pypy 5.6.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,040 kB
  • ctags: 185,069
  • sloc: python: 1,147,862; ansic: 49,642; cpp: 5,245; asm: 5,169; makefile: 529; sh: 481; xml: 232; lisp: 45
file content (142 lines) | stat: -rw-r--r-- 4,831 bytes parent folder | download
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
Description: Add multiarch tag to C extension file names
 Add _multiarch variable to sys, and MULTIARCH to sysconfig variables, exposing
 the multiarch tag.
 Add the multiarch tag to C extension file names, by default, while still
 supporting bare suffixes.
 Based on multiarch.diff in Debian cPython.
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: not-needed
Last-Modified: 2014-09-20

--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -99,6 +99,9 @@
         interpleveldefs['winver'] = 'version.get_winver(space)'
         interpleveldefs['getwindowsversion'] = 'vm.getwindowsversion'
 
+    if hasattr(sys, '_multiarch'):
+        interpleveldefs['_multiarch'] = 'debian.get_multiarch_tuple(space)'
+
     appleveldefs = {
         'excepthook'            : 'app.excepthook',
         '__excepthook__'        : 'app.excepthook',
--- /dev/null
+++ b/pypy/module/sys/debian.py
@@ -0,0 +1,12 @@
+import os
+import sys
+
+_multiarch = getattr(getattr(sys, 'implementation', sys), '_multiarch', None)
+# Support building under the Debian buildsystem, on older releases
+if not _multiarch:
+    _multiarch = os.environ['DEB_HOST_MULTIARCH']
+del os, sys
+
+
+def get_multiarch_tuple(space):
+    return space.wrap(_multiarch)
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -373,6 +373,10 @@
     # in PyPy no such module exists
     #from _sysconfigdata import build_time_vars
     #vars.update(build_time_vars)
+    if hasattr(sys, '_multiarch'):
+        vars.update({
+            'MULTIARCH': sys._multiarch,
+        })
     return
 
 def _init_non_posix(vars):
@@ -528,6 +532,9 @@
         import imp
         for suffix, mode, type_ in imp.get_suffixes():
             if type_ == imp.C_EXTENSION:
+                multiarch = _CONFIG_VARS.get('MULTIARCH')
+                if multiarch and multiarch in suffix:
+                    continue
                 _CONFIG_VARS['SOABI'] = suffix.split('.')[1]
                 break        
 
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -141,6 +141,11 @@
         exc = raises(SystemExit, sys.exit, (1, 2, 3))
         assert exc.value.code == (1, 2, 3)
 
+    def test_sys_multiarch(self):
+        import sys
+        multiarch = sys._multiarch
+        assert isinstance(multiarch, str)
+
 
 class AppTestSysModulePortedFromCPython:
 
--- a/lib-python/2.7/test/test_sysconfig.py
+++ b/lib-python/2.7/test/test_sysconfig.py
@@ -344,6 +344,11 @@
         self.assertEqual(status, 0)
         self.assertEqual(my_platform, test_platform)
 
+    def test_multiarch_config_var(self):
+        multiarch = get_config_var('MULTIARCH')
+        self.assertIsInstance(multiarch, str)
+
+
 def test_main():
     run_unittest(TestSysConfig)
 
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -42,7 +42,7 @@
 DEFAULT_MAGIC_TAG = DEFAULT_SOABI
 
 @specialize.memo()
-def get_so_extension(space):
+def get_so_extension(space, multiarch=True):
     if space.config.objspace.soabi is not None:
         soabi = space.config.objspace.soabi
     else:
@@ -54,6 +54,9 @@
     if not space.config.translating:
         soabi += 'i'
 
+    if multiarch and hasattr(sys, '_multiarch'):
+        soabi += '-' + sys._multiarch
+
     return '.' + soabi + SO
 
 def log_pyverbose(space, level, message):
--- a/pypy/module/imp/interp_imp.py
+++ b/pypy/module/imp/interp_imp.py
@@ -12,9 +12,12 @@
     w = space.wrap
     suffixes_w = []
     if importing.has_so_extension(space):
-        suffixes_w.append(
+        suffixes_w.extend([
             space.newtuple([w(importing.get_so_extension(space)),
-                            w('rb'), w(importing.C_EXTENSION)]))
+                            w('rb'), w(importing.C_EXTENSION)]),
+            space.newtuple([w(importing.get_so_extension(space, False)),
+                            w('rb'), w(importing.C_EXTENSION)]),
+            ])
     suffixes_w.extend([
         space.newtuple([w('.py'), w('U'), w(importing.PY_SOURCE)]),
         space.newtuple([w('.pyc'), w('rb'), w(importing.PY_COMPILED)]),
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -804,11 +804,12 @@
     def test_abi_tag(self):
         space1 = maketestobjspace(make_config(None, soabi='TEST'))
         space2 = maketestobjspace(make_config(None, soabi=''))
+        ma = sys._multiarch
         if sys.platform == 'win32':
             assert importing.get_so_extension(space1) == '.TESTi.pyd'
             assert importing.get_so_extension(space2) == '.pyd'
         else:
-            assert importing.get_so_extension(space1) == '.TESTi.so'
+            assert importing.get_so_extension(space1) == '.TESTi-%s.so' % ma
             assert importing.get_so_extension(space2) == '.so'
 
 def _getlong(data):