commit:     d2de8ad43c17349f4511be5e028ce3a1c31e9678
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  5 13:05:15 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jan  5 13:24:31 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2de8ad4

dev-python/pycryptodome: fix configure w/ gcc 14

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../pycryptodome-3.19.1-gcc14-configure.patch      | 48 +++++++++++++++++
 .../pycryptodome/pycryptodome-3.19.1-r1.ebuild     | 61 ++++++++++++++++++++++
 2 files changed, 109 insertions(+)

diff --git 
a/dev-python/pycryptodome/files/pycryptodome-3.19.1-gcc14-configure.patch 
b/dev-python/pycryptodome/files/pycryptodome-3.19.1-gcc14-configure.patch
new file mode 100644
index 000000000000..ee87f615b814
--- /dev/null
+++ b/dev-python/pycryptodome/files/pycryptodome-3.19.1-gcc14-configure.patch
@@ -0,0 +1,48 @@
+https://github.com/Legrandin/pycryptodome/issues/787
+https://github.com/Legrandin/pycryptodome/commit/b4083688fde0580de6c2a4d36d84da31a2549a2c
+
+From b4083688fde0580de6c2a4d36d84da31a2549a2c Mon Sep 17 00:00:00 2001
+From: Helder Eijs <[email protected]>
+Date: Fri, 29 Dec 2023 14:36:19 +0100
+Subject: [PATCH] Better autodetect of AES support, in case of aggressive
+ optimization
+
+--- a/compiler_opt.py
++++ b/compiler_opt.py
+@@ -140,7 +140,7 @@ def compiler_has_intrin_h():
+     {
+         int a, b[4];
+         __cpuid(b, a);
+-        return 0;
++        return a;
+     }
+     """
+     return test_compilation(source, msg="intrin.h header")
+@@ -154,7 +154,7 @@ def compiler_has_cpuid_h():
+     {
+         unsigned int eax, ebx, ecx, edx;
+         __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+-        return 0;
++        return eax;
+     }
+     """
+     return test_compilation(source, msg="cpuid.h header")
+@@ -163,11 +163,16 @@ def compiler_has_cpuid_h():
+ def compiler_supports_aesni():
+     source = """
+     #include <wmmintrin.h>
++    #include <string.h>
+     __m128i f(__m128i x, __m128i y) {
+         return _mm_aesenc_si128(x, y);
+     }
+     int main(void) {
+-        return 0;
++        int ret;
++        __m128i x = _mm_setzero_si128();
++        x = f(x, x);
++        memcpy(&ret, &x, sizeof(ret));
++        return ret;
+     }
+     """
+ 
+

diff --git a/dev-python/pycryptodome/pycryptodome-3.19.1-r1.ebuild 
b/dev-python/pycryptodome/pycryptodome-3.19.1-r1.ebuild
new file mode 100644
index 000000000000..89a5edcca25b
--- /dev/null
+++ b/dev-python/pycryptodome/pycryptodome-3.19.1-r1.ebuild
@@ -0,0 +1,61 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} pypy3 )
+PYTHON_REQ_USE="threads(+)"
+
+inherit distutils-r1
+
+DESCRIPTION="A self-contained cryptographic library for Python"
+HOMEPAGE="
+       https://www.pycryptodome.org/
+       https://github.com/Legrandin/pycryptodome/
+       https://pypi.org/project/pycryptodome/
+"
+SRC_URI="
+       https://github.com/Legrandin/pycryptodome/archive/v${PV}.tar.gz
+               -> ${P}.gh.tar.gz
+"
+
+LICENSE="BSD-2 Unlicense"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos 
~x64-macos ~x64-solaris"
+
+DEPEND="
+       dev-libs/gmp:=
+       >=dev-libs/libtomcrypt-1.18.2-r1:=
+"
+BDEPEND="
+       $(python_gen_cond_dep 'dev-python/cffi[${PYTHON_USEDEP}]' 'python*')
+"
+RDEPEND="
+       ${DEPEND}
+       ${BDEPEND}
+"
+
+PATCHES=(
+       "${FILESDIR}/pycryptodome-3.10.1-system-libtomcrypt.patch"
+       "${FILESDIR}/pycryptodome-3.19.1-gcc14-configure.patch"
+)
+
+python_prepare_all() {
+       # make sure we're unbundling it correctly
+       rm -r src/libtom || die
+
+       distutils-r1_python_prepare_all
+}
+
+python_test() {
+       local -x PYTHONPATH=${S}/test_vectors:${PYTHONPATH}
+       "${EPYTHON}" - <<-EOF || die
+               import sys
+               from Crypto import SelfTest
+               SelfTest.run(verbosity=2, stream=sys.stdout)
+       EOF
+
+       # TODO: run cmake tests from src/test?
+}

Reply via email to