Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pyblake2/
Date: Tue, 24 Oct 2017 17:34:20
Message-Id: 1508866432.aca68ed6f1e01986b21edc552f50c879e073ca9d.floppym@gentoo
1 commit: aca68ed6f1e01986b21edc552f50c879e073ca9d
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 23 16:40:50 2017 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Tue Oct 24 17:33:52 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aca68ed6
7
8 dev-python/pyblake2: select implementation using compiler macros
9
10 This eliminates the need for the cpu_flags_x86 USE flags, and resolves
11 a build failure if CFLAGS and cpu_flags_x86 are mismatched.
12
13 Package-Manager: Portage-2.3.11_p4, Repoman-2.3.3_p62
14
15 dev-python/pyblake2/pyblake2-0.9.3.ebuild | 37 ++++++++++++++++++++++---------
16 1 file changed, 27 insertions(+), 10 deletions(-)
17
18 diff --git a/dev-python/pyblake2/pyblake2-0.9.3.ebuild b/dev-python/pyblake2/pyblake2-0.9.3.ebuild
19 index cdfe223ded1..b0c84ac4968 100644
20 --- a/dev-python/pyblake2/pyblake2-0.9.3.ebuild
21 +++ b/dev-python/pyblake2/pyblake2-0.9.3.ebuild
22 @@ -4,7 +4,7 @@
23 EAPI=6
24
25 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} pypy )
26 -inherit distutils-r1 flag-o-matic
27 +inherit distutils-r1 flag-o-matic toolchain-funcs
28
29 DESCRIPTION="BLAKE2 hash function extension module"
30 HOMEPAGE="https://github.com/dchest/pyblake2 https://pypi.python.org/pypi/pyblake2"
31 @@ -13,18 +13,35 @@ SRC_URI="mirror://pypi/${PN::1}/${PN}/${P}.tar.gz"
32 LICENSE="CC0-1.0"
33 SLOT="0"
34 KEYWORDS="~amd64 ~ia64 ~ppc ~ppc64 ~x86 ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
35 -IUSE="cpu_flags_x86_ssse3 cpu_flags_x86_avx cpu_flags_x86_xop"
36
37 -python_prepare_all() {
38 - local impl=REGS
39 - # note: SSE2 is 2.5x slower than pure REGS, so we ignore it
40 - use cpu_flags_x86_ssse3 && impl=SSSE3
41 - # this does not actually do anything but implicitly enabled SSE4.1...
42 - use cpu_flags_x86_avx && impl=AVX
43 - use cpu_flags_x86_xop && impl=XOP
44 +blake2_impl() {
45 + local code='
46 +#if defined(__XOP__)
47 + HAVE_XOP
48 +#elif defined(__AVX__)
49 + HAVE_AVX
50 +#elif defined(__SSSE3__)
51 + HAVE_SSSE3
52 +#elif defined(__SSE2__)
53 + HAVE_SSE2
54 +#endif
55 +'
56 + local res=$($(tc-getCC) -E -P ${CFLAGS} - <<<"${code}")
57 +
58 + case ${res} in
59 + *HAVE_XOP*) echo XOP;;
60 + # this does not actually do anything but implicitly enabled SSE4.1...
61 + *HAVE_AVX*) echo AVX;;
62 + *HAVE_SSSE3*) echo SSSE3;;
63 + # note: SSE2 is 2.5x slower than pure REGS, so we ignore it
64 + #*HAVE_SSE2*) echo SSE2;;
65 + *) echo REGS;;
66 + esac
67 +}
68
69 +python_prepare_all() {
70 # uncomment the implementation of choice
71 - sed -i -e "/BLAKE2_COMPRESS_${impl}/s:^#::" setup.py || die
72 + sed -i -e "/BLAKE2_COMPRESS_$(blake2_impl)/s:^#::" setup.py || die
73
74 # avoid segfault due to over(?) optimisation
75 if [[ ${CHOST} == *86*-darwin* ]] ; then