# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_USE_PEP517=standalone
PYTHON_COMPAT=( python3_{12..14} )

inherit distutils-r1

DESCRIPTION="ML-based content (data type) detection and classification"
HOMEPAGE="https://github.com/google/magika https://pypi.org/project/magika/"

# Upstream ships a single platform-tagged (no ABI) wheel with the ONNX models
# bundled; only x86_64 is published for Linux.
_WHL_AMD64="magika-${PV}-py3-none-manylinux_2_28_x86_64.whl"
SRC_URI="https://files.pythonhosted.org/packages/d6/78/4f341c974130a464f08813d54113ed9e63d5e9c963fbe398300838922a67/${_WHL_AMD64}"
S="${WORKDIR}"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="-* ~amd64"
RESTRICT="mirror strip test"

RDEPEND="
	dev-python/click[${PYTHON_USEDEP}]
	>=sci-libs/onnxruntime-1.24.1[python,${PYTHON_USEDEP}]
"

src_unpack() {
	:
}

src_compile() {
	:
}

python_install() {
	# the wheel carries a console script and the wheel installer refuses
	# to overwrite; drop the copy left by the previous python target
	rm -f "${ED}/usr/bin/magika" || die
	distutils_wheel_install "${ED}" "${DISTDIR}/${_WHL_AMD64}"
}