Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/python:master commit in: dev-lang/python/, dev-lang/python/files/, dev-lang/python/files/3.3/
Date: Fri, 28 Oct 2016 00:03:07
Message-Id: 1477612962.97459af323867deeab8981cc82066be4a2631808.floppym@gentoo
1 commit: 97459af323867deeab8981cc82066be4a2631808
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Fri Oct 28 00:02:42 2016 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Fri Oct 28 00:02:42 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/python.git/commit/?id=97459af3
7
8 dev-lang/python: add 3.3.5
9
10 Package-Manager: portage-2.3.2
11
12 dev-lang/python/Manifest | 1 +
13 dev-lang/python/files/3.3/.gitattributes | 1 +
14 .../files/3.3/01_all_static_library_location.patch | 70 ++++
15 .../files/3.3/02_all_disable_modules_and_ssl.patch | 57 ++++
16 dev-lang/python/files/3.3/03_all_libdir.patch | 174 ++++++++++
17 .../04_all_non-zero_exit_status_on_failure.patch | 31 ++
18 ..._all_regenerate_platform-specific_modules.patch | 123 +++++++
19 .../python/files/3.3/21_all_distutils_c++.patch | 271 +++++++++++++++
20 .../files/3.3/22_all_tests_environment.patch | 192 +++++++++++
21 .../python/files/3.3/23_all_h2py_encoding.patch | 173 ++++++++++
22 .../python/files/3.3/24_all_sqlite-3.8.4.patch | 14 +
23 .../python/files/3.3/61_all_process_data.patch | 166 ++++++++++
24 .../python/files/python-3.3-CVE-2014-4616.patch | 52 +++
25 dev-lang/python/files/python-3.3-libressl.patch | 127 +++++++
26 .../files/python-3.3.5-ncurses-pkg-config.patch | 40 +++
27 dev-lang/python/files/python-3.4-gcc-5.patch | 37 +++
28 dev-lang/python/metadata.xml | 13 +
29 dev-lang/python/python-3.3.5.ebuild | 368 +++++++++++++++++++++
30 18 files changed, 1910 insertions(+)
31
32 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
33 index 0e0bd0d..38fe597 100644
34 --- a/dev-lang/python/Manifest
35 +++ b/dev-lang/python/Manifest
36 @@ -1,2 +1,3 @@
37 DIST Python-2.6.9.tar.xz 9333664 SHA256 cae7bb995006ea5b703d9d28446f694894c441fe4bfb95d561c0ac908cd06e41 SHA512 bcd9286b6af3bfa2017f0b32c6c0f9b934224ece496d2d897ab3a61a936d306a5f61a580c060ce501034a614da374d17831a9c9be9f947b01d977b56437c023b WHIRLPOOL 0b9feb710f0c5c8726522465f26ac6fa17e8f87c0e5cda4ef0b130e5d8e213d32aad0143e0ec909c677a7b515ed63ed9e9d50a33890f22068b820a5f15ba47fd
38 DIST Python-3.2.6.tar.xz 9243292 SHA256 1d12b501819fd26afafbf8459be1aa279b56f032b4c15412de0a713ce0de7bdc SHA512 514b46029dd5b07f2d287a1f00c6716970197186a38e3f2e1ec60c2292cf03a2dc45165ba9c217e5219c7cb6d96a09f790f5b3bdcc8d11db53f927297fe4ddc9 WHIRLPOOL b34f215e0f50123c5b2969e615ffbab99b631433de8f13cbbca525bf57cbc1bb9a159fba02616b3772be9b249be3cec36d6fd1856a678880674b828eb4ab08ed
39 +DIST Python-3.3.5.tar.xz 12116308 SHA256 abe99b484434503d8b23be0f243ec27139e743a4798cd71c1dce3cf40e63b6e5 SHA512 562ebd85291f29ff18d37f05682763fc45aa9d070688006f4ef5c89392a48022357c3ca9ee1d795e9e863bdef413e6bab77b8d65581d374a76dbe7cacec65550 WHIRLPOOL f4b6010d32b28b7bb038cbb7c5f98d325cc4253fd1be9a0a1089ed6fd7dd414c5169931d21ef819137d5c1084517a650828f260cf2a1d8ce871bc67aeef3fff8
40
41 diff --git a/dev-lang/python/files/3.3/.gitattributes b/dev-lang/python/files/3.3/.gitattributes
42 new file mode 100644
43 index 0000000..5e5a56d
44 --- /dev/null
45 +++ b/dev-lang/python/files/3.3/.gitattributes
46 @@ -0,0 +1 @@
47 +Makefile export-ignore
48
49 diff --git a/dev-lang/python/files/3.3/01_all_static_library_location.patch b/dev-lang/python/files/3.3/01_all_static_library_location.patch
50 new file mode 100644
51 index 0000000..36ac67a
52 --- /dev/null
53 +++ b/dev-lang/python/files/3.3/01_all_static_library_location.patch
54 @@ -0,0 +1,70 @@
55 +Install libpythonX.Y.a in /usr/lib instead of /usr/lib/pythonX.Y/config.
56 +https://bugs.gentoo.org/show_bug.cgi?id=252372
57 +http://bugs.python.org/issue6103
58 +
59 +--- Makefile.pre.in
60 ++++ Makefile.pre.in
61 +@@ -965,6 +965,19 @@
62 + fi; \
63 + else true; \
64 + fi
65 ++ @if test -f $(LIBRARY) && test $(LIBRARY) != $(LDLIBRARY); then \
66 ++ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
67 ++ if test "$(SHLIB_SUFFIX)" = .dll; then \
68 ++ $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBDIR); \
69 ++ else \
70 ++ $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBDIR); \
71 ++ $(RANLIB) $(DESTDIR)$(LIBDIR)/$(LIBRARY); \
72 ++ fi; \
73 ++ else \
74 ++ echo "Skipped install of $(LIBRARY) - use make frameworkinstall"; \
75 ++ fi; \
76 ++ else true; \
77 ++ fi
78 +
79 + bininstall: altbininstall
80 + -if test -f $(DESTDIR)$(BINDIR)/python3$(EXE) -o -h $(DESTDIR)$(BINDIR)/python3$(EXE); \
81 +@@ -1200,18 +1213,6 @@
82 + else true; \
83 + fi; \
84 + done
85 +- @if test -d $(LIBRARY); then :; else \
86 +- if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
87 +- if test "$(SHLIB_SUFFIX)" = .dll; then \
88 +- $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
89 +- else \
90 +- $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
91 +- $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
92 +- fi; \
93 +- else \
94 +- echo Skip install of $(LIBRARY) - use make frameworkinstall; \
95 +- fi; \
96 +- fi
97 + $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
98 + $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
99 + $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
100 +--- Misc/python-config.in
101 ++++ Misc/python-config.in
102 +@@ -47,11 +47,7 @@
103 + elif opt in ('--libs', '--ldflags'):
104 + libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
105 + libs.append('-lpython' + pyver + sys.abiflags)
106 +- # add the prefix/lib/pythonX.Y/config dir, but only if there is no
107 +- # shared library in prefix/lib/.
108 + if opt == '--ldflags':
109 +- if not getvar('Py_ENABLE_SHARED'):
110 +- libs.insert(0, '-L' + getvar('LIBPL'))
111 + if not getvar('PYTHONFRAMEWORK'):
112 + libs.extend(getvar('LINKFORSHARED').split())
113 + print(' '.join(libs))
114 +--- Modules/makesetup
115 ++++ Modules/makesetup
116 +@@ -89,7 +89,7 @@
117 + then
118 + ExtraLibDir=.
119 + else
120 +- ExtraLibDir='$(LIBPL)'
121 ++ ExtraLibDir='$(LIBDIR)'
122 + fi
123 + ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";;
124 + esac
125
126 diff --git a/dev-lang/python/files/3.3/02_all_disable_modules_and_ssl.patch b/dev-lang/python/files/3.3/02_all_disable_modules_and_ssl.patch
127 new file mode 100644
128 index 0000000..af735be
129 --- /dev/null
130 +++ b/dev-lang/python/files/3.3/02_all_disable_modules_and_ssl.patch
131 @@ -0,0 +1,57 @@
132 +--- setup.py
133 ++++ setup.py
134 +@@ -31,7 +31,17 @@
135 + COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS"))
136 +
137 + # This global variable is used to hold the list of modules to be disabled.
138 +-disabled_module_list = []
139 ++pdm_env = "PYTHON_DISABLE_MODULES"
140 ++if pdm_env in os.environ:
141 ++ disabled_module_list = os.environ[pdm_env].split()
142 ++else:
143 ++ disabled_module_list = []
144 ++
145 ++pds_env = "PYTHON_DISABLE_SSL"
146 ++if pds_env in os.environ:
147 ++ disable_ssl = os.environ[pds_env]
148 ++else:
149 ++ disable_ssl = 0
150 +
151 + def add_dir_to_list(dirlist, dir):
152 + """Add the directory 'dir' to the list 'dirlist' (after any relative
153 +@@ -435,6 +445,7 @@
154 + os.unlink(tmpfile)
155 +
156 + def detect_modules(self):
157 ++ global disable_ssl
158 + # Ensure that /usr/local is always used, but the local build
159 + # directories (i.e. '.' and 'Include') must be first. See issue
160 + # 10520.
161 +@@ -747,7 +758,7 @@
162 + ssl_incs = find_file('openssl/ssl.h', inc_dirs,
163 + search_for_ssl_incs_in
164 + )
165 +- if ssl_incs is not None:
166 ++ if ssl_incs is not None and not disable_ssl:
167 + krb5_h = find_file('krb5.h', inc_dirs,
168 + ['/usr/kerberos/include'])
169 + if krb5_h:
170 +@@ -758,7 +769,8 @@
171 + ] )
172 +
173 + if (ssl_incs is not None and
174 +- ssl_libs is not None):
175 ++ ssl_libs is not None and
176 ++ not disable_ssl):
177 + exts.append( Extension('_ssl', ['_ssl.c'],
178 + include_dirs = ssl_incs,
179 + library_dirs = ssl_libs,
180 +@@ -791,7 +803,7 @@
181 +
182 + #print('openssl_ver = 0x%08x' % openssl_ver)
183 + min_openssl_ver = 0x00907000
184 +- have_any_openssl = ssl_incs is not None and ssl_libs is not None
185 ++ have_any_openssl = ssl_incs is not None and ssl_libs is not None and not disable_ssl
186 + have_usable_openssl = (have_any_openssl and
187 + openssl_ver >= min_openssl_ver)
188 +
189
190 diff --git a/dev-lang/python/files/3.3/03_all_libdir.patch b/dev-lang/python/files/3.3/03_all_libdir.patch
191 new file mode 100644
192 index 0000000..052c51d
193 --- /dev/null
194 +++ b/dev-lang/python/files/3.3/03_all_libdir.patch
195 @@ -0,0 +1,174 @@
196 +--- Lib/distutils/command/install.py
197 ++++ Lib/distutils/command/install.py
198 +@@ -44,8 +44,8 @@
199 +
200 + INSTALL_SCHEMES = {
201 + 'unix_prefix': {
202 +- 'purelib': '$base/lib/python$py_version_short/site-packages',
203 +- 'platlib': '$platbase/lib/python$py_version_short/site-packages',
204 ++ 'purelib': '$base/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
205 ++ 'platlib': '$platbase/@@GENTOO_LIBDIR@@/python$py_version_short/site-packages',
206 + 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
207 + 'scripts': '$base/bin',
208 + 'data' : '$base',
209 +--- Lib/distutils/sysconfig.py
210 ++++ Lib/distutils/sysconfig.py
211 +@@ -144,7 +144,7 @@
212 +
213 + if os.name == "posix":
214 + libpython = os.path.join(prefix,
215 +- "lib", "python" + get_python_version())
216 ++ "@@GENTOO_LIBDIR@@", "python" + get_python_version())
217 + if standard_lib:
218 + return libpython
219 + else:
220 +--- Lib/site.py
221 ++++ Lib/site.py
222 +@@ -303,10 +303,10 @@
223 + if sys.platform in ('os2emx', 'riscos'):
224 + sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
225 + elif os.sep == '/':
226 +- sitepackages.append(os.path.join(prefix, "lib",
227 ++ sitepackages.append(os.path.join(prefix, "@@GENTOO_LIBDIR@@",
228 + "python" + sys.version[:3],
229 + "site-packages"))
230 +- sitepackages.append(os.path.join(prefix, "lib", "site-python"))
231 ++ sitepackages.append(os.path.join(prefix, "@@GENTOO_LIBDIR@@", "site-python"))
232 + else:
233 + sitepackages.append(prefix)
234 + sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
235 +--- Lib/sysconfig.py
236 ++++ Lib/sysconfig.py
237 +@@ -21,10 +21,10 @@
238 +
239 + _INSTALL_SCHEMES = {
240 + 'posix_prefix': {
241 +- 'stdlib': '{installed_base}/lib/python{py_version_short}',
242 +- 'platstdlib': '{platbase}/lib/python{py_version_short}',
243 +- 'purelib': '{base}/lib/python{py_version_short}/site-packages',
244 +- 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
245 ++ 'stdlib': '{installed_base}/@@GENTOO_LIBDIR@@/python{py_version_short}',
246 ++ 'platstdlib': '{platbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
247 ++ 'purelib': '{base}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
248 ++ 'platlib': '{platbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
249 + 'include':
250 + '{installed_base}/include/python{py_version_short}{abiflags}',
251 + 'platinclude':
252 +@@ -81,10 +81,10 @@
253 + 'data': '{userbase}',
254 + },
255 + 'posix_user': {
256 +- 'stdlib': '{userbase}/lib/python{py_version_short}',
257 +- 'platstdlib': '{userbase}/lib/python{py_version_short}',
258 +- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
259 +- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
260 ++ 'stdlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
261 ++ 'platstdlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}',
262 ++ 'purelib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
263 ++ 'platlib': '{userbase}/@@GENTOO_LIBDIR@@/python{py_version_short}/site-packages',
264 + 'include': '{userbase}/include/python{py_version_short}',
265 + 'scripts': '{userbase}/bin',
266 + 'data': '{userbase}',
267 +--- Lib/test/test_site.py
268 ++++ Lib/test/test_site.py
269 +@@ -248,10 +248,10 @@
270 + elif os.sep == '/':
271 + # OS X non-framwework builds, Linux, FreeBSD, etc
272 + self.assertEqual(len(dirs), 2)
273 +- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
274 ++ wanted = os.path.join('xoxo', '@@GENTOO_LIBDIR@@', 'python' + sys.version[:3],
275 + 'site-packages')
276 + self.assertEqual(dirs[0], wanted)
277 +- wanted = os.path.join('xoxo', 'lib', 'site-python')
278 ++ wanted = os.path.join('xoxo', '@@GENTOO_LIBDIR@@', 'site-python')
279 + self.assertEqual(dirs[1], wanted)
280 + else:
281 + # other platforms
282 +--- Makefile.pre.in
283 ++++ Makefile.pre.in
284 +@@ -115,7 +115,7 @@
285 + MANDIR= @mandir@
286 + INCLUDEDIR= @includedir@
287 + CONFINCLUDEDIR= $(exec_prefix)/include
288 +-SCRIPTDIR= $(prefix)/lib
289 ++SCRIPTDIR= $(prefix)/@@GENTOO_LIBDIR@@
290 + ABIFLAGS= @ABIFLAGS@
291 +
292 + # Detailed destination directories
293 +--- Modules/getpath.c
294 ++++ Modules/getpath.c
295 +@@ -122,8 +122,8 @@
296 + #endif
297 +
298 + #ifndef PYTHONPATH
299 +-#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
300 +- EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
301 ++#define PYTHONPATH PREFIX "/@@GENTOO_LIBDIR@@/python" VERSION ":" \
302 ++ EXEC_PREFIX "/@@GENTOO_LIBDIR@@/python" VERSION "/lib-dynload"
303 + #endif
304 +
305 + #ifndef LANDMARK
306 +@@ -135,7 +135,7 @@
307 + static wchar_t progpath[MAXPATHLEN+1];
308 + static wchar_t *module_search_path = NULL;
309 + static int module_search_path_malloced = 0;
310 +-static wchar_t *lib_python = L"lib/python" VERSION;
311 ++static wchar_t *lib_python = L"@@GENTOO_LIBDIR@@/python" VERSION;
312 +
313 + static void
314 + reduce(wchar_t *dir)
315 +@@ -685,7 +685,7 @@
316 + }
317 + else
318 + wcsncpy(zip_path, _prefix, MAXPATHLEN);
319 +- joinpath(zip_path, L"lib/python00.zip");
320 ++ joinpath(zip_path, L"@@GENTOO_LIBDIR@@/python00.zip");
321 + bufsz = wcslen(zip_path); /* Replace "00" with version */
322 + zip_path[bufsz - 6] = VERSION[0];
323 + zip_path[bufsz - 5] = VERSION[2];
324 +@@ -695,7 +695,7 @@
325 + fprintf(stderr,
326 + "Could not find platform dependent libraries <exec_prefix>\n");
327 + wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
328 +- joinpath(exec_prefix, L"lib/lib-dynload");
329 ++ joinpath(exec_prefix, L"@@GENTOO_LIBDIR@@/lib-dynload");
330 + }
331 + /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */
332 +
333 +--- Modules/Setup.dist
334 ++++ Modules/Setup.dist
335 +@@ -354,7 +354,7 @@
336 + # Andrew Kuchling's zlib module.
337 + # This require zlib 1.1.3 (or later).
338 + # See http://www.gzip.org/zlib/
339 +-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
340 ++#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/@@GENTOO_LIBDIR@@ -lz
341 +
342 + # Interface to the Expat XML parser
343 + #
344 +--- setup.py
345 ++++ setup.py
346 +@@ -507,8 +507,7 @@
347 + # be assumed that no additional -I,-L directives are needed.
348 + if not cross_compiling:
349 + lib_dirs = self.compiler.library_dirs + [
350 +- '/lib64', '/usr/lib64',
351 +- '/lib', '/usr/lib',
352 ++ '/@@GENTOO_LIBDIR@@', '/usr/@@GENTOO_LIBDIR@@',
353 + ]
354 + inc_dirs = self.compiler.include_dirs + ['/usr/include']
355 + else:
356 +@@ -723,11 +722,11 @@
357 + elif curses_library:
358 + readline_libs.append(curses_library)
359 + elif self.compiler.find_library_file(lib_dirs +
360 +- ['/usr/lib/termcap'],
361 ++ ['/usr/@@GENTOO_LIBDIR@@/termcap'],
362 + 'termcap'):
363 + readline_libs.append('termcap')
364 + exts.append( Extension('readline', ['readline.c'],
365 +- library_dirs=['/usr/lib/termcap'],
366 ++ library_dirs=['/usr/@@GENTOO_LIBDIR@@/termcap'],
367 + extra_link_args=readline_extra_link_args,
368 + libraries=readline_libs) )
369 + else:
370
371 diff --git a/dev-lang/python/files/3.3/04_all_non-zero_exit_status_on_failure.patch b/dev-lang/python/files/3.3/04_all_non-zero_exit_status_on_failure.patch
372 new file mode 100644
373 index 0000000..58b839f
374 --- /dev/null
375 +++ b/dev-lang/python/files/3.3/04_all_non-zero_exit_status_on_failure.patch
376 @@ -0,0 +1,31 @@
377 +https://bugs.gentoo.org/show_bug.cgi?id=281968
378 +http://bugs.python.org/issue6731
379 +
380 +--- setup.py
381 ++++ setup.py
382 +@@ -43,6 +43,8 @@
383 + else:
384 + disable_ssl = 0
385 +
386 ++exit_status = 0
387 ++
388 + def add_dir_to_list(dirlist, dir):
389 + """Add the directory 'dir' to the list 'dirlist' (after any relative
390 + directories) if:
391 +@@ -277,6 +279,8 @@
392 + print()
393 +
394 + if self.failed:
395 ++ global exit_status
396 ++ exit_status = 1
397 + failed = self.failed[:]
398 + print()
399 + print("Failed to build these modules:")
400 +@@ -2213,6 +2217,7 @@
401 + scripts = ["Tools/scripts/pydoc3", "Tools/scripts/idle3",
402 + "Tools/scripts/2to3", "Tools/scripts/pyvenv"]
403 + )
404 ++ sys.exit(exit_status)
405 +
406 + # --install-platlib
407 + if __name__ == '__main__':
408
409 diff --git a/dev-lang/python/files/3.3/05_all_regenerate_platform-specific_modules.patch b/dev-lang/python/files/3.3/05_all_regenerate_platform-specific_modules.patch
410 new file mode 100644
411 index 0000000..68f33f7
412 --- /dev/null
413 +++ b/dev-lang/python/files/3.3/05_all_regenerate_platform-specific_modules.patch
414 @@ -0,0 +1,123 @@
415 +http://bugs.python.org/issue12619
416 +
417 +--- Lib/plat-aix4/regen
418 ++++ Lib/plat-aix4/regen
419 +@@ -5,4 +5,4 @@
420 + exit 1;;
421 + esac
422 + set -v
423 +-h2py.py -i '(u_long)' /usr/include/netinet/in.h
424 ++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
425 +--- Lib/plat-linux/regen
426 ++++ Lib/plat-linux/regen
427 +@@ -5,4 +5,4 @@
428 + exit 1;;
429 + esac
430 + set -v
431 +-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h
432 ++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/dlfcn.h /usr/include/linux/cdrom.h
433 +--- Lib/plat-sunos5/regen
434 ++++ Lib/plat-sunos5/regen
435 +@@ -5,5 +5,4 @@
436 + exit 1;;
437 + esac
438 + set -v
439 +-h2py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/sys/stropts.h /usr/include/dlfcn.h
440 +-
441 ++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/sys/types.h /usr/include/netinet/in.h /usr/include/sys/stropts.h /usr/include/dlfcn.h
442 +--- Lib/plat-unixware7/regen
443 ++++ Lib/plat-unixware7/regen
444 +@@ -5,5 +5,5 @@
445 + exit 1;;
446 + esac
447 + set -v
448 +-h2py -i '(u_long)' /usr/include/netinet/in.h
449 +-h2py /usr/include/sys/stropts.h
450 ++python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
451 ++python$EXE ../../Tools/scripts/h2py.py /usr/include/sys/stropts.h
452 +--- Makefile.pre.in
453 ++++ Makefile.pre.in
454 +@@ -444,7 +444,7 @@
455 +
456 + # Default target
457 + all: build_all
458 +-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed
459 ++build_all: $(BUILDPYTHON) oldsharedmods sharedmods platformspecificmods gdbhooks Modules/_testembed
460 +
461 + # Compile a binary with gcc profile guided optimization.
462 + profile-opt:
463 +@@ -500,6 +500,32 @@
464 + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
465 + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
466 +
467 ++# Build the platform-specific modules
468 ++platformspecificmods: $(BUILDPYTHON) sharedmods
469 ++ @PLATDIR=$(PLATDIR); \
470 ++ if test ! -f $(srcdir)/Lib/$(PLATDIR)/regen; then \
471 ++ $(INSTALL) -d $(srcdir)/Lib/$(PLATDIR); \
472 ++ if test -f $(srcdir)/Lib/$${PLATDIR%?}/regen; then \
473 ++ cp $(srcdir)/Lib/$${PLATDIR%?}/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
474 ++ else \
475 ++ cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen; \
476 ++ fi \
477 ++ fi
478 ++ @EXE="$(BUILDEXE)"; export EXE; \
479 ++ PATH="`pwd`:$$PATH"; export PATH; \
480 ++ PYTHONPATH="`pwd`/Lib"; export PYTHONPATH; \
481 ++ if [ -n "$(MULTIARCH)" ]; then MULTIARCH=$(MULTIARCH); export MULTIARCH; fi; \
482 ++ if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; then \
483 ++ PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
484 ++ else \
485 ++ PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
486 ++ fi; export PYTHON_FOR_BUILD; \
487 ++ cd $(srcdir)/Lib/$(PLATDIR); \
488 ++ $(RUNSHARED) ./regen || exit 1; \
489 ++ for module in *.py; do \
490 ++ $(RUNSHARED) $(BUILDPYTHON) -c "with open('$$module', 'rb') as module: compile(module.read(), '$$module', 'exec')" || exit 1; \
491 ++ done
492 ++
493 + # Build static library
494 + # avoid long command lines, same as LIBRARY_OBJS
495 + $(LIBRARY): $(LIBRARY_OBJS)
496 +@@ -1074,7 +1100,7 @@
497 + unittest unittest/test unittest/test/testmock \
498 + venv venv/scripts venv/scripts/posix \
499 + curses pydoc_data $(MACHDEPS)
500 +-libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
501 ++libinstall: build_all $(srcdir)/Modules/xxmodule.c
502 + @for i in $(SCRIPTDIR) $(LIBDEST); \
503 + do \
504 + if test ! -d $(DESTDIR)$$i; then \
505 +@@ -1157,23 +1183,6 @@
506 + -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
507 + $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
508 +
509 +-# Create the PLATDIR source directory, if one wasn't distributed..
510 +-$(srcdir)/Lib/$(PLATDIR):
511 +- mkdir $(srcdir)/Lib/$(PLATDIR)
512 +- cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
513 +- export PATH; PATH="`pwd`:$$PATH"; \
514 +- export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
515 +- export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
516 +- export EXE; EXE="$(BUILDEXE)"; \
517 +- if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
518 +- export PYTHON_FOR_BUILD; \
519 +- if [ "$(BUILD_GNU_TYPE)" = "$(HOST_GNU_TYPE)" ]; then \
520 +- PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
521 +- else \
522 +- PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
523 +- fi; \
524 +- cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
525 +-
526 + python-config: $(srcdir)/Misc/python-config.in
527 + # Substitution happens here, as the completely-expanded BINDIR
528 + # is not available in configure
529 +@@ -1476,7 +1485,7 @@
530 + Python/thread.o: @THREADHEADERS@
531 +
532 + # Declare targets that aren't real files
533 +-.PHONY: all build_all sharedmods oldsharedmods test quicktest
534 ++.PHONY: all build_all sharedmods oldsharedmods platformspecificmods test quicktest
535 + .PHONY: install altinstall oldsharedinstall bininstall altbininstall
536 + .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
537 + .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
538
539 diff --git a/dev-lang/python/files/3.3/21_all_distutils_c++.patch b/dev-lang/python/files/3.3/21_all_distutils_c++.patch
540 new file mode 100644
541 index 0000000..1f6c19a
542 --- /dev/null
543 +++ b/dev-lang/python/files/3.3/21_all_distutils_c++.patch
544 @@ -0,0 +1,271 @@
545 +http://bugs.python.org/issue1222585
546 +
547 +--- Lib/distutils/cygwinccompiler.py
548 ++++ Lib/distutils/cygwinccompiler.py
549 +@@ -124,8 +124,10 @@
550 + # dllwrap 2.10.90 is buggy
551 + if self.ld_version >= "2.10.90":
552 + self.linker_dll = "gcc"
553 ++ self.linker_dll_cxx = "g++"
554 + else:
555 + self.linker_dll = "dllwrap"
556 ++ self.linker_dll_cxx = "dllwrap"
557 +
558 + # ld_version >= "2.13" support -shared so use it instead of
559 + # -mdll -static
560 +@@ -139,9 +141,13 @@
561 + self.set_executables(compiler='gcc -mcygwin -O -Wall',
562 + compiler_so='gcc -mcygwin -mdll -O -Wall',
563 + compiler_cxx='g++ -mcygwin -O -Wall',
564 ++ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
565 + linker_exe='gcc -mcygwin',
566 + linker_so=('%s -mcygwin %s' %
567 +- (self.linker_dll, shared_option)))
568 ++ (self.linker_dll, shared_option)),
569 ++ linker_exe_cxx='g++ -mcygwin',
570 ++ linker_so_cxx=('%s -mcygwin %s' %
571 ++ (self.linker_dll_cxx, shared_option)))
572 +
573 + # cygwin and mingw32 need different sets of libraries
574 + if self.gcc_version == "2.91.57":
575 +@@ -165,8 +171,12 @@
576 + raise CompileError(msg)
577 + else: # for other files use the C-compiler
578 + try:
579 +- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
580 +- extra_postargs)
581 ++ if self.detect_language(src) == 'c++':
582 ++ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
583 ++ extra_postargs)
584 ++ else:
585 ++ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
586 ++ extra_postargs)
587 + except DistutilsExecError as msg:
588 + raise CompileError(msg)
589 +
590 +@@ -302,9 +312,14 @@
591 + self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
592 + compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
593 + compiler_cxx='g++%s -O -Wall' % no_cygwin,
594 ++ compiler_so_cxx='g++%s -mdll -O -Wall' % no_cygwin,
595 + linker_exe='gcc%s' % no_cygwin,
596 + linker_so='%s%s %s %s'
597 + % (self.linker_dll, no_cygwin,
598 ++ shared_option, entry_point),
599 ++ linker_exe_cxx='g++%s' % no_cygwin,
600 ++ linker_so_cxx='%s%s %s %s'
601 ++ % (self.linker_dll_cxx, no_cygwin,
602 + shared_option, entry_point))
603 + # Maybe we should also append -mthreads, but then the finished
604 + # dlls need another dll (mingwm10.dll see Mingw32 docs)
605 +--- Lib/distutils/emxccompiler.py
606 ++++ Lib/distutils/emxccompiler.py
607 +@@ -63,8 +63,12 @@
608 + # XXX optimization, warnings etc. should be customizable.
609 + self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
610 + compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
611 ++ compiler_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
612 ++ compiler_so_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
613 + linker_exe='gcc -Zomf -Zmt -Zcrtdll',
614 +- linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
615 ++ linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll',
616 ++ linker_exe_cxx='g++ -Zomf -Zmt -Zcrtdll',
617 ++ linker_so_cxx='g++ -Zomf -Zmt -Zcrtdll -Zdll')
618 +
619 + # want the gcc library statically linked (so that we don't have
620 + # to distribute a version dependent on the compiler we have)
621 +@@ -81,8 +85,12 @@
622 + raise CompileError(msg)
623 + else: # for other files use the C-compiler
624 + try:
625 +- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
626 +- extra_postargs)
627 ++ if self.detect_language(src) == 'c++':
628 ++ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
629 ++ extra_postargs)
630 ++ else:
631 ++ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
632 ++ extra_postargs)
633 + except DistutilsExecError as msg:
634 + raise CompileError(msg)
635 +
636 +--- Lib/distutils/sysconfig.py
637 ++++ Lib/distutils/sysconfig.py
638 +@@ -191,9 +191,12 @@
639 + _osx_support.customize_compiler(_config_vars)
640 + _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
641 +
642 +- (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
643 +- get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
644 +- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
645 ++ (cc, cxx, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, ar_flags) = \
646 ++ get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
647 ++ 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
648 ++
649 ++ cflags = ''
650 ++ cxxflags = ''
651 +
652 + if 'CC' in os.environ:
653 + newcc = os.environ['CC']
654 +@@ -208,19 +211,27 @@
655 + cxx = os.environ['CXX']
656 + if 'LDSHARED' in os.environ:
657 + ldshared = os.environ['LDSHARED']
658 ++ if 'LDCXXSHARED' in os.environ:
659 ++ ldcxxshared = os.environ['LDCXXSHARED']
660 + if 'CPP' in os.environ:
661 + cpp = os.environ['CPP']
662 + else:
663 + cpp = cc + " -E" # not always
664 + if 'LDFLAGS' in os.environ:
665 + ldshared = ldshared + ' ' + os.environ['LDFLAGS']
666 ++ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
667 + if 'CFLAGS' in os.environ:
668 +- cflags = opt + ' ' + os.environ['CFLAGS']
669 ++ cflags = os.environ['CFLAGS']
670 + ldshared = ldshared + ' ' + os.environ['CFLAGS']
671 ++ if 'CXXFLAGS' in os.environ:
672 ++ cxxflags = os.environ['CXXFLAGS']
673 ++ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
674 + if 'CPPFLAGS' in os.environ:
675 + cpp = cpp + ' ' + os.environ['CPPFLAGS']
676 + cflags = cflags + ' ' + os.environ['CPPFLAGS']
677 ++ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
678 + ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
679 ++ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
680 + if 'AR' in os.environ:
681 + ar = os.environ['AR']
682 + if 'ARFLAGS' in os.environ:
683 +@@ -229,13 +240,17 @@
684 + archiver = ar + ' ' + ar_flags
685 +
686 + cc_cmd = cc + ' ' + cflags
687 ++ cxx_cmd = cxx + ' ' + cxxflags
688 + compiler.set_executables(
689 + preprocessor=cpp,
690 + compiler=cc_cmd,
691 + compiler_so=cc_cmd + ' ' + ccshared,
692 +- compiler_cxx=cxx,
693 ++ compiler_cxx=cxx_cmd,
694 ++ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
695 + linker_so=ldshared,
696 + linker_exe=cc,
697 ++ linker_so_cxx=ldcxxshared,
698 ++ linker_exe_cxx=cxx,
699 + archiver=archiver)
700 +
701 + compiler.shared_lib_extension = shlib_suffix
702 +--- Lib/distutils/unixccompiler.py
703 ++++ Lib/distutils/unixccompiler.py
704 +@@ -52,14 +52,17 @@
705 + # are pretty generic; they will probably have to be set by an outsider
706 + # (eg. using information discovered by the sysconfig about building
707 + # Python extensions).
708 +- executables = {'preprocessor' : None,
709 +- 'compiler' : ["cc"],
710 +- 'compiler_so' : ["cc"],
711 +- 'compiler_cxx' : ["cc"],
712 +- 'linker_so' : ["cc", "-shared"],
713 +- 'linker_exe' : ["cc"],
714 +- 'archiver' : ["ar", "-cr"],
715 +- 'ranlib' : None,
716 ++ executables = {'preprocessor' : None,
717 ++ 'compiler' : ["cc"],
718 ++ 'compiler_so' : ["cc"],
719 ++ 'compiler_cxx' : ["c++"],
720 ++ 'compiler_so_cxx' : ["c++"],
721 ++ 'linker_so' : ["cc", "-shared"],
722 ++ 'linker_exe' : ["cc"],
723 ++ 'linker_so_cxx' : ["c++", "-shared"],
724 ++ 'linker_exe_cxx' : ["c++"],
725 ++ 'archiver' : ["ar", "-cr"],
726 ++ 'ranlib' : None,
727 + }
728 +
729 + if sys.platform[:6] == "darwin":
730 +@@ -108,12 +111,19 @@
731 +
732 + def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
733 + compiler_so = self.compiler_so
734 ++ compiler_so_cxx = self.compiler_so_cxx
735 + if sys.platform == 'darwin':
736 + compiler_so = _osx_support.compiler_fixup(compiler_so,
737 + cc_args + extra_postargs)
738 ++ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
739 ++ cc_args + extra_postargs)
740 + try:
741 +- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
742 +- extra_postargs)
743 ++ if self.detect_language(src) == 'c++':
744 ++ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
745 ++ extra_postargs)
746 ++ else:
747 ++ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
748 ++ extra_postargs)
749 + except DistutilsExecError as msg:
750 + raise CompileError(msg)
751 +
752 +@@ -171,22 +181,16 @@
753 + ld_args.extend(extra_postargs)
754 + self.mkpath(os.path.dirname(output_filename))
755 + try:
756 +- if target_desc == CCompiler.EXECUTABLE:
757 +- linker = self.linker_exe[:]
758 ++ if target_lang == "c++":
759 ++ if target_desc == CCompiler.EXECUTABLE:
760 ++ linker = self.linker_exe_cxx[:]
761 ++ else:
762 ++ linker = self.linker_so_cxx[:]
763 + else:
764 +- linker = self.linker_so[:]
765 +- if target_lang == "c++" and self.compiler_cxx:
766 +- # skip over environment variable settings if /usr/bin/env
767 +- # is used to set up the linker's environment.
768 +- # This is needed on OSX. Note: this assumes that the
769 +- # normal and C++ compiler have the same environment
770 +- # settings.
771 +- i = 0
772 +- if os.path.basename(linker[0]) == "env":
773 +- i = 1
774 +- while '=' in linker[i]:
775 +- i += 1
776 +- linker[i] = self.compiler_cxx[i]
777 ++ if target_desc == CCompiler.EXECUTABLE:
778 ++ linker = self.linker_exe[:]
779 ++ else:
780 ++ linker = self.linker_so[:]
781 +
782 + if sys.platform == 'darwin':
783 + linker = _osx_support.compiler_fixup(linker, ld_args)
784 +--- Lib/_osx_support.py
785 ++++ Lib/_osx_support.py
786 +@@ -14,13 +14,13 @@
787 + # configuration variables that may contain universal build flags,
788 + # like "-arch" or "-isdkroot", that may need customization for
789 + # the user environment
790 +-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
791 +- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
792 +- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
793 +- 'PY_CORE_CFLAGS')
794 ++_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
795 ++ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
796 ++ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
797 ++ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
798 +
799 + # configuration variables that may contain compiler calls
800 +-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
801 ++_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
802 +
803 + # prefix added to original configuration variable names
804 + _INITPRE = '_OSX_SUPPORT_INITIAL_'
805 +--- Makefile.pre.in
806 ++++ Makefile.pre.in
807 +@@ -496,7 +496,7 @@
808 + *\ -s*|s*) quiet="-q";; \
809 + *) quiet="";; \
810 + esac; \
811 +- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
812 ++ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
813 + _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
814 + $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
815 +
816
817 diff --git a/dev-lang/python/files/3.3/22_all_tests_environment.patch b/dev-lang/python/files/3.3/22_all_tests_environment.patch
818 new file mode 100644
819 index 0000000..edb3351
820 --- /dev/null
821 +++ b/dev-lang/python/files/3.3/22_all_tests_environment.patch
822 @@ -0,0 +1,192 @@
823 +http://bugs.python.org/issue1674555
824 +
825 +--- Lib/site.py
826 ++++ Lib/site.py
827 +@@ -587,8 +587,9 @@
828 + known_paths = venv(known_paths)
829 + if ENABLE_USER_SITE is None:
830 + ENABLE_USER_SITE = check_enableusersite()
831 +- known_paths = addusersitepackages(known_paths)
832 +- known_paths = addsitepackages(known_paths)
833 ++ if os.environ.get("_PYTHONNOSITEPACKAGES") is None:
834 ++ known_paths = addusersitepackages(known_paths)
835 ++ known_paths = addsitepackages(known_paths)
836 + if sys.platform == 'os2emx':
837 + setBEGINLIBPATH()
838 + setquit()
839 +--- Lib/test/regrtest.py
840 ++++ Lib/test/regrtest.py
841 +@@ -188,6 +188,7 @@
842 + import unittest
843 + import warnings
844 + from inspect import isabstract
845 ++from subprocess import Popen, PIPE
846 +
847 + try:
848 + import threading
849 +@@ -578,6 +579,62 @@
850 + support.use_resources = use_resources
851 + save_modules = sys.modules.keys()
852 +
853 ++ opt_args = support.args_from_interpreter_flags()
854 ++ base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
855 ++ debug_output_pat = re.compile(r"\[\d+ refs\]$")
856 ++
857 ++ def get_args_tuple(test, verbose, quiet, huntrleaks, debug, use_resources,
858 ++ output_on_failure, failfast, match_tests, timeout):
859 ++ return (
860 ++ (test, verbose, quiet),
861 ++ dict(huntrleaks=huntrleaks, debug=debug,
862 ++ use_resources=use_resources,
863 ++ output_on_failure=output_on_failure, failfast=failfast,
864 ++ match_tests=match_tests, timeout=timeout)
865 ++ )
866 ++
867 ++ def _runtest(test, verbose, quiet, huntrleaks=False, debug=False,
868 ++ use_resources=None, output_on_failure=False, failfast=False,
869 ++ match_tests=None, timeout=None):
870 ++ if test == "test_site":
871 ++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks, debug,
872 ++ use_resources, output_on_failure,
873 ++ failfast, match_tests, timeout)
874 ++ env = os.environ.copy()
875 ++ try:
876 ++ del env["_PYTHONNOSITEPACKAGES"]
877 ++ except KeyError:
878 ++ pass
879 ++ popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)],
880 ++ stdout=PIPE, stderr=PIPE,
881 ++ universal_newlines=True,
882 ++ close_fds=(os.name != 'nt'),
883 ++ env=env)
884 ++ stdout, stderr = popen.communicate()
885 ++ retcode = popen.wait()
886 ++ # Strip last refcount output line if it exists, since it
887 ++ # comes from the shutdown of the interpreter in the subcommand.
888 ++ stderr = debug_output_pat.sub("", stderr)
889 ++ stdout, _, result = stdout.strip().rpartition("\n")
890 ++ if retcode != 0:
891 ++ result = (CHILD_ERROR, "Exit code %s" % retcode)
892 ++ else:
893 ++ result = json.loads(result)
894 ++ if stdout:
895 ++ print(stdout)
896 ++ if stderr:
897 ++ print(stderr, file=sys.stderr)
898 ++ if result[0] == INTERRUPTED:
899 ++ assert result[1] == 'KeyboardInterrupt'
900 ++ raise KeyboardInterrupt
901 ++ return result
902 ++ else:
903 ++ return runtest(test, verbose, quiet, huntrleaks=huntrleaks,
904 ++ debug=debug, use_resources=use_resources,
905 ++ output_on_failure=output_on_failure,
906 ++ failfast=failfast, match_tests=match_tests,
907 ++ timeout=timeout)
908 ++
909 + def accumulate_result(test, result):
910 + ok, test_time = result
911 + test_times.append((test_time, test))
912 +@@ -615,12 +672,8 @@
913 + print("Multiprocess option requires thread support")
914 + sys.exit(2)
915 + from queue import Queue
916 +- from subprocess import Popen, PIPE
917 +- debug_output_pat = re.compile(r"\[\d+ refs\]$")
918 + output = Queue()
919 + pending = MultiprocessTests(tests)
920 +- opt_args = support.args_from_interpreter_flags()
921 +- base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
922 + def work():
923 + # A worker thread.
924 + try:
925 +@@ -630,13 +683,9 @@
926 + except StopIteration:
927 + output.put((None, None, None, None))
928 + return
929 +- args_tuple = (
930 +- (test, verbose, quiet),
931 +- dict(huntrleaks=huntrleaks, use_resources=use_resources,
932 +- debug=debug, output_on_failure=verbose3,
933 +- timeout=timeout, failfast=failfast,
934 +- match_tests=match_tests)
935 +- )
936 ++ args_tuple = get_args_tuple(test, verbose, quiet, huntrleaks,
937 ++ debug, use_resources, verbose3,
938 ++ failfast, match_tests, timeout)
939 + # -E is needed by some tests, e.g. test_import
940 + # Running the child from the same working directory ensures
941 + # that TEMPDIR for the child is the same when
942 +@@ -707,14 +756,14 @@
943 + if trace:
944 + # If we're tracing code coverage, then we don't exit with status
945 + # if on a false return value from main.
946 +- tracer.runctx('runtest(test, verbose, quiet, timeout=timeout)',
947 ++ tracer.runctx('_runtest(test, verbose, quiet, timeout=timeout)',
948 + globals=globals(), locals=vars())
949 + else:
950 + try:
951 +- result = runtest(test, verbose, quiet, huntrleaks, debug,
952 +- output_on_failure=verbose3,
953 +- timeout=timeout, failfast=failfast,
954 +- match_tests=match_tests)
955 ++ result = _runtest(test, verbose, quiet, huntrleaks, debug,
956 ++ output_on_failure=verbose3,
957 ++ timeout=timeout, failfast=failfast,
958 ++ match_tests=match_tests)
959 + accumulate_result(test, result)
960 + except KeyboardInterrupt:
961 + interrupted = True
962 +@@ -785,7 +834,7 @@
963 + sys.stdout.flush()
964 + try:
965 + verbose = True
966 +- ok = runtest(test, True, quiet, huntrleaks, debug, timeout=timeout)
967 ++ ok = _runtest(test, True, quiet, huntrleaks, debug, timeout=timeout)
968 + except KeyboardInterrupt:
969 + # print a newline separate from the ^C
970 + print()
971 +@@ -1182,8 +1231,9 @@
972 + for name, get, restore in self.resource_info():
973 + current = get()
974 + original = saved_values.pop(name)
975 +- # Check for changes to the resource's value
976 +- if current != original:
977 ++ # Check for changes to the resource's value. test_site is always run
978 ++ # in a subprocess and is allowed to change os.environ and sys.path.
979 ++ if current != original and self.testname != "test_site":
980 + self.changed = True
981 + restore(original)
982 + if not self.quiet:
983 +--- Lib/test/test_site.py
984 ++++ Lib/test/test_site.py
985 +@@ -8,6 +8,7 @@
986 + import test.support
987 + from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
988 + import builtins
989 ++import imp
990 + import os
991 + import sys
992 + import re
993 +@@ -26,6 +27,10 @@
994 +
995 + import site
996 +
997 ++if "_PYTHONNOSITEPACKAGES" in os.environ:
998 ++ del os.environ["_PYTHONNOSITEPACKAGES"]
999 ++ imp.reload(site)
1000 ++
1001 + if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
1002 + # need to add user site directory for tests
1003 + os.makedirs(site.USER_SITE)
1004 +--- Makefile.pre.in
1005 ++++ Makefile.pre.in
1006 +@@ -883,7 +883,7 @@
1007 + ######################################################################
1008 +
1009 + TESTOPTS= $(EXTRATESTOPTS)
1010 +-TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
1011 ++TESTPYTHON= _PYTHONNOSITEPACKAGES=1 $(RUNSHARED) ./$(BUILDPYTHON) $(TESTPYTHONOPTS)
1012 + TESTRUNNER= $(TESTPYTHON) $(srcdir)/Tools/scripts/run_tests.py
1013 + TESTTIMEOUT= 3600
1014 +
1015
1016 diff --git a/dev-lang/python/files/3.3/23_all_h2py_encoding.patch b/dev-lang/python/files/3.3/23_all_h2py_encoding.patch
1017 new file mode 100644
1018 index 0000000..d594f56
1019 --- /dev/null
1020 +++ b/dev-lang/python/files/3.3/23_all_h2py_encoding.patch
1021 @@ -0,0 +1,173 @@
1022 +http://bugs.python.org/issue13032
1023 +
1024 +--- Tools/scripts/h2py.py
1025 ++++ Tools/scripts/h2py.py
1026 +@@ -23,36 +23,36 @@
1027 +
1028 + import sys, re, getopt, os
1029 +
1030 +-p_define = re.compile('^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
1031 ++p_define = re.compile(b'^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+')
1032 +
1033 + p_macro = re.compile(
1034 +- '^[\t ]*#[\t ]*define[\t ]+'
1035 +- '([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
1036 ++ b'^[\t ]*#[\t ]*define[\t ]+'
1037 ++ b'([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+')
1038 +
1039 +-p_include = re.compile('^[\t ]*#[\t ]*include[\t ]+<([a-zA-Z0-9_/\.]+)')
1040 ++p_include = re.compile(b'^[\t ]*#[\t ]*include[\t ]+<([a-zA-Z0-9_/\.]+)')
1041 +
1042 +-p_comment = re.compile(r'/\*([^*]+|\*+[^/])*(\*+/)?')
1043 +-p_cpp_comment = re.compile('//.*')
1044 ++p_comment = re.compile(br'/\*([^*]+|\*+[^/])*(\*+/)?')
1045 ++p_cpp_comment = re.compile(b'//.*')
1046 +
1047 + ignores = [p_comment, p_cpp_comment]
1048 +
1049 +-p_char = re.compile(r"'(\\.[^\\]*|[^\\])'")
1050 ++p_char = re.compile(br"'(\\.[^\\]*|[^\\])'")
1051 +
1052 +-p_hex = re.compile(r"0x([0-9a-fA-F]+)L?")
1053 ++p_hex = re.compile(br"0x([0-9a-fA-F]+)L?")
1054 +
1055 + filedict = {}
1056 + importable = {}
1057 +
1058 + try:
1059 +- searchdirs=os.environ['include'].split(';')
1060 ++ searchdirs=os.environb[b'include'].split(b';')
1061 + except KeyError:
1062 + try:
1063 +- searchdirs=os.environ['INCLUDE'].split(';')
1064 ++ searchdirs=os.environb[b'INCLUDE'].split(b';')
1065 + except KeyError:
1066 +- searchdirs=['/usr/include']
1067 ++ searchdirs=[b'/usr/include']
1068 + try:
1069 +- searchdirs.insert(0, os.path.join('/usr/include',
1070 +- os.environ['MULTIARCH']))
1071 ++ searchdirs.insert(0, os.path.join(b'/usr/include',
1072 ++ os.environb[b'MULTIARCH']))
1073 + except KeyError:
1074 + pass
1075 +
1076 +@@ -61,22 +61,23 @@
1077 + opts, args = getopt.getopt(sys.argv[1:], 'i:')
1078 + for o, a in opts:
1079 + if o == '-i':
1080 +- ignores.append(re.compile(a))
1081 ++ ignores.append(re.compile(a.encode()))
1082 + if not args:
1083 + args = ['-']
1084 + for filename in args:
1085 + if filename == '-':
1086 + sys.stdout.write('# Generated by h2py from stdin\n')
1087 +- process(sys.stdin, sys.stdout)
1088 ++ process(sys.stdin.buffer, sys.stdout.buffer)
1089 + else:
1090 +- fp = open(filename, 'r')
1091 ++ filename = filename.encode()
1092 ++ fp = open(filename, 'rb')
1093 + outfile = os.path.basename(filename)
1094 +- i = outfile.rfind('.')
1095 ++ i = outfile.rfind(b'.')
1096 + if i > 0: outfile = outfile[:i]
1097 + modname = outfile.upper()
1098 +- outfile = modname + '.py'
1099 +- outfp = open(outfile, 'w')
1100 +- outfp.write('# Generated by h2py from %s\n' % filename)
1101 ++ outfile = modname + b'.py'
1102 ++ outfp = open(outfile, 'wb')
1103 ++ outfp.write(b'# Generated by h2py from ' + filename + b'\n')
1104 + filedict = {}
1105 + for dir in searchdirs:
1106 + if filename[:len(dir)] == dir:
1107 +@@ -90,9 +91,9 @@
1108 + def pytify(body):
1109 + # replace ignored patterns by spaces
1110 + for p in ignores:
1111 +- body = p.sub(' ', body)
1112 ++ body = p.sub(b' ', body)
1113 + # replace char literals by ord(...)
1114 +- body = p_char.sub("ord('\\1')", body)
1115 ++ body = p_char.sub(b"ord('\\1')", body)
1116 + # Compute negative hexadecimal constants
1117 + start = 0
1118 + UMAX = 2*(sys.maxsize+1)
1119 +@@ -103,7 +104,7 @@
1120 + val = int(body[slice(*m.span(1))], 16)
1121 + if val > sys.maxsize:
1122 + val -= UMAX
1123 +- body = body[:s] + "(" + str(val) + ")" + body[e:]
1124 ++ body = body[:s] + b"(" + str(val).encode() + b")" + body[e:]
1125 + start = s + 1
1126 + return body
1127 +
1128 +@@ -116,7 +117,7 @@
1129 + match = p_define.match(line)
1130 + if match:
1131 + # gobble up continuation lines
1132 +- while line[-2:] == '\\\n':
1133 ++ while line[-2:] == b'\\\n':
1134 + nextline = fp.readline()
1135 + if not nextline: break
1136 + lineno = lineno + 1
1137 +@@ -125,11 +126,11 @@
1138 + body = line[match.end():]
1139 + body = pytify(body)
1140 + ok = 0
1141 +- stmt = '%s = %s\n' % (name, body.strip())
1142 ++ stmt = name + b' = ' + body.strip() + b'\n'
1143 + try:
1144 + exec(stmt, env)
1145 + except:
1146 +- sys.stderr.write('Skipping: %s' % stmt)
1147 ++ sys.stderr.buffer.write(b'Skipping: ' + stmt)
1148 + else:
1149 + outfp.write(stmt)
1150 + match = p_macro.match(line)
1151 +@@ -137,11 +138,11 @@
1152 + macro, arg = match.group(1, 2)
1153 + body = line[match.end():]
1154 + body = pytify(body)
1155 +- stmt = 'def %s(%s): return %s\n' % (macro, arg, body)
1156 ++ stmt = b'def ' + macro + b'(' + arg + b'): return ' + body + b'\n'
1157 + try:
1158 + exec(stmt, env)
1159 + except:
1160 +- sys.stderr.write('Skipping: %s' % stmt)
1161 ++ sys.stderr.buffer.write(b'Skipping: ' + stmt)
1162 + else:
1163 + outfp.write(stmt)
1164 + match = p_include.match(line)
1165 +@@ -150,23 +151,24 @@
1166 + a, b = regs[1]
1167 + filename = line[a:b]
1168 + if filename in importable:
1169 +- outfp.write('from %s import *\n' % importable[filename])
1170 ++ outfp.write(b'from ' + importable[filename] + b' import *\n')
1171 + elif filename not in filedict:
1172 + filedict[filename] = None
1173 + inclfp = None
1174 + for dir in searchdirs:
1175 + try:
1176 +- inclfp = open(dir + '/' + filename)
1177 ++ inclfp = open(dir + b'/' + filename, 'rb')
1178 + break
1179 + except IOError:
1180 + pass
1181 + if inclfp:
1182 + outfp.write(
1183 +- '\n# Included from %s\n' % filename)
1184 ++ b'\n# Included from ' + filename + b'\n')
1185 + process(inclfp, outfp, env)
1186 ++ inclfp.close()
1187 + else:
1188 +- sys.stderr.write('Warning - could not find file %s\n' %
1189 +- filename)
1190 ++ sys.stderr.buffer.write(b'Warning - could not find file ' +
1191 ++ filename + b'\n')
1192 +
1193 + if __name__ == '__main__':
1194 + main()
1195
1196 diff --git a/dev-lang/python/files/3.3/24_all_sqlite-3.8.4.patch b/dev-lang/python/files/3.3/24_all_sqlite-3.8.4.patch
1197 new file mode 100644
1198 index 0000000..d6af2eb
1199 --- /dev/null
1200 +++ b/dev-lang/python/files/3.3/24_all_sqlite-3.8.4.patch
1201 @@ -0,0 +1,14 @@
1202 +http://bugs.python.org/issue20901
1203 +http://hg.python.org/cpython/rev/dbc9e3ed5e9f
1204 +
1205 +--- Lib/sqlite3/test/hooks.py
1206 ++++ Lib/sqlite3/test/hooks.py
1207 +@@ -162,7 +162,7 @@
1208 + create table bar (a, b)
1209 + """)
1210 + second_count = len(progress_calls)
1211 +- self.assertGreater(first_count, second_count)
1212 ++ self.assertGreaterEqual(first_count, second_count)
1213 +
1214 + def CheckCancelOperation(self):
1215 + """
1216
1217 diff --git a/dev-lang/python/files/3.3/61_all_process_data.patch b/dev-lang/python/files/3.3/61_all_process_data.patch
1218 new file mode 100644
1219 index 0000000..b7738c7
1220 --- /dev/null
1221 +++ b/dev-lang/python/files/3.3/61_all_process_data.patch
1222 @@ -0,0 +1,166 @@
1223 +GENTOO_PYTHON_PROCESS_NAME environmental variable is set by python-wrapper and wrapper scripts generated by
1224 +python_generate_wrapper_scripts() and specifies process name.
1225 +GENTOO_PYTHON_WRAPPER_SCRIPT_PATH environmental variable is set by wrapper scripts generated by
1226 +python_generate_wrapper_scripts() and specifies sys.argv[0] in target executables.
1227 +GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable is set by wrapper scripts generated by
1228 +python_generate_wrapper_scripts() and specifies paths to actually executed scripts.
1229 +GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION environmental variable is used by wrapper scripts generated by
1230 +python_generate_wrapper_scripts() to check if Python supports GENTOO_PYTHON_TARGET_SCRIPT_PATH environmental variable.
1231 +
1232 +--- Modules/main.c
1233 ++++ Modules/main.c
1234 +@@ -331,6 +331,7 @@
1235 + int version = 0;
1236 + int saw_unbuffered_flag = 0;
1237 + PyCompilerFlags cf;
1238 ++ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
1239 +
1240 + cf.cf_flags = 0;
1241 +
1242 +@@ -551,7 +552,17 @@
1243 + filename = argv[_PyOS_optind];
1244 +
1245 + #else
1246 +- filename = argv[_PyOS_optind];
1247 ++ if (target_script_name != NULL && *target_script_name != '\0') {
1248 ++ size_t length = strlen(target_script_name);
1249 ++ wchar_t *wcs_target_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
1250 ++ char *old_locale = setlocale(LC_CTYPE, NULL);
1251 ++ setlocale(LC_CTYPE, "");
1252 ++ if (mbstowcs(wcs_target_script_name, target_script_name, length) >= 0)
1253 ++ filename = wcs_target_script_name;
1254 ++ setlocale(LC_CTYPE, old_locale);
1255 ++ }
1256 ++ if (filename == NULL)
1257 ++ filename = argv[_PyOS_optind];
1258 + #endif
1259 + }
1260 +
1261 +--- Modules/posixmodule.c
1262 ++++ Modules/posixmodule.c
1263 +@@ -1157,6 +1157,10 @@
1264 + char *p = strchr(*e, '=');
1265 + if (p == NULL)
1266 + continue;
1267 ++ if ((strlen("GENTOO_PYTHON_PROCESS_NAME") == (int)(p-*e) && strncmp("GENTOO_PYTHON_PROCESS_NAME", *e, (int)(p-*e)) == 0) ||
1268 ++ (strlen("GENTOO_PYTHON_TARGET_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_TARGET_SCRIPT_PATH", *e, (int)(p-*e)) == 0) ||
1269 ++ (strlen("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH") == (int)(p-*e) && strncmp("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH", *e, (int)(p-*e)) == 0))
1270 ++ continue;
1271 + k = PyBytes_FromStringAndSize(*e, (int)(p-*e));
1272 + if (k == NULL) {
1273 + PyErr_Clear();
1274 +--- Modules/python.c
1275 ++++ Modules/python.c
1276 +@@ -7,6 +7,14 @@
1277 + #include <floatingpoint.h>
1278 + #endif
1279 +
1280 ++#ifdef __linux__
1281 ++#include <linux/prctl.h>
1282 ++#include <sys/prctl.h>
1283 ++#ifndef PR_SET_NAME
1284 ++#define PR_SET_NAME 15
1285 ++#endif
1286 ++#endif
1287 ++
1288 + #ifdef MS_WINDOWS
1289 + int
1290 + wmain(int argc, wchar_t **argv)
1291 +@@ -18,6 +26,11 @@
1292 + int
1293 + main(int argc, char **argv)
1294 + {
1295 ++ if (getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION")) {
1296 ++ printf("GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n");
1297 ++ return 0;
1298 ++ }
1299 ++
1300 + wchar_t **argv_copy;
1301 + /* We need a second copy, as Python might modify the first one. */
1302 + wchar_t **argv_copy2;
1303 +@@ -59,6 +72,16 @@
1304 +
1305 + setlocale(LC_ALL, oldloc);
1306 + free(oldloc);
1307 ++
1308 ++#ifdef __linux__
1309 ++ char *process_name = getenv("GENTOO_PYTHON_PROCESS_NAME");
1310 ++#ifdef HAVE_UNSETENV
1311 ++ unsetenv("GENTOO_PYTHON_PROCESS_NAME");
1312 ++#endif
1313 ++ if (process_name != NULL && *process_name != '\0')
1314 ++ prctl(PR_SET_NAME, process_name);
1315 ++#endif
1316 ++
1317 + res = Py_Main(argc, argv_copy);
1318 + for (i = 0; i < argc; i++) {
1319 + PyMem_Free(argv_copy2[i]);
1320 +--- Python/sysmodule.c
1321 ++++ Python/sysmodule.c
1322 +@@ -1778,6 +1778,10 @@
1323 + makeargvobject(int argc, wchar_t **argv)
1324 + {
1325 + PyObject *av;
1326 ++ char *wrapper_script_name = getenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH");
1327 ++#ifdef HAVE_UNSETENV
1328 ++ unsetenv("GENTOO_PYTHON_WRAPPER_SCRIPT_PATH");
1329 ++#endif
1330 + if (argc <= 0 || argv == NULL) {
1331 + /* Ensure at least one (empty) argument is seen */
1332 + static wchar_t *empty_argv[1] = {L""};
1333 +@@ -1802,7 +1806,16 @@
1334 + } else
1335 + v = PyUnicode_FromString(argv[i]);
1336 + #else
1337 +- PyObject *v = PyUnicode_FromWideChar(argv[i], -1);
1338 ++ PyObject *v = NULL;
1339 ++ if (i == 0 && wrapper_script_name != NULL && *wrapper_script_name != '\0') {
1340 ++ size_t length = strlen(wrapper_script_name);
1341 ++ wchar_t *wcs_wrapper_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
1342 ++ if (mbstowcs(wcs_wrapper_script_name, wrapper_script_name, length) >= 0)
1343 ++ v = PyUnicode_FromWideChar(wcs_wrapper_script_name, -1);
1344 ++ free(wcs_wrapper_script_name);
1345 ++ }
1346 ++ if (v == NULL)
1347 ++ v = PyUnicode_FromWideChar(argv[i], -1);
1348 + #endif
1349 + if (v == NULL) {
1350 + Py_DECREF(av);
1351 +@@ -1822,7 +1835,12 @@
1352 + static void
1353 + sys_update_path(int argc, wchar_t **argv)
1354 + {
1355 +- wchar_t *argv0;
1356 ++ char *target_script_name = getenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
1357 ++#ifdef HAVE_UNSETENV
1358 ++ unsetenv("GENTOO_PYTHON_TARGET_SCRIPT_PATH");
1359 ++#endif
1360 ++ wchar_t *wcs_target_script_name = NULL;
1361 ++ wchar_t *argv0 = NULL;
1362 + wchar_t *p = NULL;
1363 + Py_ssize_t n = 0;
1364 + PyObject *a;
1365 +@@ -1842,7 +1860,14 @@
1366 + if (path == NULL)
1367 + return;
1368 +
1369 +- argv0 = argv[0];
1370 ++ if (target_script_name != NULL && *target_script_name != '\0') {
1371 ++ size_t length = strlen(target_script_name);
1372 ++ wcs_target_script_name = (wchar_t *) calloc(length + 1, sizeof(wchar_t));
1373 ++ if (mbstowcs(wcs_target_script_name, target_script_name, length) >= 0)
1374 ++ argv0 = wcs_target_script_name;
1375 ++ }
1376 ++ if (argv0 == NULL)
1377 ++ argv0 = argv[0];
1378 +
1379 + #ifdef HAVE_READLINK
1380 + if (_HAVE_SCRIPT_ARGUMENT(argc, argv))
1381 +@@ -1919,6 +1944,7 @@
1382 + if (PyList_Insert(path, 0, a) < 0)
1383 + Py_FatalError("sys.path.insert(0) failed");
1384 + Py_DECREF(a);
1385 ++ free(wcs_target_script_name);
1386 + }
1387 +
1388 + void
1389
1390 diff --git a/dev-lang/python/files/python-3.3-CVE-2014-4616.patch b/dev-lang/python/files/python-3.3-CVE-2014-4616.patch
1391 new file mode 100644
1392 index 0000000..c67b2e5
1393 --- /dev/null
1394 +++ b/dev-lang/python/files/python-3.3-CVE-2014-4616.patch
1395 @@ -0,0 +1,52 @@
1396 +# HG changeset patch
1397 +# User Benjamin Peterson <benjamin@××××××.org>
1398 +# Date 1397441438 14400
1399 +# Node ID 50c07ed1743da9cd4540d83de0c30bd17aeb41b0
1400 +# Parent 218e28a935ab4494d05215c243e2129625a71893
1401 +in scan_once, prevent the reading of arbitrary memory when passed a negative index
1402 +
1403 +Bug reported by Guido Vranken.
1404 +
1405 +Index: Python-3.3.5/Lib/json/tests/test_decode.py
1406 +===================================================================
1407 +--- Python-3.3.5.orig/Lib/test/test_json/test_decode.py 2014-06-26 18:40:10.825269130 +0200
1408 ++++ Python-3.3.5/Lib/test/test_json/test_decode.py 2014-06-26 18:40:21.962323035 +0200
1409 +@@ -60,5 +60,10 @@
1410 + msg = 'escape'
1411 + self.assertRaisesRegexp(ValueError, msg, self.loads, s)
1412 +
1413 ++ def test_negative_index(self):
1414 ++ d = self.json.JSONDecoder()
1415 ++ self.assertRaises(ValueError, d.raw_decode, 'a'*42, -50000)
1416 ++ self.assertRaises(ValueError, d.raw_decode, u'a'*42, -50000)
1417 ++
1418 + class TestPyDecode(TestDecode, PyTest): pass
1419 + class TestCDecode(TestDecode, CTest): pass
1420 +Index: Python-3.3.5/Misc/ACKS
1421 +===================================================================
1422 +--- Python-3.3.5.orig/Misc/ACKS 2014-06-26 18:40:10.826269135 +0200
1423 ++++ Python-3.3.5/Misc/ACKS 2014-06-26 18:40:21.962323035 +0200
1424 +@@ -1085,6 +1085,7 @@
1425 + Frank Visser
1426 + Johannes Vogel
1427 + Alex Volkov
1428 ++Guido Vranken
1429 + Martijn Vries
1430 + Niki W. Waibel
1431 + Wojtek Walczak
1432 +Index: Python-3.3.5/Modules/_json.c
1433 +===================================================================
1434 +--- a/Modules/_json.c
1435 ++++ b/Modules/_json.c
1436 +@@ -975,7 +975,10 @@ scan_once_unicode(PyScannerObject *s, Py
1437 + kind = PyUnicode_KIND(pystr);
1438 + length = PyUnicode_GET_LENGTH(pystr);
1439 +
1440 +- if (idx >= length) {
1441 ++ if (idx < 0)
1442 ++ /* Compatibility with Python version. */
1443 ++ idx += length;
1444 ++ if (idx < 0 || idx >= length) {
1445 + PyErr_SetNone(PyExc_StopIteration);
1446 + return NULL;
1447 + }
1448
1449 diff --git a/dev-lang/python/files/python-3.3-libressl.patch b/dev-lang/python/files/python-3.3-libressl.patch
1450 new file mode 100644
1451 index 0000000..816704e
1452 --- /dev/null
1453 +++ b/dev-lang/python/files/python-3.3-libressl.patch
1454 @@ -0,0 +1,127 @@
1455 +From eed8d3b553e00e04c1f97c87ea02723630fb15a4 Mon Sep 17 00:00:00 2001
1456 +From: hasufell <hasufell@g.o>
1457 +Date: Sun, 20 Sep 2015 14:25:43 +0200
1458 +Subject: [PATCH] Backport upstream libressl patches to python-3.3
1459 +
1460 +https://hg.python.org/cpython/raw-rev/7f82f50fdad0
1461 +https://hg.python.org/cpython/raw-rev/4dac45f88d45
1462 +---
1463 + Lib/ssl.py | 7 ++++++-
1464 + Lib/test/test_ssl.py | 21 +++++++++++++--------
1465 + Modules/_ssl.c | 4 ++++
1466 + configure | 42 ++++++++++++++++++++++++++++++++++++++++++
1467 + configure.ac | 3 +++
1468 + pyconfig.h.in | 3 +++
1469 + 6 files changed, 71 insertions(+), 9 deletions(-)
1470 +
1471 +diff --git a/Lib/ssl.py b/Lib/ssl.py
1472 +index cd8d6b4..445ae87 100644
1473 +--- a/Lib/ssl.py
1474 ++++ b/Lib/ssl.py
1475 +@@ -78,7 +78,12 @@ try:
1476 + from _ssl import OP_SINGLE_ECDH_USE
1477 + except ImportError:
1478 + pass
1479 +-from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes
1480 ++from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes
1481 ++try:
1482 ++ from _ssl import RAND_egd
1483 ++except ImportError:
1484 ++ # LibreSSL does not provide RAND_egd
1485 ++ pass
1486 + from _ssl import (
1487 + SSL_ERROR_ZERO_RETURN,
1488 + SSL_ERROR_WANT_READ,
1489 +diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
1490 +index 9fc6027..879f791 100644
1491 +--- a/Lib/test/test_ssl.py
1492 ++++ b/Lib/test/test_ssl.py
1493 +@@ -130,8 +130,9 @@ class BasicSocketTests(unittest.TestCase):
1494 + self.assertRaises(ValueError, ssl.RAND_bytes, -5)
1495 + self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
1496 +
1497 +- self.assertRaises(TypeError, ssl.RAND_egd, 1)
1498 +- self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
1499 ++ if hasattr(ssl, 'RAND_egd'):
1500 ++ self.assertRaises(TypeError, ssl.RAND_egd, 1)
1501 ++ self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
1502 + ssl.RAND_add("this is a random string", 75.0)
1503 +
1504 + @unittest.skipUnless(os.name == 'posix', 'requires posix')
1505 +@@ -250,11 +251,11 @@ class BasicSocketTests(unittest.TestCase):
1506 + # Some sanity checks follow
1507 + # >= 0.9
1508 + self.assertGreaterEqual(n, 0x900000)
1509 +- # < 2.0
1510 +- self.assertLess(n, 0x20000000)
1511 ++ # < 3.0
1512 ++ self.assertLess(n, 0x30000000)
1513 + major, minor, fix, patch, status = t
1514 + self.assertGreaterEqual(major, 0)
1515 +- self.assertLess(major, 2)
1516 ++ self.assertLess(major, 3)
1517 + self.assertGreaterEqual(minor, 0)
1518 + self.assertLess(minor, 256)
1519 + self.assertGreaterEqual(fix, 0)
1520 +@@ -263,9 +264,13 @@ class BasicSocketTests(unittest.TestCase):
1521 + self.assertLessEqual(patch, 26)
1522 + self.assertGreaterEqual(status, 0)
1523 + self.assertLessEqual(status, 15)
1524 +- # Version string as returned by OpenSSL, the format might change
1525 +- self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
1526 +- (s, t))
1527 ++ # Version string as returned by {Open,Libre}SSL, the format might change
1528 ++ if "LibreSSL" in s:
1529 ++ self.assertTrue(s.startswith("LibreSSL {:d}.{:d}".format(major, minor)),
1530 ++ (s, t))
1531 ++ else:
1532 ++ self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
1533 ++ (s, t))
1534 +
1535 + @support.cpython_only
1536 + def test_refcycle(self):
1537 +diff --git a/Modules/_ssl.c b/Modules/_ssl.c
1538 +index 499e8ba..cb151ba 100644
1539 +--- a/Modules/_ssl.c
1540 ++++ b/Modules/_ssl.c
1541 +@@ -2559,6 +2559,7 @@ Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n\
1542 + It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
1543 + using the ssl() function.");
1544 +
1545 ++#ifdef HAVE_RAND_EGD
1546 + static PyObject *
1547 + PySSL_RAND_egd(PyObject *self, PyObject *args)
1548 + {
1549 +@@ -2586,6 +2587,7 @@ PyDoc_STRVAR(PySSL_RAND_egd_doc,
1550 + Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
1551 + Returns number of bytes read. Raises SSLError if connection to EGD\n\
1552 + fails or if it does not provide enough data to seed PRNG.");
1553 ++#endif /* HAVE_RAND_EGD */
1554 +
1555 + #endif /* HAVE_OPENSSL_RAND */
1556 +
1557 +@@ -2604,8 +2606,10 @@ static PyMethodDef PySSL_methods[] = {
1558 + PySSL_RAND_bytes_doc},
1559 + {"RAND_pseudo_bytes", PySSL_RAND_pseudo_bytes, METH_VARARGS,
1560 + PySSL_RAND_pseudo_bytes_doc},
1561 ++#ifdef HAVE_RAND_EGD
1562 + {"RAND_egd", PySSL_RAND_egd, METH_VARARGS,
1563 + PySSL_RAND_egd_doc},
1564 ++#endif
1565 + {"RAND_status", (PyCFunction)PySSL_RAND_status, METH_NOARGS,
1566 + PySSL_RAND_status_doc},
1567 + #endif
1568 +diff --git a/configure.ac b/configure.ac
1569 +index 6a64bff..90f315a 100644
1570 +--- a/configure.ac
1571 ++++ b/configure.ac
1572 +@@ -2181,6 +2181,9 @@ AC_MSG_RESULT($SHLIBS)
1573 + AC_CHECK_LIB(sendfile, sendfile)
1574 + AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1575 + AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
1576 ++AC_CHECK_LIB(crypto, RAND_egd,
1577 ++ AC_DEFINE(HAVE_RAND_EGD, 1,
1578 ++ [Define if the libcrypto has RAND_egd]))
1579 +
1580 + # only check for sem_init if thread support is requested
1581 + if test "$with_threads" = "yes" -o -z "$with_threads"; then
1582
1583 diff --git a/dev-lang/python/files/python-3.3.5-ncurses-pkg-config.patch b/dev-lang/python/files/python-3.3.5-ncurses-pkg-config.patch
1584 new file mode 100644
1585 index 0000000..d963b9e
1586 --- /dev/null
1587 +++ b/dev-lang/python/files/python-3.3.5-ncurses-pkg-config.patch
1588 @@ -0,0 +1,40 @@
1589 +do not hardcode /usr/include paths
1590 +
1591 +--- a/configure.ac
1592 ++++ b/configure.ac
1593 +@@ -668,6 +668,8 @@ AC_ARG_WITH(cxx_main,
1594 + ])
1595 + AC_MSG_RESULT($with_cxx_main)
1596 +
1597 ++AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1598 ++
1599 + preset_cxx="$CXX"
1600 + if test -z "$CXX"
1601 + then
1602 +@@ -1513,7 +1515,7 @@ dnl AC_MSG_RESULT($cpp_type)
1603 + # checks for header files
1604 + AC_HEADER_STDC
1605 + ac_save_cppflags="$CPPFLAGS"
1606 +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
1607 ++CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags ncursesw`"
1608 + AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1609 + fcntl.h grp.h \
1610 + ieeefp.h io.h langinfo.h libintl.h ncurses.h process.h pthread.h \
1611 +@@ -2225,8 +2227,6 @@ LIBS="$withval $LIBS"
1612 + ],
1613 + [AC_MSG_RESULT(no)])
1614 +
1615 +-AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1616 +-
1617 + # Check for use of the system expat library
1618 + AC_MSG_CHECKING(for --with-system-expat)
1619 + AC_ARG_WITH(system_expat,
1620 +@@ -4273,7 +4273,7 @@ then
1621 + fi
1622 +
1623 + ac_save_cppflags="$CPPFLAGS"
1624 +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
1625 ++CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags ncursesw`"
1626 + # On HP/UX 11.0, mvwdelch is a block with a return statement
1627 + AC_MSG_CHECKING(whether mvwdelch is an expression)
1628 + AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
1629
1630 diff --git a/dev-lang/python/files/python-3.4-gcc-5.patch b/dev-lang/python/files/python-3.4-gcc-5.patch
1631 new file mode 100644
1632 index 0000000..80afbd1
1633 --- /dev/null
1634 +++ b/dev-lang/python/files/python-3.4-gcc-5.patch
1635 @@ -0,0 +1,37 @@
1636 +changeset: 94583:689092296ad3
1637 +branch: 3.4
1638 +parent: 94579:645f3d750be1
1639 +user: Victor Stinner <victor.stinner@×××××.com>
1640 +date: Wed Feb 11 14:23:35 2015 +0100
1641 +summary: Issue #23433: Fix faulthandler._stack_overflow()
1642 +
1643 +diff -r 645f3d750be1 -r 689092296ad3 Modules/faulthandler.c
1644 +--- a/Modules/faulthandler.c Tue Feb 10 14:49:32 2015 +0100
1645 ++++ b/Modules/faulthandler.c Wed Feb 11 14:23:35 2015 +0100
1646 +@@ -911,12 +911,12 @@
1647 + }
1648 +
1649 + #if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
1650 +-static void*
1651 +-stack_overflow(void *min_sp, void *max_sp, size_t *depth)
1652 ++static Py_uintptr_t
1653 ++stack_overflow(Py_uintptr_t min_sp, Py_uintptr_t max_sp, size_t *depth)
1654 + {
1655 + /* allocate 4096 bytes on the stack at each call */
1656 + unsigned char buffer[4096];
1657 +- void *sp = &buffer;
1658 ++ Py_uintptr_t sp = (Py_uintptr_t)&buffer;
1659 + *depth += 1;
1660 + if (sp < min_sp || max_sp < sp)
1661 + return sp;
1662 +@@ -929,7 +929,8 @@
1663 + faulthandler_stack_overflow(PyObject *self)
1664 + {
1665 + size_t depth, size;
1666 +- char *sp = (char *)&depth, *stop;
1667 ++ Py_uintptr_t sp = (Py_uintptr_t)&depth;
1668 ++ Py_uintptr_t stop;
1669 +
1670 + depth = 0;
1671 + stop = stack_overflow(sp - STACK_OVERFLOW_MAX_SIZE,
1672 +
1673
1674 diff --git a/dev-lang/python/metadata.xml b/dev-lang/python/metadata.xml
1675 new file mode 100644
1676 index 0000000..6a4ebd8
1677 --- /dev/null
1678 +++ b/dev-lang/python/metadata.xml
1679 @@ -0,0 +1,13 @@
1680 +<?xml version="1.0" encoding="UTF-8"?>
1681 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
1682 +<pkgmetadata>
1683 +<maintainer type="project">
1684 + <email>python@g.o</email>
1685 + <name>Python</name>
1686 +</maintainer>
1687 +<use>
1688 + <flag name="threads">Enable threading support. (DON'T DISABLE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)</flag>
1689 + <flag name="wide-unicode">Enable wide Unicode implementation which uses 4-byte Unicode characters. Switching of this USE flag changes ABI of Python and requires reinstallation of many Python modules. (DON'T DISABLE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)</flag>
1690 + <flag name="wininst">Install Windows executables required to create an executable installer for MS Windows.</flag>
1691 +</use>
1692 +</pkgmetadata>
1693
1694 diff --git a/dev-lang/python/python-3.3.5.ebuild b/dev-lang/python/python-3.3.5.ebuild
1695 new file mode 100644
1696 index 0000000..896721e
1697 --- /dev/null
1698 +++ b/dev-lang/python/python-3.3.5.ebuild
1699 @@ -0,0 +1,368 @@
1700 +# Copyright 1999-2016 Gentoo Foundation
1701 +# Distributed under the terms of the GNU General Public License v2
1702 +# $Id$
1703 +
1704 +EAPI="5"
1705 +WANT_AUTOMAKE="none"
1706 +WANT_LIBTOOL="none"
1707 +
1708 +inherit autotools eutils flag-o-matic multilib pax-utils python-utils-r1 toolchain-funcs multiprocessing
1709 +
1710 +MY_P="Python-${PV}"
1711 +PATCHSET_VERSION="${PV}-0"
1712 +
1713 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
1714 +HOMEPAGE="http://www.python.org/"
1715 +SRC_URI="http://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz"
1716 +
1717 +LICENSE="PSF-2"
1718 +SLOT="3.3/3.3m"
1719 +KEYWORDS=""
1720 +IUSE="build doc elibc_uclibc examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl +threads tk wininst +xml"
1721 +
1722 +# Do not add a dependency on dev-lang/python to this ebuild.
1723 +# If you need to apply a patch which requires python for bootstrapping, please
1724 +# run the bootstrap code on your dev box and include the results in the
1725 +# patchset. See bug 447752.
1726 +
1727 +PYVER=${SLOT%/*}
1728 +
1729 +RDEPEND="app-arch/bzip2:0=
1730 + app-arch/xz-utils:0=
1731 + >=sys-libs/zlib-1.1.3:0=
1732 + virtual/libffi
1733 + virtual/libintl
1734 + !build? (
1735 + gdbm? ( sys-libs/gdbm:0=[berkdb] )
1736 + ncurses? (
1737 + >=sys-libs/ncurses-5.2:0=
1738 + readline? ( >=sys-libs/readline-4.1:0= )
1739 + )
1740 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
1741 + ssl? (
1742 + !libressl? ( dev-libs/openssl:0= )
1743 + libressl? ( dev-libs/libressl:= )
1744 + )
1745 + tk? (
1746 + >=dev-lang/tcl-8.0:0=
1747 + >=dev-lang/tk-8.0:0=
1748 + dev-tcltk/blt:0=
1749 + dev-tcltk/tix
1750 + )
1751 + xml? ( >=dev-libs/expat-2.1:0= )
1752 + )
1753 + !!<sys-apps/sandbox-2.6-r1"
1754 +DEPEND="${RDEPEND}
1755 + virtual/pkgconfig
1756 + >=sys-devel/autoconf-2.65
1757 + !sys-devel/gcc[libffi(-)]"
1758 +RDEPEND+=" !build? ( app-misc/mime-types )
1759 + doc? ( dev-python/python-docs:${PYVER} )"
1760 +PDEPEND=">=app-eselect/eselect-python-20140125-r1"
1761 +
1762 +S="${WORKDIR}/${MY_P}"
1763 +
1764 +src_prepare() {
1765 + # Ensure that internal copies of expat, libffi and zlib are not used.
1766 + rm -fr Modules/expat
1767 + rm -fr Modules/_ctypes/libffi*
1768 + rm -fr Modules/zlib
1769 +
1770 + if tc-is-cross-compiler; then
1771 + # Invokes BUILDPYTHON, which is built for the host arch
1772 + local EPATCH_EXCLUDE="*_regenerate_platform-specific_modules.patch"
1773 + fi
1774 +
1775 + EPATCH_SUFFIX="patch" EPATCH_EXCLUDE="61_all_process_data.patch" \
1776 + epatch "${FILESDIR}/3.3"
1777 + epatch "${FILESDIR}/${PN}-3.3.5-ncurses-pkg-config.patch"
1778 + epatch "${FILESDIR}/${PN}-3.4-gcc-5.patch" #547626
1779 +
1780 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
1781 + Lib/distutils/command/install.py \
1782 + Lib/distutils/sysconfig.py \
1783 + Lib/site.py \
1784 + Lib/sysconfig.py \
1785 + Lib/test/test_site.py \
1786 + Makefile.pre.in \
1787 + Modules/Setup.dist \
1788 + Modules/getpath.c \
1789 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
1790 +
1791 + # bug #514686
1792 + epatch "${FILESDIR}/${PN}-3.3-CVE-2014-4616.patch"
1793 +
1794 + epatch "${FILESDIR}"/${PN}-3.3-libressl.patch
1795 +
1796 + epatch_user
1797 +
1798 + eautoconf
1799 + eautoheader
1800 +}
1801 +
1802 +src_configure() {
1803 + if use build; then
1804 + # Disable extraneous modules with extra dependencies.
1805 + export PYTHON_DISABLE_MODULES="gdbm _curses _curses_panel readline _sqlite3 _tkinter _elementtree pyexpat"
1806 + export PYTHON_DISABLE_SSL="1"
1807 + else
1808 + local disable
1809 + use gdbm || disable+=" gdbm"
1810 + use ncurses || disable+=" _curses _curses_panel"
1811 + use readline || disable+=" readline"
1812 + use sqlite || disable+=" _sqlite3"
1813 + use ssl || export PYTHON_DISABLE_SSL="1"
1814 + use tk || disable+=" _tkinter"
1815 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
1816 + export PYTHON_DISABLE_MODULES="${disable}"
1817 +
1818 + if ! use xml; then
1819 + ewarn "You have configured Python without XML support."
1820 + ewarn "This is NOT a recommended configuration as you"
1821 + ewarn "may face problems parsing any XML documents."
1822 + fi
1823 + fi
1824 +
1825 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
1826 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
1827 + fi
1828 +
1829 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
1830 + append-flags -fwrapv
1831 + fi
1832 +
1833 + filter-flags -malign-double
1834 +
1835 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
1836 + if is-flagq -O3; then
1837 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
1838 + use hardened && replace-flags -O3 -O2
1839 + fi
1840 +
1841 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
1842 + tc-export CXX
1843 + # The configure script fails to use pkg-config correctly.
1844 + # http://bugs.python.org/issue15506
1845 + export ac_cv_path_PKG_CONFIG=$(tc-getPKG_CONFIG)
1846 +
1847 + # Set LDFLAGS so we link modules with -lpython3.2 correctly.
1848 + # Needed on FreeBSD unless Python 3.2 is already installed.
1849 + # Please query BSD team before removing this!
1850 + append-ldflags "-L."
1851 +
1852 + local dbmliborder
1853 + if use gdbm; then
1854 + dbmliborder+="${dbmliborder:+:}gdbm"
1855 + fi
1856 +
1857 + BUILD_DIR="${WORKDIR}/${CHOST}"
1858 + mkdir -p "${BUILD_DIR}" || die
1859 + cd "${BUILD_DIR}" || die
1860 +
1861 + ECONF_SOURCE="${S}" OPT="" \
1862 + econf \
1863 + --with-fpectl \
1864 + --enable-shared \
1865 + $(use_enable ipv6) \
1866 + $(use_with threads) \
1867 + --infodir='${prefix}/share/info' \
1868 + --mandir='${prefix}/share/man' \
1869 + --with-computed-gotos \
1870 + --with-dbmliborder="${dbmliborder}" \
1871 + --with-libc="" \
1872 + --enable-loadable-sqlite-extensions \
1873 + --with-system-expat \
1874 + --with-system-ffi
1875 +
1876 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
1877 + eerror "configure has detected that the sem_open function is broken."
1878 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
1879 + die "Broken sem_open function (bug 496328)"
1880 + fi
1881 +}
1882 +
1883 +src_compile() {
1884 + # Avoid invoking pgen for cross-compiles.
1885 + touch Include/graminit.h Python/graminit.c || die
1886 +
1887 + cd "${BUILD_DIR}" || die
1888 + emake CPPFLAGS="" CFLAGS="" LDFLAGS=""
1889 +
1890 + # Work around bug 329499. See also bug 413751 and 457194.
1891 + if has_version dev-libs/libffi[pax_kernel]; then
1892 + pax-mark E python
1893 + else
1894 + pax-mark m python
1895 + fi
1896 +}
1897 +
1898 +src_test() {
1899 + # Tests will not work when cross compiling.
1900 + if tc-is-cross-compiler; then
1901 + elog "Disabling tests due to crosscompiling."
1902 + return
1903 + fi
1904 +
1905 + cd "${BUILD_DIR}" || die
1906 +
1907 + # Skip failing tests.
1908 + local skipped_tests="gdb"
1909 +
1910 + for test in ${skipped_tests}; do
1911 + mv "${S}"/Lib/test/test_${test}.py "${T}"
1912 + done
1913 +
1914 + PYTHONDONTWRITEBYTECODE="" emake test EXTRATESTOPTS="-u -network" FLAGS="" CFLAGS="" LDFLAGS="" < /dev/tty
1915 + local result="$?"
1916 +
1917 + for test in ${skipped_tests}; do
1918 + mv "${T}/test_${test}.py" "${S}"/Lib/test
1919 + done
1920 +
1921 + elog "The following tests have been skipped:"
1922 + for test in ${skipped_tests}; do
1923 + elog "test_${test}.py"
1924 + done
1925 +
1926 + elog "If you would like to run them, you may:"
1927 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
1928 + elog "and run the tests separately."
1929 +
1930 + if [[ "${result}" -ne 0 ]]; then
1931 + die "emake test failed"
1932 + fi
1933 +}
1934 +
1935 +src_install() {
1936 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
1937 +
1938 + cd "${BUILD_DIR}" || die
1939 +
1940 + emake DESTDIR="${D}" altinstall
1941 +
1942 + sed \
1943 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
1944 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
1945 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
1946 +
1947 + # Fix collisions between different slots of Python.
1948 + rm -f "${ED}usr/$(get_libdir)/libpython3.so"
1949 +
1950 + # Cheap hack to get version with ABIFLAGS
1951 + local abiver=$(cd "${ED}usr/include"; echo python*)
1952 + if [[ ${abiver} != python${PYVER} ]]; then
1953 + # Replace python3.X with a symlink to python3.Xm
1954 + rm "${ED}usr/bin/python${PYVER}" || die
1955 + dosym "${abiver}" "/usr/bin/python${PYVER}"
1956 + # Create python3.X-config symlink
1957 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
1958 + # Create python-3.5m.pc symlink
1959 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
1960 + fi
1961 +
1962 + if use build; then
1963 + rm -fr "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,sqlite3,test,tkinter}
1964 + else
1965 + use elibc_uclibc && rm -fr "${libdir}/test"
1966 + use sqlite || rm -fr "${libdir}/"{sqlite3,test/test_sqlite*}
1967 + use tk || rm -fr "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*}
1968 + fi
1969 +
1970 + use threads || rm -fr "${libdir}/multiprocessing"
1971 + use wininst || rm -f "${libdir}/distutils/command/"wininst-*.exe
1972 +
1973 + dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
1974 +
1975 + if use examples; then
1976 + insinto /usr/share/doc/${PF}/examples
1977 + find "${S}"/Tools -name __pycache__ -print0 | xargs -0 rm -fr
1978 + doins -r "${S}"/Tools
1979 + fi
1980 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
1981 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
1982 + emake --no-print-directory -s -f - 2>/dev/null)
1983 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
1984 +
1985 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
1986 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
1987 + sed \
1988 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
1989 + -e "s:@PYDOC@:pydoc${PYVER}:" \
1990 + -i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed"
1991 +
1992 + # for python-exec
1993 + local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR )
1994 +
1995 + # if not using a cross-compiler, use the fresh binary
1996 + if ! tc-is-cross-compiler; then
1997 + local -x PYTHON=./python
1998 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}.
1999 + else
2000 + vars=( PYTHON "${vars[@]}" )
2001 + fi
2002 +
2003 + python_export "python${PYVER}" "${vars[@]}"
2004 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
2005 + python_domodule epython.py
2006 +
2007 + # python-exec wrapping support
2008 + local pymajor=${PYVER%.*}
2009 + mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die
2010 + # python and pythonX
2011 + ln -s "../../../bin/${abiver}" \
2012 + "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die
2013 + ln -s "python${pymajor}" \
2014 + "${D}${PYTHON_SCRIPTDIR}/python" || die
2015 + # python-config and pythonX-config
2016 + # note: we need to create a wrapper rather than symlinking it due
2017 + # to some random dirname(argv[0]) magic performed by python-config
2018 + cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die
2019 + #!/bin/sh
2020 + exec "${abiver}-config" "\${@}"
2021 + EOF
2022 + chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die
2023 + ln -s "python${pymajor}-config" \
2024 + "${D}${PYTHON_SCRIPTDIR}/python-config" || die
2025 + # 2to3, pydoc, pyvenv
2026 + ln -s "../../../bin/2to3-${PYVER}" \
2027 + "${D}${PYTHON_SCRIPTDIR}/2to3" || die
2028 + ln -s "../../../bin/pydoc${PYVER}" \
2029 + "${D}${PYTHON_SCRIPTDIR}/pydoc" || die
2030 + ln -s "../../../bin/pyvenv-${PYVER}" \
2031 + "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die
2032 + # idle
2033 + if use tk; then
2034 + ln -s "../../../bin/idle${PYVER}" \
2035 + "${D}${PYTHON_SCRIPTDIR}/idle" || die
2036 + fi
2037 +}
2038 +
2039 +pkg_preinst() {
2040 + if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then
2041 + python_updater_warning="1"
2042 + fi
2043 +}
2044 +
2045 +eselect_python_update() {
2046 + if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
2047 + eselect python update
2048 + fi
2049 +
2050 + if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
2051 + eselect python update --python${PV%%.*}
2052 + fi
2053 +}
2054 +
2055 +pkg_postinst() {
2056 + eselect_python_update
2057 +
2058 + if [[ "${python_updater_warning}" == "1" ]]; then
2059 + ewarn "You have just upgraded from an older version of Python."
2060 + ewarn
2061 + ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules."
2062 + fi
2063 +}
2064 +
2065 +pkg_postrm() {
2066 + eselect_python_update
2067 +}