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

EAPI=8

DISTUTILS_EXT=1
DISTUTILS_USE_PEP517=scikit-build-core
PYTHON_COMPAT=( python3_{10..13} )

inherit distutils-r1

DESCRIPTION="PDAL Python bindings"
HOMEPAGE="https://github.com/PDAL/python"
SRC_URI="https://github.com/PDAL/python/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RDEPEND="
    >=dev-python/numpy-1.22[${PYTHON_USEDEP}]
    dev-libs/jsoncpp
    >=sci-libs/pdal-2.7
"

DEPEND="${RDEPEND}"

BDEPEND="
    >=dev-build/cmake-3.16
    dev-python/pybind11
    >=dev-python/scikit-build-core-0.9
"

distutils_enable_tests pytest

src_unpack() {
    unpack ${A}
    mv "${WORKDIR}/python-${PV}" "${WORKDIR}/pypdal-${PV}"
}

src_prepare() {
    eapply_user

    sed -i -e '/cmake_minimum_required/s/3.11/3.16/' "${WORKDIR}/pypdal-${PV}"/CMakeLists.txt || die
    sed -i -e '/cmake.build-type/s/Release/RelWithDebInfo/' "${WORKDIR}/pypdal-${PV}"/pyproject.toml || die
}