From 0e6434fbf979cd0aa62897c595458554640060f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Thu, 15 Sep 2022 18:53:26 +0200 Subject: [PATCH] dev-python/blake3-py-c: New package, C variant of blake3-py, v0.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- dev-python/blake3-py-c/Manifest | 1 + .../blake3-py-c/blake3-py-c-0.3.1.ebuild | 42 +++++++++++ .../files/blake3-py-c-0.3.1-backports.patch | 73 +++++++++++++++++++ dev-python/blake3-py-c/metadata.xml | 11 +++ 4 files changed, 127 insertions(+) create mode 100644 dev-python/blake3-py-c/Manifest create mode 100644 dev-python/blake3-py-c/blake3-py-c-0.3.1.ebuild create mode 100644 dev-python/blake3-py-c/files/blake3-py-c-0.3.1-backports.patch create mode 100644 dev-python/blake3-py-c/metadata.xml diff --git a/dev-python/blake3-py-c/Manifest b/dev-python/blake3-py-c/Manifest new file mode 100644 index 0000000000000..a74044be12b44 --- /dev/null +++ b/dev-python/blake3-py-c/Manifest @@ -0,0 +1 @@ +DIST blake3-py-0.3.1.gh.tar.gz 131798 BLAKE2B 6c816bab8d1e432453d4d40f4acc4d33bb45d305a2ab8458dded72bfee6ffd687a016d257dad4c2d656ddd5d765e5ad450e18fdd4af084a51f1973ce56daea68 SHA512 d3901339df9dc3409f8c2407c6f4f02fb9e13e8e7a76d77c06d9f58c6cceea4829cedf71a687fdded8ad70897d3a4833f2b124f39837b0ffa5fb8b907b51fd56 diff --git a/dev-python/blake3-py-c/blake3-py-c-0.3.1.ebuild b/dev-python/blake3-py-c/blake3-py-c-0.3.1.ebuild new file mode 100644 index 0000000000000..954d842bcbe71 --- /dev/null +++ b/dev-python/blake3-py-c/blake3-py-c-0.3.1.ebuild @@ -0,0 +1,42 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{8..11} ) + +inherit distutils-r1 + +MY_P=${P/-c} +DESCRIPTION="Python bindings for the BLAKE3 cryptographic hash function" +HOMEPAGE="https://github.com/oconnor663/blake3-py/" +SRC_URI=" + https://github.com/oconnor663/blake3-py/archive/${PV}.tar.gz + -> ${MY_P}.gh.tar.gz +" +S=${WORKDIR}/${MY_P}/c_impl + +LICENSE="|| ( CC0-1.0 Apache-2.0 )" +SLOT="0" +KEYWORDS="~amd64" + +RDEPEND=" + !dev-python/blake3-py[${PYTHON_USEDEP}] +" +BDEPEND=" + test? ( + dev-python/numpy[${PYTHON_USEDEP}] + ) +" + +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}"/${P}-backports.patch +) + +python_test() { + cd .. || die + epytest +} diff --git a/dev-python/blake3-py-c/files/blake3-py-c-0.3.1-backports.patch b/dev-python/blake3-py-c/files/blake3-py-c-0.3.1-backports.patch new file mode 100644 index 0000000000000..0c36aaa5ff214 --- /dev/null +++ b/dev-python/blake3-py-c/files/blake3-py-c-0.3.1-backports.patch @@ -0,0 +1,73 @@ +From 0d7526621087fd016d4ab5d34abfb35c715ec0cd Mon Sep 17 00:00:00 2001 +From: Thomas Waldmann +Date: Tue, 29 Mar 2022 17:31:02 +0200 +Subject: [PATCH] c_impl: compatibility fix for python < 3.10 + +--- + blake3module.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/blake3module.c b/blake3module.c +index f4160fb..0fce6ad 100644 +--- a/blake3module.c ++++ b/blake3module.c +@@ -414,7 +414,8 @@ PyMODINIT_FUNC PyInit_blake3(void) { + goto exit; + } + +- if (PyModule_AddObjectRef(module, "blake3", (PyObject *)&Blake3Type) < 0) { ++ if (PyModule_AddObject(module, "blake3", (PyObject *)&Blake3Type) < 0) { ++ Py_DECREF((PyObject *)&Blake3Type); + goto exit; + } + +From 52676a355eccfb0050b372cd36a14ab49878e8b3 Mon Sep 17 00:00:00 2001 +From: Thomas Waldmann +Date: Tue, 29 Mar 2022 18:18:46 +0200 +Subject: [PATCH] c_impl: apple silicon build fix, fixes #31 + +On Apple Silicon (M1 CPU), the platform.machine() call returns "arm64". +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index a159d8b..863c7ea 100644 +--- a/setup.py ++++ b/setup.py +@@ -66,7 +66,7 @@ def targeting_x86_32(): + + + def is_aarch64(): +- return platform.machine().lower() == "aarch64" ++ return platform.machine().lower() in ("aarch64", "arm64") + + + def force_intrinsics(): +From 5eac8ae62d8f4e0a574164b73c42837ddc6ff356 Mon Sep 17 00:00:00 2001 +From: Thomas Waldmann +Date: Tue, 29 Mar 2022 20:30:30 +0200 +Subject: [PATCH] c_impl: fix usedforsecurity argument variable type, fixes #34 + +the python docs state that this must be int (not: bool). + +as seen in #34, using the wrong type here seems to overflow the variable +and leads to a wrong value in max_threads, which leads to that strange +test failure. +--- + blake3module.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/blake3module.c b/blake3module.c +index 0fce6ad..a9562cf 100644 +--- a/blake3module.c ++++ b/blake3module.c +@@ -53,7 +53,7 @@ static PyObject *Blake3_new(PyTypeObject *type, PyObject *args, + Py_buffer key = {0}; + const char *derive_key_context = NULL; + Py_ssize_t max_threads = 1; +- bool usedforsecurity = true; ++ int usedforsecurity = 1; + + PyObject *ret = NULL; + diff --git a/dev-python/blake3-py-c/metadata.xml b/dev-python/blake3-py-c/metadata.xml new file mode 100644 index 0000000000000..3091c4dd69fe2 --- /dev/null +++ b/dev-python/blake3-py-c/metadata.xml @@ -0,0 +1,11 @@ + + + + + python@gentoo.org + Python + + + oconnor663/blake3-py + +