# Template file for 'python3-scikit-image'
pkgname=python3-scikit-image
version=0.21.0
revision=1
build_style=meson
build_helper="python3"
hostmakedepends="python3-build python3-installer python3-meson-python
 python3-wheel python3-setuptools python3-packaging python3-Cython pythran
 python3-lazy_loader python3-numpy pkg-config"
makedepends="python3-devel python3-numpy pythran"
depends="python3-numpy python3-scipy python3-networkx python3-Pillow
 python3-imageio python3-tifffile python3-pywt python3-packaging
 python3-lazy_loader"
short_desc="Image processing in Python"
maintainer="Andrew J. Hesford <ajh@sideband.org>"
license="BSD-3-Clause, MIT"
homepage="https://scikit-image.org/"
distfiles="https://github.com/scikit-image/scikit-image/archive/v${version}.tar.gz"
checksum=53a82a9dbd3ed608d2ad3876269a271a7e922b12e228388eac996b508aadd652
# Tests require data files and unpackaged dependencies
make_check=no

if [ "${CROSS_BUILD}" ]; then
	configure_args="--cross-file=python.cross"
fi

pre_patch() {
	if [ "${CROSS_BUILD}" ]; then
		# Meson can't tolerate $CC with arguments as set by build helper
		CC="${XBPS_CROSS_TRIPLET}-gcc"
		# CXX needs to know where to find Python headers
		CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}"
	fi
}

post_patch() {
	if [ "${CROSS_BUILD}" ]; then
		local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}"
		cat > python.cross <<-EOF
		[properties]
		numpy-include-dir = '${_xpy}/numpy/core/include'
		pythran-include-dir = '${_xpy}/pythran'
		EOF
	fi
}

do_build() {
	# Use the build directory already configured by xbps-src for meson
	python3 -m build --no-isolation --wheel \
		-Cbuilddir="./build" -Ccompile-args="${makejobs}" .
}

do_install() {
	python3 -m installer --destdir "${DESTDIR}" \
		--no-compile-bytecode dist/*.whl
	vlicense LICENSE.txt
}
