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

EAPI=8

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

inherit distutils-r1 pypi

DESCRIPTION="Matplotlib Jupyter Extension"
HOMEPAGE="https://matplotlib.org/"
SRC_URI="$(pypi_sdist_url "${PN^}" "${PV}")"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~arm64"

RDEPEND="
	dev-python/ipython[${PYTHON_USEDEP}]
	>=dev-python/ipywidgets-7.6.0[${PYTHON_USEDEP}]
	>=dev-python/matplotlib-3.5.0[${PYTHON_USEDEP}]
	dev-python/numpy[${PYTHON_USEDEP}]
	dev-python/pillow[${PYTHON_USEDEP}]
	<dev-python/traitlets-6[${PYTHON_USEDEP}]
"
EPYTEST_PLUGINS=()
distutils_enable_tests pytest

src_prepare() {
	# The separate lab-extension package handles npm; remove its Hatch hook.
	grep -qF '[tool.hatch.build.hooks.jupyter-builder]' pyproject.toml ||
		die "jupyter-builder anchor moved"
	sed -i '/^\[tool\.hatch\.build\.hooks\.jupyter-builder/,/^\[/{/^\[tool\.hatch\.build\.hooks\.jupyter-builder/d;/^\[/!d}' \
		pyproject.toml || die
	distutils-r1_src_prepare
}