makemaker-defaults.mk: fallback COMPONENT_PROJECT_URL to dist
[oi-userland.git] / components / python / python27 / patches / 04-solaris-64-bit.patch
blob4bd3c87d10b0f6a56b78979fa5e040cc747da8f9
1 --- Python-2.7.6/Lib/distutils/command/build_ext.py.~1~ 2013-11-09 23:36:40.000000000 -0800
2 +++ Python-2.7.6/Lib/distutils/command/build_ext.py 2014-05-14 12:47:04.342901439 -0700
3 @@ -634,6 +634,10 @@
4 filename = self.get_ext_filename(ext_name)
5 filename = os.path.split(filename)[-1]
7 + # on Solaris we put 64-bit python objects under .../64
8 + if sys.maxint != 2147483647L:
9 + filename = os.path.join("64", filename)
11 if not self.inplace:
12 # no further work needed
13 # returning :
14 @@ -674,7 +678,14 @@
15 so_ext = get_config_var('SO')
16 if os.name == 'nt' and self.debug:
17 return os.path.join(*ext_path) + '_d' + so_ext
18 - return os.path.join(*ext_path) + so_ext
19 + #return os.path.join(*ext_path) + so_ext
20 + # .so extensions are word-size specific
21 + path = apply(os.path.join, ext_path)
22 + if sys.maxint == 2147483647L:
23 + return path + so_ext
24 + dirname = os.path.dirname(path);
25 + basename = os.path.basename(path);
26 + return os.path.join(dirname, "64", basename + so_ext)
28 def get_export_symbols (self, ext):
29 """Return the list of symbols that a shared extension has to
30 --- Python-2.7.6/Python/import.c.~1~ 2013-11-09 23:36:41.000000000 -0800
31 +++ Python-2.7.6/Python/import.c 2014-05-14 12:53:34.233016586 -0700
32 @@ -1288,6 +1288,57 @@
33 static int find_init_module(char *); /* Forward */
34 static struct filedescr importhookdescr = {"", "", IMP_HOOK};
36 +#ifdef HAVE_STAT
37 +static char *
38 +insert_64dir(char *buf, size_t buflen)
40 + char *base;
41 + char *cp;
42 + size_t blen;
44 + if ((blen = strlen(buf)) == 0)
45 + return (NULL);
47 + cp = &buf[blen - 1];
48 + while (cp != buf && *cp != SEP)
49 + cp--;
51 + if (cp != buf)
52 + cp++;
54 + if (blen + strlen("64/") + 1 >= buflen)
55 + return NULL;
57 + base = strdup(cp);
58 + sprintf(cp, "64%c%s", SEP, base);
59 + free(base);
61 + return buf;
64 +/*
65 + * If we're on a 64-bit platform, modify lookups for shared object files.
66 + */
67 +static size_t modify_path(struct filedescr *fdp, char *buf, size_t buflen)
69 + struct stat statbuf;
71 + if (sizeof(void *) != 8)
72 + return 0;
74 + if (stat(buf, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))
75 + return 0;
77 + if (fdp->type != C_EXTENSION)
78 + return 0;
80 + if (insert_64dir(buf, buflen) == NULL)
81 + return 0;
83 + return strlen("64/");
85 +#endif
87 static struct filedescr *
88 find_module(char *fullname, char *subname, PyObject *path, char *buf,
89 size_t buflen, FILE **p_fp, PyObject **p_loader)
90 @@ -1302,11 +1353,10 @@
91 static struct filedescr fd_builtin = {"", "", C_BUILTIN};
92 static struct filedescr fd_package = {"", "", PKG_DIRECTORY};
93 char *name;
94 -#if defined(PYOS_OS2)
95 size_t saved_len;
96 size_t saved_namelen;
97 char *saved_buf = NULL;
98 -#endif
100 if (p_loader != NULL)
101 *p_loader = NULL;
103 @@ -1513,15 +1563,17 @@
107 -#if defined(PYOS_OS2)
108 /* take a snapshot of the module spec for restoration
109 * after the 8 character DLL hackery
111 saved_buf = strdup(buf);
112 saved_len = len;
113 saved_namelen = namelen;
114 -#endif /* PYOS_OS2 */
116 for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {
117 +#ifdef HAVE_STAT
118 + len += modify_path(fdp, buf, buflen);
119 +#endif
120 #if defined(PYOS_OS2) && defined(HAVE_DYNAMIC_LOADING)
121 /* OS/2 limits DLLs to 8 character names (w/o
122 extension)
123 @@ -1562,21 +1614,20 @@
124 fp = NULL;
127 -#if defined(PYOS_OS2)
129 /* restore the saved snapshot */
130 strcpy(buf, saved_buf);
131 len = saved_len;
132 namelen = saved_namelen;
133 -#endif
135 -#if defined(PYOS_OS2)
137 /* don't need/want the module name snapshot anymore */
138 if (saved_buf)
140 free(saved_buf);
141 saved_buf = NULL;
143 -#endif
145 Py_XDECREF(copy);
146 if (fp != NULL)
147 break;
148 --- Python-2.7.1/Python/importdl.h.orig Fri Jul 15 15:48:16 2011
149 +++ Python-2.7.1/Python/importdl.h Fri Jul 15 15:49:10 2011
150 @@ -31,8 +31,9 @@
151 extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname,
152 FILE *);
154 -/* Max length of module suffix searched for -- accommodates "module.slb" */
155 -#define MAXSUFFIXSIZE 12
156 +/* Max length of module suffix searched for -- accommodates "module.slb"
157 + and '64/' */
158 +#define MAXSUFFIXSIZE 15
160 #ifdef MS_WINDOWS
161 #include <windows.h>
162 --- Python-2.7.15/Lib/distutils/tests/test_build_ext.py.~1~ 2018-04-30 01:47:33.000000000 +0000
163 +++ Python-2.7.15/Lib/distutils/tests/test_build_ext.py 2018-08-27 17:45:37.658024420 +0000
164 @@ -298,7 +298,8 @@
165 self.assertEqual(os.path.splitext(so_file)[-1],
166 sysconfig.get_config_var('SO'))
167 so_dir = os.path.dirname(so_file)
168 - self.assertEqual(so_dir, other_tmp_dir)
169 + if sys.platform != 'sunos5':
170 + self.assertEqual(so_dir, other_tmp_dir)
171 cmd.compiler = None
172 cmd.inplace = 0
173 cmd.run()
174 @@ -307,7 +308,8 @@
175 self.assertEqual(os.path.splitext(so_file)[-1],
176 sysconfig.get_config_var('SO'))
177 so_dir = os.path.dirname(so_file)
178 - self.assertEqual(so_dir, cmd.build_lib)
179 + if sys.platform != 'sunos5':
180 + self.assertEqual(so_dir, cmd.build_lib)
182 # inplace = 0, cmd.package = 'bar'
183 build_py = cmd.get_finalized_command('build_py')
184 @@ -315,7 +317,8 @@
185 path = cmd.get_ext_fullpath('foo')
186 # checking that the last directory is the build_dir
187 path = os.path.split(path)[0]
188 - self.assertEqual(path, cmd.build_lib)
189 + if sys.platform != 'sunos5':
190 + self.assertEqual(path, cmd.build_lib)
192 # inplace = 1, cmd.package = 'bar'
193 cmd.inplace = 1
194 @@ -329,7 +332,8 @@
195 # checking that the last directory is bar
196 path = os.path.split(path)[0]
197 lastdir = os.path.split(path)[-1]
198 - self.assertEqual(lastdir, 'bar')
199 + if sys.platform != 'sunos5':
200 + self.assertEqual(lastdir, 'bar')
202 def test_ext_fullpath(self):
203 ext = sysconfig.get_config_vars()['SO']
204 @@ -341,14 +345,16 @@
205 curdir = os.getcwd()
206 wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
207 path = cmd.get_ext_fullpath('lxml.etree')
208 - self.assertEqual(wanted, path)
209 + if sys.platform != 'sunos5':
210 + self.assertEqual(wanted, path)
212 # building lxml.etree not inplace
213 cmd.inplace = 0
214 cmd.build_lib = os.path.join(curdir, 'tmpdir')
215 wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
216 path = cmd.get_ext_fullpath('lxml.etree')
217 - self.assertEqual(wanted, path)
218 + if sys.platform != 'sunos5':
219 + self.assertEqual(wanted, path)
221 # building twisted.runner.portmap not inplace
222 build_py = cmd.get_finalized_command('build_py')
223 @@ -357,13 +363,15 @@
224 path = cmd.get_ext_fullpath('twisted.runner.portmap')
225 wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
226 'portmap' + ext)
227 - self.assertEqual(wanted, path)
228 + if sys.platform != 'sunos5':
229 + self.assertEqual(wanted, path)
231 # building twisted.runner.portmap inplace
232 cmd.inplace = 1
233 path = cmd.get_ext_fullpath('twisted.runner.portmap')
234 wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
235 - self.assertEqual(wanted, path)
236 + if sys.platform != 'sunos5':
237 + self.assertEqual(wanted, path)
239 def test_build_ext_inplace(self):
240 etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
241 @@ -378,7 +386,8 @@
242 ext = sysconfig.get_config_var("SO")
243 wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
244 path = cmd.get_ext_fullpath('lxml.etree')
245 - self.assertEqual(wanted, path)
246 + if sys.platform != 'sunos5':
247 + self.assertEqual(wanted, path)
249 def test_setuptools_compat(self):
250 import distutils.core, distutils.extension, distutils.command.build_ext
251 @@ -418,7 +427,8 @@
252 ext_name = os.path.join('UpdateManager', 'fdsend')
253 ext_path = cmd.get_ext_fullpath(ext_name)
254 wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext)
255 - self.assertEqual(ext_path, wanted)
256 + if sys.platform != 'sunos5':
257 + self.assertEqual(ext_path, wanted)
259 @unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows')
260 def test_build_ext_path_cross_platform(self):