commit: e5ac8f7bfa74eefd96fc5e23a2da95618dbea70e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 12 16:26:13 2023 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Dec 12 16:27:49 2023 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5ac8f7b
dev-python/blake3: Merge the C impl under USE flag
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
dev-python/blake3/blake3-0.3.4.ebuild | 49 ++++++++++++++++++++++++++++++++---
dev-python/blake3/metadata.xml | 6 +++++
2 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/dev-python/blake3/blake3-0.3.4.ebuild
b/dev-python/blake3/blake3-0.3.4.ebuild
index e7f5b03d69af..d3a711eaac1d 100644
--- a/dev-python/blake3/blake3-0.3.4.ebuild
+++ b/dev-python/blake3/blake3-0.3.4.ebuild
@@ -3,8 +3,9 @@
EAPI=8
+CARGO_OPTIONAL=1
DISTUTILS_EXT=1
-DISTUTILS_USE_PEP517=maturin
+DISTUTILS_USE_PEP517=standalone
PYTHON_COMPAT=( python3_{10..12} )
CRATES="
@@ -66,20 +67,37 @@ HOMEPAGE="
SRC_URI="
https://github.com/oconnor663/blake3-py/archive/${PV}.tar.gz
-> ${MY_P}.gh.tar.gz
- ${CARGO_CRATE_URIS}
+ rust? (
+ ${CARGO_CRATE_URIS}
+ )
"
S=${WORKDIR}/${MY_P}
-LICENSE="|| ( CC0-1.0 Apache-2.0 )"
+LICENSE="
+ || ( CC0-1.0 Apache-2.0 )
+ rust? (
+"
# Dependent crate licenses
LICENSE+="
Apache-2.0-with-LLVM-exceptions BSD-2 MIT Unicode-DFS-2016
|| ( Apache-2.0 CC0-1.0 )
"
+LICENSE+="
+ )
+"
SLOT="0"
KEYWORDS="~amd64"
+IUSE="+rust"
BDEPEND="
+ rust? (
+ ${RUST_DEPEND}
+ dev-util/maturin[${PYTHON_USEDEP}]
+ )
+ !rust? (
+ dev-python/setuptools[${PYTHON_USEDEP}]
+ dev-python/wheel[${PYTHON_USEDEP}]
+ )
test? (
dev-python/numpy[${PYTHON_USEDEP}]
)
@@ -88,3 +106,28 @@ BDEPEND="
QA_FLAGS_IGNORED="usr/lib.*/py.*/site-packages/blake3/blake3.*.so"
distutils_enable_tests pytest
+
+src_unpack() {
+ cargo_src_unpack
+}
+
+src_prepare() {
+ # sed the package name and version to improve compatibility
+ sed -e 's:blake3_experimental_c:blake3:' \
+ -e "s:0[.]0[.]1:${PV}:" \
+ -i c_impl/setup.py || die
+
+ distutils-r1_src_prepare
+}
+
+python_compile() {
+ local DISTUTILS_USE_PEP517=$(usex rust maturin setuptools)
+
+ if ! use rust; then
+ cd c_impl || die
+ fi
+ distutils-r1_python_compile
+ if ! use rust; then
+ cd - >/dev/null || die
+ fi
+}
diff --git a/dev-python/blake3/metadata.xml b/dev-python/blake3/metadata.xml
index ea862e0f3e8e..55ea3bd9e001 100644
--- a/dev-python/blake3/metadata.xml
+++ b/dev-python/blake3/metadata.xml
@@ -9,4 +9,10 @@
<remote-id type="github">oconnor663/blake3-py</remote-id>
<remote-id type="pypi">blake3</remote-id>
</upstream>
+ <use>
+ <flag name="rust">
+ Build the Rust implementation (if disabled, the
"experimental"
+ C implementation is used instead).
+ </flag>
+ </use>
</pkgmetadata>