From e5ac8f7bfa74eefd96fc5e23a2da95618dbea70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 12 Dec 2023 17:26:13 +0100 Subject: [PATCH] dev-python/blake3: Merge the C impl under USE flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- 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 e7f5b03d69af8..d3a711eaac1d3 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 ea862e0f3e8e7..55ea3bd9e0015 100644 --- a/dev-python/blake3/metadata.xml +++ b/dev-python/blake3/metadata.xml @@ -9,4 +9,10 @@ oconnor663/blake3-py blake3 + + + Build the Rust implementation (if disabled, the "experimental" + C implementation is used instead). + +