Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/riscv:master commit in: dev-lang/python/, dev-lang/python/files/
Date: Sat, 20 Apr 2019 23:37:35
Message-Id: 1555803290.f09799fa0c57ccb122754914ed23136e02b0da2f.dilfridge@gentoo
1 commit: f09799fa0c57ccb122754914ed23136e02b0da2f
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 20 23:34:50 2019 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 20 23:34:50 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/riscv.git/commit/?id=f09799fa
7
8 dev-lang/python: Add our monkeypatched python
9
10 Package-Manager: Portage-2.3.63, Repoman-2.3.12
11 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
12
13 dev-lang/python/Manifest | 2 +
14 dev-lang/python/files/3.4-getentropy-linux.patch | 40 +++
15 dev-lang/python/files/3.6-disable-nis.patch | 21 ++
16 dev-lang/python/files/3.6.5-disable-nis.patch | 11 +
17 dev-lang/python/files/pydoc.conf | 6 +
18 dev-lang/python/files/pydoc.init | 24 ++
19 .../python-2.7.10-cross-compile-warn-test.patch | 24 ++
20 .../python/files/python-2.7.10-system-libffi.patch | 36 +++
21 .../files/python-2.7.5-nonfatal-compileall.patch | 18 ++
22 .../files/python-2.7.9-ncurses-pkg-config.patch | 13 +
23 .../files/python-3.4.3-ncurses-pkg-config.patch | 13 +
24 dev-lang/python/files/python-3.4.5-cross.patch | 11 +
25 .../files/python-3.5-distutils-OO-build.patch | 80 +++++
26 .../python/files/python-3.5.5-hash-unaligned.patch | 43 +++
27 .../python-3.5.5-libressl-compatibility.patch | 69 ++++
28 .../python/files/python-3.6.5-hash-unaligned.patch | 42 +++
29 .../python-3.6.5-libressl-compatibility.patch | 114 +++++++
30 .../python/files/python-3.6.8-reducepath.patch | 22 ++
31 dev-lang/python/metadata.xml | 13 +
32 dev-lang/python/python-3.6.8-r1.ebuild | 351 +++++++++++++++++++++
33 20 files changed, 953 insertions(+)
34
35 diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest
36 new file mode 100644
37 index 0000000..d2f2f32
38 --- /dev/null
39 +++ b/dev-lang/python/Manifest
40 @@ -0,0 +1,2 @@
41 +DIST Python-3.6.8.tar.xz 17212420 BLAKE2B e104b49a35492b622080ab81a446c0cdd1223e8ddf95c4e1b262762a027664b59f3e4deeda4ba7177115d780e48b6764a053acef640a645327df428d2e4820cd SHA512 b17867e451ebe662f50df83ed112d3656c089e7d750651ea640052b01b713b58e66aac9e082f71fd16f5b5510bc9b797f5ccd30f5399581e9aa406197f02938a
42 +DIST python-gentoo-patches-3.6.8.tar.xz 11224 BLAKE2B 5fe38282bcf28df18e0bd37756c880ae191ea738dc92f1cf83f682cfdc52525b9c44287dc99191a73d75c90672ab501b56adf49515b35ff1fdee88c8dc07b175 SHA512 89e700663db25d6d78eee1d4bfdab686c5341a794062f3a63df3485ac0b58deb4b4885d24701f3ae138d06ca783be92e310e1100c6d633910c33732f3cb0d7df
43
44 diff --git a/dev-lang/python/files/3.4-getentropy-linux.patch b/dev-lang/python/files/3.4-getentropy-linux.patch
45 new file mode 100644
46 index 0000000..9f12389
47 --- /dev/null
48 +++ b/dev-lang/python/files/3.4-getentropy-linux.patch
49 @@ -0,0 +1,40 @@
50 +From 5635d44079e1bbd9c495951ede8d078e7b8d67d5 Mon Sep 17 00:00:00 2001
51 +From: Victor Stinner <victor.stinner@×××××.com>
52 +Date: Mon, 9 Jan 2017 11:10:41 +0100
53 +Subject: [PATCH] Don't use getentropy() on Linux
54 +
55 +Issue #29188: Support glibc 2.24 on Linux: don't use getentropy() function but
56 +read from /dev/urandom to get random bytes, for example in os.urandom(). On
57 +Linux, getentropy() is implemented which getrandom() is blocking mode, whereas
58 +os.urandom() should not block.
59 +---
60 + Python/random.c | 13 ++++++++++---
61 + 1 file changed, 10 insertions(+), 3 deletions(-)
62 +
63 +diff --git a/Python/random.c b/Python/random.c
64 +index af3d0bd0d5..dc6400d3b8 100644
65 +--- a/Python/random.c
66 ++++ b/Python/random.c
67 +@@ -67,9 +67,16 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
68 + return 0;
69 + }
70 +
71 +-/* Issue #25003: Don' use getentropy() on Solaris (available since
72 +- * Solaris 11.3), it is blocking whereas os.urandom() should not block. */
73 +-#elif defined(HAVE_GETENTROPY) && !defined(sun)
74 ++/* Issue #25003: Don't use getentropy() on Solaris (available since
75 ++ Solaris 11.3), it is blocking whereas os.urandom() should not block.
76 ++
77 ++ Issue #29188: Don't use getentropy() on Linux since the glibc 2.24
78 ++ implements it with the getrandom() syscall which can fail with ENOSYS,
79 ++ and this error is not supported in py_getentropy() and getrandom() is called
80 ++ with flags=0 which blocks until system urandom is initialized, which is not
81 ++ the desired behaviour to seed the Python hash secret nor for os.urandom():
82 ++ see the PEP 524 which was only implemented in Python 3.6. */
83 ++#elif defined(HAVE_GETENTROPY) && !defined(sun) && !defined(linux)
84 + #define PY_GETENTROPY 1
85 +
86 + /* Fill buffer with size pseudo-random bytes generated by getentropy().
87 +--
88 +2.15.0.rc2
89 +
90
91 diff --git a/dev-lang/python/files/3.6-disable-nis.patch b/dev-lang/python/files/3.6-disable-nis.patch
92 new file mode 100644
93 index 0000000..4e81847
94 --- /dev/null
95 +++ b/dev-lang/python/files/3.6-disable-nis.patch
96 @@ -0,0 +1,21 @@
97 +--- a/setup.py
98 ++++ b/setup.py
99 +@@ -1332,17 +1332,7 @@ class PyBuildExt(build_ext):
100 + # Jeremy Hylton's rlimit interface
101 + exts.append( Extension('resource', ['resource.c']) )
102 +
103 +- # Sun yellow pages. Some systems have the functions in libc.
104 +- if (host_platform not in ['cygwin', 'qnx6'] and
105 +- find_file('rpcsvc/yp_prot.h', inc_dirs, []) is not None):
106 +- if (self.compiler.find_library_file(lib_dirs, 'nsl')):
107 +- libs = ['nsl']
108 +- else:
109 +- libs = []
110 +- exts.append( Extension('nis', ['nismodule.c'],
111 +- libraries = libs) )
112 +- else:
113 +- missing.append('nis')
114 ++ missing.append('nis')
115 + else:
116 + missing.extend(['nis', 'resource', 'termios'])
117 +
118
119 diff --git a/dev-lang/python/files/3.6.5-disable-nis.patch b/dev-lang/python/files/3.6.5-disable-nis.patch
120 new file mode 100644
121 index 0000000..3937c6f
122 --- /dev/null
123 +++ b/dev-lang/python/files/3.6.5-disable-nis.patch
124 @@ -0,0 +1,11 @@
125 +--- a/setup.py
126 ++++ b/setup.py
127 +@@ -1364,7 +1364,7 @@ class PyBuildExt(build_ext):
128 + else:
129 + missing.extend(['resource', 'termios'])
130 +
131 +- nis = self._detect_nis(inc_dirs, lib_dirs)
132 ++ nis = None
133 + if nis is not None:
134 + exts.append(nis)
135 + else:
136
137 diff --git a/dev-lang/python/files/pydoc.conf b/dev-lang/python/files/pydoc.conf
138 new file mode 100644
139 index 0000000..3c6920c
140 --- /dev/null
141 +++ b/dev-lang/python/files/pydoc.conf
142 @@ -0,0 +1,6 @@
143 +# /etc/init.d/pydoc.conf
144 +
145 +# This file contains the configuration for pydoc's internal webserver.
146 +
147 +# Default port for Python's pydoc server.
148 +@PYDOC_PORT_VARIABLE@="7464"
149
150 diff --git a/dev-lang/python/files/pydoc.init b/dev-lang/python/files/pydoc.init
151 new file mode 100644
152 index 0000000..148ce0b
153 --- /dev/null
154 +++ b/dev-lang/python/files/pydoc.init
155 @@ -0,0 +1,24 @@
156 +#!/sbin/openrc-run
157 +# Copyright 1999-2019 Gentoo Authors
158 +# Distributed under the terms of the GNU General Public Licence v2
159 +
160 +start() {
161 + local pydoc_port="${@PYDOC_PORT_VARIABLE@-${PYDOC_PORT}}"
162 +
163 + if [ -z "${pydoc_port}" ]; then
164 + eerror "Port not set"
165 + return 1
166 + fi
167 +
168 + ebegin "Starting pydoc server on port ${pydoc_port}"
169 + start-stop-daemon --start --background --make-pidfile \
170 + --pidfile /var/run/@PYDOC@.pid \
171 + --exec /usr/bin/@PYDOC@ -- -p "${pydoc_port}"
172 + eend $?
173 +}
174 +
175 +stop() {
176 + ebegin "Stopping pydoc server"
177 + start-stop-daemon --stop --quiet --pidfile /var/run/@PYDOC@.pid
178 + eend $?
179 +}
180
181 diff --git a/dev-lang/python/files/python-2.7.10-cross-compile-warn-test.patch b/dev-lang/python/files/python-2.7.10-cross-compile-warn-test.patch
182 new file mode 100644
183 index 0000000..38433de
184 --- /dev/null
185 +++ b/dev-lang/python/files/python-2.7.10-cross-compile-warn-test.patch
186 @@ -0,0 +1,24 @@
187 +https://bugs.python.org/issue25397
188 +
189 +improve the cross-compile tests to be more focused
190 +
191 +--- a/configure.ac
192 ++++ b/configure.ac
193 +@@ -1339,7 +1339,7 @@ if test "$GCC" = "yes"
194 + then
195 + AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
196 + save_CFLAGS=$CFLAGS
197 +- CFLAGS="$CFLAGS -Werror -Wformat"
198 ++ CFLAGS="$CFLAGS -Werror=format"
199 + AC_COMPILE_IFELSE([
200 + AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
201 + ],[
202 +@@ -4458,7 +4458,7 @@ then
203 + [ac_cv_have_long_long_format="cross -- assuming no"
204 + if test x$GCC = xyes; then
205 + save_CFLAGS=$CFLAGS
206 +- CFLAGS="$CFLAGS -Werror -Wformat"
207 ++ CFLAGS="$CFLAGS -Werror=format"
208 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
209 + #include <stdio.h>
210 + #include <stddef.h>
211
212 diff --git a/dev-lang/python/files/python-2.7.10-system-libffi.patch b/dev-lang/python/files/python-2.7.10-system-libffi.patch
213 new file mode 100644
214 index 0000000..0b49b79
215 --- /dev/null
216 +++ b/dev-lang/python/files/python-2.7.10-system-libffi.patch
217 @@ -0,0 +1,36 @@
218 +make sure we respect the system libffi setting in our build config.
219 +the compiler probing is fragile and can break in some situations.
220 +
221 +--- a/setup.py
222 ++++ b/setup.py
223 +@@ -2069,7 +2069,7 @@ class PyBuildExt(build_ext):
224 + return True
225 +
226 + def detect_ctypes(self, inc_dirs, lib_dirs):
227 +- self.use_system_libffi = False
228 ++ self.use_system_libffi = ('--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"))
229 + include_dirs = []
230 + extra_compile_args = []
231 + extra_link_args = []
232 +@@ -2113,7 +2113,7 @@ class PyBuildExt(build_ext):
233 + sources=['_ctypes/_ctypes_test.c'])
234 + self.extensions.extend([ext, ext_test])
235 +
236 +- if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"):
237 ++ if not self.use_system_libffi:
238 + return
239 +
240 + if host_platform == 'darwin':
241 +@@ -2141,10 +2141,10 @@ class PyBuildExt(build_ext):
242 + ffi_lib = lib_name
243 + break
244 +
245 +- if ffi_inc and ffi_lib:
246 ++ if ffi_inc:
247 + ext.include_dirs.extend(ffi_inc)
248 ++ if ffi_lib:
249 + ext.libraries.append(ffi_lib)
250 +- self.use_system_libffi = True
251 +
252 +
253 + class PyBuildInstall(install):
254
255 diff --git a/dev-lang/python/files/python-2.7.5-nonfatal-compileall.patch b/dev-lang/python/files/python-2.7.5-nonfatal-compileall.patch
256 new file mode 100644
257 index 0000000..a762dfb
258 --- /dev/null
259 +++ b/dev-lang/python/files/python-2.7.5-nonfatal-compileall.patch
260 @@ -0,0 +1,18 @@
261 +diff --git a/Makefile.pre.in b/Makefile.pre.in
262 +--- a/Makefile.pre.in
263 ++++ b/Makefile.pre.in
264 +@@ -1000,12 +1000,12 @@
265 + $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
266 + $(DESTDIR)$(LIBDEST)/distutils/tests ; \
267 + fi
268 +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
269 ++ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
270 + $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
271 + -d $(LIBDEST) -f \
272 + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
273 + $(DESTDIR)$(LIBDEST)
274 +- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
275 ++ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
276 + $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
277 + -d $(LIBDEST) -f \
278 + -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
279
280 diff --git a/dev-lang/python/files/python-2.7.9-ncurses-pkg-config.patch b/dev-lang/python/files/python-2.7.9-ncurses-pkg-config.patch
281 new file mode 100644
282 index 0000000..38ce6f7
283 --- /dev/null
284 +++ b/dev-lang/python/files/python-2.7.9-ncurses-pkg-config.patch
285 @@ -0,0 +1,13 @@
286 +do not hardcode /usr/include paths
287 +
288 +--- a/configure.ac
289 ++++ b/configure.ac
290 +@@ -4316,7 +4316,7 @@ fi
291 +
292 + # first curses configure check
293 + ac_save_cppflags="$CPPFLAGS"
294 +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
295 ++CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags ncursesw`"
296 +
297 + AC_CHECK_HEADERS(curses.h ncurses.h)
298 +
299
300 diff --git a/dev-lang/python/files/python-3.4.3-ncurses-pkg-config.patch b/dev-lang/python/files/python-3.4.3-ncurses-pkg-config.patch
301 new file mode 100644
302 index 0000000..8bfad11
303 --- /dev/null
304 +++ b/dev-lang/python/files/python-3.4.3-ncurses-pkg-config.patch
305 @@ -0,0 +1,13 @@
306 +do not hardcode /usr/include paths
307 +
308 +--- a/configure.ac
309 ++++ b/configure.ac
310 +@@ -4402,7 +4402,7 @@ fi
311 +
312 + # first curses header check
313 + ac_save_cppflags="$CPPFLAGS"
314 +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
315 ++CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags ncursesw`"
316 +
317 + AC_CHECK_HEADERS(curses.h ncurses.h)
318 +
319
320 diff --git a/dev-lang/python/files/python-3.4.5-cross.patch b/dev-lang/python/files/python-3.4.5-cross.patch
321 new file mode 100644
322 index 0000000..7a016ff
323 --- /dev/null
324 +++ b/dev-lang/python/files/python-3.4.5-cross.patch
325 @@ -0,0 +1,11 @@
326 +--- a/Lib/distutils/command/build_ext.py
327 ++++ b/Lib/distutils/command/build_ext.py
328 +@@ -729,7 +729,7 @@
329 + if sysconfig.get_config_var('Py_ENABLE_SHARED'):
330 + pythonlib = 'python{}.{}{}'.format(
331 + sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
332 +- sys.abiflags)
333 ++ sysconfig.get_config_var('ABIFLAGS'))
334 + return ext.libraries + [pythonlib]
335 + else:
336 + return ext.libraries
337
338 diff --git a/dev-lang/python/files/python-3.5-distutils-OO-build.patch b/dev-lang/python/files/python-3.5-distutils-OO-build.patch
339 new file mode 100644
340 index 0000000..8af8c30
341 --- /dev/null
342 +++ b/dev-lang/python/files/python-3.5-distutils-OO-build.patch
343 @@ -0,0 +1,80 @@
344 +From 90507018442f9adabb586fd3d0a0206b9c2f2f50 Mon Sep 17 00:00:00 2001
345 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
346 +Date: Sun, 5 Jun 2016 08:18:01 +0200
347 +Subject: [PATCH] distutils: make -OO enable both opt-1 and opt-2 optimization
348 +
349 +Bug: http://bugs.python.org/issue27226
350 +Bug: https://bugs.gentoo.org/585060
351 +---
352 + Lib/distutils/command/build_py.py | 8 ++++----
353 + Lib/distutils/command/install_lib.py | 12 ++++++------
354 + 2 files changed, 10 insertions(+), 10 deletions(-)
355 +
356 +diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
357 +index cf0ca57..838d4e4 100644
358 +--- a/Lib/distutils/command/build_py.py
359 ++++ b/Lib/distutils/command/build_py.py
360 +@@ -315,9 +315,9 @@ class build_py (Command):
361 + if self.compile:
362 + outputs.append(importlib.util.cache_from_source(
363 + filename, optimization=''))
364 +- if self.optimize > 0:
365 ++ for opt in range(1, self.optimize + 1):
366 + outputs.append(importlib.util.cache_from_source(
367 +- filename, optimization=self.optimize))
368 ++ filename, optimization=opt))
369 +
370 + outputs += [
371 + os.path.join(build_dir, filename)
372 +@@ -387,8 +387,8 @@ class build_py (Command):
373 + if self.compile:
374 + byte_compile(files, optimize=0,
375 + force=self.force, prefix=prefix, dry_run=self.dry_run)
376 +- if self.optimize > 0:
377 +- byte_compile(files, optimize=self.optimize,
378 ++ for opt in range(1, self.optimize + 1):
379 ++ byte_compile(files, optimize=opt,
380 + force=self.force, prefix=prefix, dry_run=self.dry_run)
381 +
382 + class build_py_2to3(build_py, Mixin2to3):
383 +diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
384 +index 6154cf0..049b662 100644
385 +--- a/Lib/distutils/command/install_lib.py
386 ++++ b/Lib/distutils/command/install_lib.py
387 +@@ -24,8 +24,8 @@ class install_lib(Command):
388 + # 2) compile .pyc only (--compile --no-optimize; default)
389 + # 3) compile .pyc and "opt-1" .pyc (--compile --optimize)
390 + # 4) compile "opt-1" .pyc only (--no-compile --optimize)
391 +- # 5) compile .pyc and "opt-2" .pyc (--compile --optimize-more)
392 +- # 6) compile "opt-2" .pyc only (--no-compile --optimize-more)
393 ++ # 5) compile .pyc, "opt-1" and "opt-2" .pyc (--compile --optimize-more)
394 ++ # 6) compile "opt-1" and "opt-2" .pyc (--no-compile --optimize-more)
395 + #
396 + # The UI for this is two options, 'compile' and 'optimize'.
397 + # 'compile' is strictly boolean, and only decides whether to
398 +@@ -132,8 +132,8 @@ class install_lib(Command):
399 + byte_compile(files, optimize=0,
400 + force=self.force, prefix=install_root,
401 + dry_run=self.dry_run)
402 +- if self.optimize > 0:
403 +- byte_compile(files, optimize=self.optimize,
404 ++ for opt in range(1, self.optimize + 1):
405 ++ byte_compile(files, optimize=opt,
406 + force=self.force, prefix=install_root,
407 + verbose=self.verbose, dry_run=self.dry_run)
408 +
409 +@@ -167,9 +167,9 @@ class install_lib(Command):
410 + if self.compile:
411 + bytecode_files.append(importlib.util.cache_from_source(
412 + py_file, optimization=''))
413 +- if self.optimize > 0:
414 ++ for opt in range(1, self.optimize + 1):
415 + bytecode_files.append(importlib.util.cache_from_source(
416 +- py_file, optimization=self.optimize))
417 ++ py_file, optimization=opt))
418 +
419 + return bytecode_files
420 +
421 +--
422 +2.8.3
423 +
424
425 diff --git a/dev-lang/python/files/python-3.5.5-hash-unaligned.patch b/dev-lang/python/files/python-3.5.5-hash-unaligned.patch
426 new file mode 100644
427 index 0000000..c418f40
428 --- /dev/null
429 +++ b/dev-lang/python/files/python-3.5.5-hash-unaligned.patch
430 @@ -0,0 +1,43 @@
431 +The hash implementation casts the input pointer to uint64_t* and directly reads
432 +from this, which may cause unaligned accesses. Use memcpy() instead so this code
433 +will not crash with SIGBUS on sparc.
434 +
435 +--- a/Python/pyhash.c 2017-11-29 10:21:20.283094068 +0100
436 ++++ b/Python/pyhash.c 2017-11-29 10:24:26.733087813 +0100
437 +@@ -372,7 +372,7 @@ siphash24(const void *src, Py_ssize_t sr
438 + PY_UINT64_T k0 = _le64toh(_Py_HashSecret.siphash.k0);
439 + PY_UINT64_T k1 = _le64toh(_Py_HashSecret.siphash.k1);
440 + PY_UINT64_T b = (PY_UINT64_T)src_sz << 56;
441 +- const PY_UINT64_T *in = (PY_UINT64_T*)src;
442 ++ const PY_UINT8_T *in = (PY_UINT8_T*)src;
443 +
444 + PY_UINT64_T v0 = k0 ^ 0x736f6d6570736575ULL;
445 + PY_UINT64_T v1 = k1 ^ 0x646f72616e646f6dULL;
446 +@@ -381,12 +381,14 @@ siphash24(const void *src, Py_ssize_t sr
447 +
448 + PY_UINT64_T t;
449 + PY_UINT8_T *pt;
450 +- PY_UINT8_T *m;
451 ++ const PY_UINT8_T *m;
452 +
453 + while (src_sz >= 8) {
454 +- PY_UINT64_T mi = _le64toh(*in);
455 +- in += 1;
456 +- src_sz -= 8;
457 ++ PY_UINT64_T mi;
458 ++ memcpy(&mi, in, sizeof(mi));
459 ++ mi = _le64toh(mi);
460 ++ in += sizeof(mi);
461 ++ src_sz -= sizeof(mi);
462 + v3 ^= mi;
463 + DOUBLE_ROUND(v0,v1,v2,v3);
464 + v0 ^= mi;
465 +@@ -394,7 +396,7 @@ siphash24(const void *src, Py_ssize_t sr
466 +
467 + t = 0;
468 + pt = (PY_UINT8_T *)&t;
469 +- m = (PY_UINT8_T *)in;
470 ++ m = in;
471 + switch (src_sz) {
472 + case 7: pt[6] = m[6];
473 + case 6: pt[5] = m[5];
474
475 diff --git a/dev-lang/python/files/python-3.5.5-libressl-compatibility.patch b/dev-lang/python/files/python-3.5.5-libressl-compatibility.patch
476 new file mode 100644
477 index 0000000..67d57d0
478 --- /dev/null
479 +++ b/dev-lang/python/files/python-3.5.5-libressl-compatibility.patch
480 @@ -0,0 +1,69 @@
481 +# From 8d89a385b71a2e4cce0fba0cfc8d91b63485edc5 Mon Sep 17 00:00:00 2001
482 +# From: Christian Heimes <christian@××××××.org>
483 +# Date: Sat, 24 Mar 2018 18:38:14 +0100
484 +# Subject: [PATCH] [3.6] bpo-33127: Compatibility patch for LibreSSL 2.7.0
485 +# (GH-6210) (GH-6214)
486 +#
487 +# LibreSSL 2.7 introduced OpenSSL 1.1.0 API. The ssl module now detects
488 +# LibreSSL 2.7 and only provides API shims for OpenSSL < 1.1.0 and
489 +# LibreSSL < 2.7.
490 +
491 +# Documentation updates and fixes for failing tests will be provided in
492 +# another patch set.
493 +
494 +# Signed-off-by: Christian Heimes <christian@××××××.org>.
495 +# (cherry picked from commit 4ca0739c9d97ac7cd45499e0d31be68dc659d0e1)
496 +
497 +# Co-authored-by: Christian Heimes <christian@××××××.org>
498 +# Patch modified by Aaron Bauman <bman@g.o> for 3.5.5
499 +
500 +--- a/Modules/_ssl.c 2018-04-13 18:33:17.397649561 -0400
501 ++++ b/Modules/_ssl.c 2018-04-13 18:40:22.319852014 -0400
502 +@@ -101,6 +101,12 @@
503 +
504 + #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
505 + # define OPENSSL_VERSION_1_1 1
506 ++# define PY_OPENSSL_1_1_API 1
507 ++#endif
508 ++
509 ++/* LibreSSL 2.7.0 provides necessary OpenSSL 1.1.0 APIs */
510 ++#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070000fL
511 ++# define PY_OPENSSL_1_1_API 1
512 + #endif
513 +
514 + /* Openssl comes with TLSv1.1 and TLSv1.2 between 1.0.0h and 1.0.1
515 +@@ -129,16 +135,18 @@
516 + #define INVALID_SOCKET (-1)
517 + #endif
518 +
519 +-#ifdef OPENSSL_VERSION_1_1
520 +-/* OpenSSL 1.1.0+ */
521 +-#ifndef OPENSSL_NO_SSL2
522 +-#define OPENSSL_NO_SSL2
523 +-#endif
524 +-#else /* OpenSSL < 1.1.0 */
525 +-#if defined(WITH_THREAD)
526 ++/* OpenSSL 1.0.2 and LibreSSL needs extra code for locking */
527 ++#if !defined(OPENSSL_VERSION_1_1) && defined(WITH_THREAD)
528 + #define HAVE_OPENSSL_CRYPTO_LOCK
529 + #endif
530 +
531 ++#if defined(OPENSSL_VERSION_1_1) && !defined(OPENSSL_NO_SSL2)
532 ++#define OPENSSL_NO_SSL2
533 ++#endif
534 ++
535 ++#ifndef PY_OPENSSL_1_1_API
536 ++/* OpenSSL 1.1 API shims for OpenSSL < 1.1.0 and LibreSSL < 2.7.0 */
537 ++
538 + #define TLS_method SSLv23_method
539 +
540 + static int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne)
541 +@@ -187,7 +195,7 @@
542 + {
543 + return store->param;
544 + }
545 +-#endif /* OpenSSL < 1.1.0 or LibreSSL */
546 ++#endif /* OpenSSL < 1.1.0 or LibreSSL < 2.7.0 */
547 +
548 +
549 + enum py_ssl_error {
550
551 diff --git a/dev-lang/python/files/python-3.6.5-hash-unaligned.patch b/dev-lang/python/files/python-3.6.5-hash-unaligned.patch
552 new file mode 100644
553 index 0000000..d096887
554 --- /dev/null
555 +++ b/dev-lang/python/files/python-3.6.5-hash-unaligned.patch
556 @@ -0,0 +1,42 @@
557 +The hash implementation casts the input pointer to uint64_t* and directly reads
558 +from this, which may cause unaligned accesses. Use memcpy() instead so this code
559 +will not crash with SIGBUS on sparc.
560 +
561 +--- a/Python/pyhash.c 2017-11-29 10:21:20.283094068 +0100
562 ++++ b/Python/pyhash.c 2017-11-29 10:24:26.733087813 +0100
563 +@@ -369,7 +369,7 @@
564 + uint64_t k0 = _le64toh(_Py_HashSecret.siphash.k0);
565 + uint64_t k1 = _le64toh(_Py_HashSecret.siphash.k1);
566 + uint64_t b = (uint64_t)src_sz << 56;
567 +- const uint64_t *in = (uint64_t*)src;
568 ++ const uint8_t *in = (uint8_t*)src;
569 +
570 + uint64_t v0 = k0 ^ 0x736f6d6570736575ULL;
571 + uint64_t v1 = k1 ^ 0x646f72616e646f6dULL;
572 +@@ -378,11 +378,13 @@
573 +
574 + uint64_t t;
575 + uint8_t *pt;
576 +- uint8_t *m;
577 ++ const uint8_t *m;
578 +
579 + while (src_sz >= 8) {
580 +- uint64_t mi = _le64toh(*in);
581 +- in += 1;
582 +- src_sz -= 8;
583 ++ uint64_t mi;
584 ++ memcpy(&mi, in, sizeof(mi));
585 ++ mi = _le64toh(mi);
586 ++ in += sizeof(mi);
587 ++ src_sz -= sizeof(mi);
588 + v3 ^= mi;
589 + DOUBLE_ROUND(v0,v1,v2,v3);
590 +@@ -391,7 +393,7 @@
591 +
592 + t = 0;
593 + pt = (uint8_t *)&t;
594 +- m = (uint8_t *)in;
595 ++ m = in;
596 + switch (src_sz) {
597 + case 7: pt[6] = m[6]; /* fall through */
598 + case 6: pt[5] = m[5]; /* fall through */
599
600 diff --git a/dev-lang/python/files/python-3.6.5-libressl-compatibility.patch b/dev-lang/python/files/python-3.6.5-libressl-compatibility.patch
601 new file mode 100644
602 index 0000000..2f9e6a2
603 --- /dev/null
604 +++ b/dev-lang/python/files/python-3.6.5-libressl-compatibility.patch
605 @@ -0,0 +1,114 @@
606 +From 8d89a385b71a2e4cce0fba0cfc8d91b63485edc5 Mon Sep 17 00:00:00 2001
607 +From: Christian Heimes <christian@××××××.org>
608 +Date: Sat, 24 Mar 2018 18:38:14 +0100
609 +Subject: [PATCH] [3.6] bpo-33127: Compatibility patch for LibreSSL 2.7.0
610 + (GH-6210) (GH-6214)
611 +
612 +LibreSSL 2.7 introduced OpenSSL 1.1.0 API. The ssl module now detects
613 +LibreSSL 2.7 and only provides API shims for OpenSSL < 1.1.0 and
614 +LibreSSL < 2.7.
615 +
616 +Documentation updates and fixes for failing tests will be provided in
617 +another patch set.
618 +
619 +Signed-off-by: Christian Heimes <christian@××××××.org>.
620 +(cherry picked from commit 4ca0739c9d97ac7cd45499e0d31be68dc659d0e1)
621 +
622 +Co-authored-by: Christian Heimes <christian@××××××.org>
623 +---
624 + Lib/test/test_ssl.py | 1 +
625 + .../2018-03-24-15-08-24.bpo-33127.olJmHv.rst | 1 +
626 + Modules/_ssl.c | 24 ++++++++++++-------
627 + Tools/ssl/multissltests.py | 3 ++-
628 + 4 files changed, 20 insertions(+), 9 deletions(-)
629 + create mode 100644 Misc/NEWS.d/next/Library/2018-03-24-15-08-24.bpo-33127.olJmHv.rst
630 +
631 +diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
632 +index 8dd3b41450..9785a59a7e 100644
633 +--- a/Lib/test/test_ssl.py
634 ++++ b/Lib/test/test_ssl.py
635 +@@ -1687,6 +1687,7 @@ class SimpleBackgroundTests(unittest.TestCase):
636 + self.assertEqual(len(ctx.get_ca_certs()), 1)
637 +
638 + @needs_sni
639 ++ @unittest.skipUnless(hasattr(ssl, "PROTOCOL_TLSv1_2"), "needs TLS 1.2")
640 + def test_context_setget(self):
641 + # Check that the context of a connected socket can be replaced.
642 + ctx1 = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
643 +diff --git a/Misc/NEWS.d/next/Library/2018-03-24-15-08-24.bpo-33127.olJmHv.rst b/Misc/NEWS.d/next/Library/2018-03-24-15-08-24.bpo-33127.olJmHv.rst
644 +new file mode 100644
645 +index 0000000000..635aabbde0
646 +--- /dev/null
647 ++++ b/Misc/NEWS.d/next/Library/2018-03-24-15-08-24.bpo-33127.olJmHv.rst
648 +@@ -0,0 +1 @@
649 ++The ssl module now compiles with LibreSSL 2.7.1.
650 +diff --git a/Modules/_ssl.c b/Modules/_ssl.c
651 +index c54e43c2b4..5e007da858 100644
652 +--- a/Modules/_ssl.c
653 ++++ b/Modules/_ssl.c
654 +@@ -106,6 +106,12 @@ struct py_ssl_library_code {
655 +
656 + #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
657 + # define OPENSSL_VERSION_1_1 1
658 ++# define PY_OPENSSL_1_1_API 1
659 ++#endif
660 ++
661 ++/* LibreSSL 2.7.0 provides necessary OpenSSL 1.1.0 APIs */
662 ++#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x2070000fL
663 ++# define PY_OPENSSL_1_1_API 1
664 + #endif
665 +
666 + /* Openssl comes with TLSv1.1 and TLSv1.2 between 1.0.0h and 1.0.1
667 +@@ -152,16 +158,18 @@ struct py_ssl_library_code {
668 + #define INVALID_SOCKET (-1)
669 + #endif
670 +
671 +-#ifdef OPENSSL_VERSION_1_1
672 +-/* OpenSSL 1.1.0+ */
673 +-#ifndef OPENSSL_NO_SSL2
674 +-#define OPENSSL_NO_SSL2
675 +-#endif
676 +-#else /* OpenSSL < 1.1.0 */
677 +-#if defined(WITH_THREAD)
678 ++/* OpenSSL 1.0.2 and LibreSSL needs extra code for locking */
679 ++#if !defined(OPENSSL_VERSION_1_1) && defined(WITH_THREAD)
680 + #define HAVE_OPENSSL_CRYPTO_LOCK
681 + #endif
682 +
683 ++#if defined(OPENSSL_VERSION_1_1) && !defined(OPENSSL_NO_SSL2)
684 ++#define OPENSSL_NO_SSL2
685 ++#endif
686 ++
687 ++#ifndef PY_OPENSSL_1_1_API
688 ++/* OpenSSL 1.1 API shims for OpenSSL < 1.1.0 and LibreSSL < 2.7.0 */
689 ++
690 + #define TLS_method SSLv23_method
691 + #define TLS_client_method SSLv23_client_method
692 + #define TLS_server_method SSLv23_server_method
693 +@@ -227,7 +235,7 @@ SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s)
694 + return s->tlsext_tick_lifetime_hint;
695 + }
696 +
697 +-#endif /* OpenSSL < 1.1.0 or LibreSSL */
698 ++#endif /* OpenSSL < 1.1.0 or LibreSSL < 2.7.0 */
699 +
700 +
701 + enum py_ssl_error {
702 +diff --git a/Tools/ssl/multissltests.py b/Tools/ssl/multissltests.py
703 +index ce5bbd8530..ba4529ae06 100755
704 +--- a/Tools/ssl/multissltests.py
705 ++++ b/Tools/ssl/multissltests.py
706 +@@ -57,8 +57,9 @@ LIBRESSL_OLD_VERSIONS = [
707 + ]
708 +
709 + LIBRESSL_RECENT_VERSIONS = [
710 +- "2.5.3",
711 + "2.5.5",
712 ++ "2.6.4",
713 ++ "2.7.1",
714 + ]
715 +
716 + # store files in ../multissl
717 +--
718 +2.17.0
719 +
720
721 diff --git a/dev-lang/python/files/python-3.6.8-reducepath.patch b/dev-lang/python/files/python-3.6.8-reducepath.patch
722 new file mode 100644
723 index 0000000..5f39097
724 --- /dev/null
725 +++ b/dev-lang/python/files/python-3.6.8-reducepath.patch
726 @@ -0,0 +1,22 @@
727 +ONLY FOR MULTILIB RISCV!
728 +Handles the extra / in the libdir... -dilfridge
729 +
730 +diff -ruN Python-3.6.8.orig/Modules/getpath.c Python-3.6.8/Modules/getpath.c
731 +--- Python-3.6.8.orig/Modules/getpath.c 2018-12-23 22:37:14.000000000 +0100
732 ++++ Python-3.6.8/Modules/getpath.c 2019-04-21 01:05:35.127440301 +0200
733 +@@ -796,6 +796,7 @@
734 + if (pfound > 0) {
735 + reduce(prefix);
736 + reduce(prefix);
737 ++ reduce(prefix);
738 + /* The prefix is the root directory, but reduce() chopped
739 + * off the "/". */
740 + if (!prefix[0])
741 +@@ -808,6 +809,7 @@
742 + reduce(exec_prefix);
743 + reduce(exec_prefix);
744 + reduce(exec_prefix);
745 ++ reduce(exec_prefix);
746 + if (!exec_prefix[0])
747 + wcscpy(exec_prefix, separator);
748 + }
749
750 diff --git a/dev-lang/python/metadata.xml b/dev-lang/python/metadata.xml
751 new file mode 100644
752 index 0000000..8662752
753 --- /dev/null
754 +++ b/dev-lang/python/metadata.xml
755 @@ -0,0 +1,13 @@
756 +<?xml version="1.0" encoding="UTF-8"?>
757 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
758 +<pkgmetadata>
759 +<maintainer type="project">
760 + <email>python@g.o</email>
761 + <name>Python</name>
762 +</maintainer>
763 +<use>
764 + <flag name="bluetooth">Build Bluetooth protocol support in socket module</flag>
765 + <flag name="threads">Enable threading support. (DON'T DISABLE THIS UNLESS YOU KNOW WHAT YOU'RE DOING)</flag>
766 + <flag name="wininst">Install Windows executables required to create an executable installer for MS Windows.</flag>
767 +</use>
768 +</pkgmetadata>
769
770 diff --git a/dev-lang/python/python-3.6.8-r1.ebuild b/dev-lang/python/python-3.6.8-r1.ebuild
771 new file mode 100644
772 index 0000000..b362845
773 --- /dev/null
774 +++ b/dev-lang/python/python-3.6.8-r1.ebuild
775 @@ -0,0 +1,351 @@
776 +# Copyright 1999-2019 Gentoo Authors
777 +# Distributed under the terms of the GNU General Public License v2
778 +
779 +EAPI="6"
780 +WANT_LIBTOOL="none"
781 +
782 +inherit autotools flag-o-matic pax-utils python-utils-r1 toolchain-funcs
783 +
784 +MY_P="Python-${PV}"
785 +PATCHSET_VERSION="3.6.8"
786 +
787 +DESCRIPTION="An interpreted, interactive, object-oriented programming language"
788 +HOMEPAGE="https://www.python.org/"
789 +SRC_URI="https://www.python.org/ftp/python/${PV}/${MY_P}.tar.xz
790 + https://dev.gentoo.org/~floppym/python/python-gentoo-patches-${PATCHSET_VERSION}.tar.xz"
791 +
792 +LICENSE="PSF-2"
793 +SLOT="3.6/3.6m"
794 +KEYWORDS="~riscv"
795 +IUSE="bluetooth build examples gdbm hardened ipv6 libressl +ncurses +readline sqlite +ssl test +threads tk wininst +xml"
796 +RESTRICT="!test? ( test )"
797 +
798 +# Do not add a dependency on dev-lang/python to this ebuild.
799 +# If you need to apply a patch which requires python for bootstrapping, please
800 +# run the bootstrap code on your dev box and include the results in the
801 +# patchset. See bug 447752.
802 +
803 +RDEPEND="app-arch/bzip2:0=
804 + app-arch/xz-utils:0=
805 + >=sys-libs/zlib-1.1.3:0=
806 + virtual/libffi:=
807 + virtual/libintl
808 + gdbm? ( sys-libs/gdbm:0=[berkdb] )
809 + ncurses? ( >=sys-libs/ncurses-5.2:0= )
810 + readline? ( >=sys-libs/readline-4.1:0= )
811 + sqlite? ( >=dev-db/sqlite-3.3.8:3= )
812 + ssl? (
813 + !libressl? ( dev-libs/openssl:0= )
814 + libressl? ( dev-libs/libressl:0= )
815 + )
816 + tk? (
817 + >=dev-lang/tcl-8.0:0=
818 + >=dev-lang/tk-8.0:0=
819 + dev-tcltk/blt:0=
820 + dev-tcltk/tix
821 + )
822 + xml? ( >=dev-libs/expat-2.1:0= )
823 + !!<sys-apps/sandbox-2.6-r1"
824 +# bluetooth requires headers from bluez
825 +DEPEND="${RDEPEND}
826 + bluetooth? ( net-wireless/bluez )
827 + test? ( app-arch/xz-utils[extra-filters(+)] )
828 + virtual/pkgconfig
829 + !sys-devel/gcc[libffi(-)]"
830 +RDEPEND+=" !build? ( app-misc/mime-types )"
831 +PDEPEND=">=app-eselect/eselect-python-20140125-r1"
832 +
833 +S="${WORKDIR}/${MY_P}"
834 +PYVER=${SLOT%/*}
835 +
836 +src_prepare() {
837 + # Ensure that internal copies of expat, libffi and zlib are not used.
838 + rm -fr Modules/expat
839 + rm -fr Modules/_ctypes/libffi*
840 + rm -fr Modules/zlib
841 +
842 + local PATCHES=(
843 + "${WORKDIR}/patches"
844 + )
845 +
846 + default
847 +
848 + eapply "${FILESDIR}/${P}-reducepath.patch" # only for multilib riscv
849 +
850 + sed -i -e "s:@@GENTOO_LIBDIR@@:$(get_libdir):g" \
851 + Lib/distutils/command/install.py \
852 + Lib/distutils/sysconfig.py \
853 + Lib/site.py \
854 + Lib/sysconfig.py \
855 + Lib/test/test_site.py \
856 + Makefile.pre.in \
857 + Modules/Setup.dist \
858 + Modules/getpath.c \
859 + configure.ac \
860 + setup.py || die "sed failed to replace @@GENTOO_LIBDIR@@"
861 +
862 + eautoreconf
863 +}
864 +
865 +src_configure() {
866 + local disable
867 + # disable automagic bluetooth headers detection
868 + use bluetooth || export ac_cv_header_bluetooth_bluetooth_h=no
869 + use gdbm || disable+=" gdbm"
870 + use ncurses || disable+=" _curses _curses_panel"
871 + use readline || disable+=" readline"
872 + use sqlite || disable+=" _sqlite3"
873 + use ssl || export PYTHON_DISABLE_SSL="1"
874 + use tk || disable+=" _tkinter"
875 + use xml || disable+=" _elementtree pyexpat" # _elementtree uses pyexpat.
876 + export PYTHON_DISABLE_MODULES="${disable}"
877 +
878 + if ! use xml; then
879 + ewarn "You have configured Python without XML support."
880 + ewarn "This is NOT a recommended configuration as you"
881 + ewarn "may face problems parsing any XML documents."
882 + fi
883 +
884 + if [[ -n "${PYTHON_DISABLE_MODULES}" ]]; then
885 + einfo "Disabled modules: ${PYTHON_DISABLE_MODULES}"
886 + fi
887 +
888 + if [[ "$(gcc-major-version)" -ge 4 ]]; then
889 + append-flags -fwrapv
890 + fi
891 +
892 + filter-flags -malign-double
893 +
894 + # https://bugs.gentoo.org/show_bug.cgi?id=50309
895 + if is-flagq -O3; then
896 + is-flagq -fstack-protector-all && replace-flags -O3 -O2
897 + use hardened && replace-flags -O3 -O2
898 + fi
899 +
900 + # Export CXX so it ends up in /usr/lib/python3.X/config/Makefile.
901 + tc-export CXX
902 +
903 + # Set LDFLAGS so we link modules with -lpython3.2 correctly.
904 + # Needed on FreeBSD unless Python 3.2 is already installed.
905 + # Please query BSD team before removing this!
906 + append-ldflags "-L."
907 +
908 + local dbmliborder
909 + if use gdbm; then
910 + dbmliborder+="${dbmliborder:+:}gdbm"
911 + fi
912 +
913 + local myeconfargs=(
914 + --with-fpectl
915 + --enable-shared
916 + $(use_enable ipv6)
917 + $(use_with threads)
918 + --infodir='${prefix}/share/info'
919 + --mandir='${prefix}/share/man'
920 + --with-computed-gotos
921 + --with-dbmliborder="${dbmliborder}"
922 + --with-libc=
923 + --enable-loadable-sqlite-extensions
924 + --without-ensurepip
925 + --with-system-expat
926 + --with-system-ffi
927 + )
928 +
929 + OPT="" econf "${myeconfargs[@]}"
930 +
931 + if use threads && grep -q "#define POSIX_SEMAPHORES_NOT_ENABLED 1" pyconfig.h; then
932 + eerror "configure has detected that the sem_open function is broken."
933 + eerror "Please ensure that /dev/shm is mounted as a tmpfs with mode 1777."
934 + die "Broken sem_open function (bug 496328)"
935 + fi
936 +}
937 +
938 +src_compile() {
939 + # Ensure sed works as expected
940 + # https://bugs.gentoo.org/594768
941 + local -x LC_ALL=C
942 +
943 + emake CPPFLAGS= CFLAGS= LDFLAGS=
944 +
945 + # Work around bug 329499. See also bug 413751 and 457194.
946 + if has_version dev-libs/libffi[pax_kernel]; then
947 + pax-mark E python
948 + else
949 + pax-mark m python
950 + fi
951 +}
952 +
953 +src_test() {
954 + # Tests will not work when cross compiling.
955 + if tc-is-cross-compiler; then
956 + elog "Disabling tests due to crosscompiling."
957 + return
958 + fi
959 +
960 + # Skip failing tests.
961 + local skipped_tests="gdb"
962 +
963 + for test in ${skipped_tests}; do
964 + mv "${S}"/Lib/test/test_${test}.py "${T}"
965 + done
966 +
967 + # bug 660358
968 + local -x COLUMNS=80
969 +
970 + local -x PYTHONDONTWRITEBYTECODE=
971 +
972 + emake test EXTRATESTOPTS="-u-network" CPPFLAGS= CFLAGS= LDFLAGS= < /dev/tty
973 + local result=$?
974 +
975 + for test in ${skipped_tests}; do
976 + mv "${T}/test_${test}.py" "${S}"/Lib/test
977 + done
978 +
979 + elog "The following tests have been skipped:"
980 + for test in ${skipped_tests}; do
981 + elog "test_${test}.py"
982 + done
983 +
984 + elog "If you would like to run them, you may:"
985 + elog "cd '${EPREFIX}/usr/$(get_libdir)/python${PYVER}/test'"
986 + elog "and run the tests separately."
987 +
988 + if [[ ${result} -ne 0 ]]; then
989 + die "emake test failed"
990 + fi
991 +}
992 +
993 +src_install() {
994 + local libdir=${ED}/usr/$(get_libdir)/python${PYVER}
995 +
996 + emake DESTDIR="${D}" altinstall
997 +
998 + sed \
999 + -e "s/\(CONFIGURE_LDFLAGS=\).*/\1/" \
1000 + -e "s/\(PY_LDFLAGS=\).*/\1/" \
1001 + -i "${libdir}/config-${PYVER}"*/Makefile || die "sed failed"
1002 +
1003 + # Fix collisions between different slots of Python.
1004 + rm -f "${ED}usr/$(get_libdir)/libpython3.so"
1005 +
1006 + # Cheap hack to get version with ABIFLAGS
1007 + local abiver=$(cd "${ED}usr/include"; echo python*)
1008 + if [[ ${abiver} != python${PYVER} ]]; then
1009 + # Replace python3.X with a symlink to python3.Xm
1010 + rm "${ED}usr/bin/python${PYVER}" || die
1011 + dosym "${abiver}" "/usr/bin/python${PYVER}"
1012 + # Create python3.X-config symlink
1013 + dosym "${abiver}-config" "/usr/bin/python${PYVER}-config"
1014 + # Create python-3.5m.pc symlink
1015 + dosym "python-${PYVER}.pc" "/usr/$(get_libdir)/pkgconfig/${abiver/${PYVER}/-${PYVER}}.pc"
1016 + fi
1017 +
1018 + # python seems to get rebuilt in src_install (bug 569908)
1019 + # Work around it for now.
1020 + if has_version dev-libs/libffi[pax_kernel]; then
1021 + pax-mark E "${ED}usr/bin/${abiver}"
1022 + else
1023 + pax-mark m "${ED}usr/bin/${abiver}"
1024 + fi
1025 +
1026 + use sqlite || rm -r "${libdir}/"{sqlite3,test/test_sqlite*} || die
1027 + use tk || rm -r "${ED}usr/bin/idle${PYVER}" "${libdir}/"{idlelib,tkinter,test/test_tk*} || die
1028 +
1029 + use threads || rm -r "${libdir}/multiprocessing" || die
1030 + use wininst || rm "${libdir}/distutils/command/"wininst-*.exe || die
1031 +
1032 + dodoc "${S}"/Misc/{ACKS,HISTORY,NEWS}
1033 +
1034 + if use examples; then
1035 + insinto /usr/share/doc/${PF}/examples
1036 + find "${S}"/Tools -name __pycache__ -print0 | xargs -0 rm -fr
1037 + doins -r "${S}"/Tools
1038 + fi
1039 + insinto /usr/share/gdb/auto-load/usr/$(get_libdir) #443510
1040 + local libname=$(printf 'e:\n\t@echo $(INSTSONAME)\ninclude Makefile\n' | \
1041 + emake --no-print-directory -s -f - 2>/dev/null)
1042 + newins "${S}"/Tools/gdb/libpython.py "${libname}"-gdb.py
1043 +
1044 + newconfd "${FILESDIR}/pydoc.conf" pydoc-${PYVER}
1045 + newinitd "${FILESDIR}/pydoc.init" pydoc-${PYVER}
1046 + sed \
1047 + -e "s:@PYDOC_PORT_VARIABLE@:PYDOC${PYVER/./_}_PORT:" \
1048 + -e "s:@PYDOC@:pydoc${PYVER}:" \
1049 + -i "${ED}etc/conf.d/pydoc-${PYVER}" "${ED}etc/init.d/pydoc-${PYVER}" || die "sed failed"
1050 +
1051 + # for python-exec
1052 + local vars=( EPYTHON PYTHON_SITEDIR PYTHON_SCRIPTDIR )
1053 +
1054 + # if not using a cross-compiler, use the fresh binary
1055 + if ! tc-is-cross-compiler; then
1056 + local -x PYTHON=./python
1057 + local -x LD_LIBRARY_PATH=${LD_LIBRARY_PATH+${LD_LIBRARY_PATH}:}${PWD}
1058 + else
1059 + vars=( PYTHON "${vars[@]}" )
1060 + fi
1061 +
1062 + python_export "python${PYVER}" "${vars[@]}"
1063 + echo "EPYTHON='${EPYTHON}'" > epython.py || die
1064 + python_domodule epython.py
1065 +
1066 + # python-exec wrapping support
1067 + local pymajor=${PYVER%.*}
1068 + mkdir -p "${D}${PYTHON_SCRIPTDIR}" || die
1069 + # python and pythonX
1070 + ln -s "../../../bin/${abiver}" \
1071 + "${D}${PYTHON_SCRIPTDIR}/python${pymajor}" || die
1072 + ln -s "python${pymajor}" \
1073 + "${D}${PYTHON_SCRIPTDIR}/python" || die
1074 + # python-config and pythonX-config
1075 + # note: we need to create a wrapper rather than symlinking it due
1076 + # to some random dirname(argv[0]) magic performed by python-config
1077 + cat > "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" <<-EOF || die
1078 + #!/bin/sh
1079 + exec "${abiver}-config" "\${@}"
1080 + EOF
1081 + chmod +x "${D}${PYTHON_SCRIPTDIR}/python${pymajor}-config" || die
1082 + ln -s "python${pymajor}-config" \
1083 + "${D}${PYTHON_SCRIPTDIR}/python-config" || die
1084 + # 2to3, pydoc, pyvenv
1085 + ln -s "../../../bin/2to3-${PYVER}" \
1086 + "${D}${PYTHON_SCRIPTDIR}/2to3" || die
1087 + ln -s "../../../bin/pydoc${PYVER}" \
1088 + "${D}${PYTHON_SCRIPTDIR}/pydoc" || die
1089 + ln -s "../../../bin/pyvenv-${PYVER}" \
1090 + "${D}${PYTHON_SCRIPTDIR}/pyvenv" || die
1091 + # idle
1092 + if use tk; then
1093 + ln -s "../../../bin/idle${PYVER}" \
1094 + "${D}${PYTHON_SCRIPTDIR}/idle" || die
1095 + fi
1096 +}
1097 +
1098 +pkg_preinst() {
1099 + if has_version "<${CATEGORY}/${PN}-${PYVER}" && ! has_version ">=${CATEGORY}/${PN}-${PYVER}_alpha"; then
1100 + python_updater_warning="1"
1101 + fi
1102 +}
1103 +
1104 +eselect_python_update() {
1105 + if [[ -z "$(eselect python show)" || ! -f "${EROOT}usr/bin/$(eselect python show)" ]]; then
1106 + eselect python update
1107 + fi
1108 +
1109 + if [[ -z "$(eselect python show --python${PV%%.*})" || ! -f "${EROOT}usr/bin/$(eselect python show --python${PV%%.*})" ]]; then
1110 + eselect python update --python${PV%%.*}
1111 + fi
1112 +}
1113 +
1114 +pkg_postinst() {
1115 + eselect_python_update
1116 +
1117 + if [[ "${python_updater_warning}" == "1" ]]; then
1118 + ewarn "You have just upgraded from an older version of Python."
1119 + ewarn
1120 + ewarn "Please adjust PYTHON_TARGETS (if so desired), and run emerge with the --newuse or --changed-use option to rebuild packages installing python modules."
1121 + fi
1122 +}
1123 +
1124 +pkg_postrm() {
1125 + eselect_python_update
1126 +}