# Template file for 'duckdb'
pkgname=duckdb
version=1.1.1
revision=1
archs="x86_64* aarch64*" # 32-bit FTBFS
build_style=cmake
build_helper="python3"
configure_args="-DOVERRIDE_GIT_DESCRIBE=v${version}-0-gdeadbeeff
 -DBUILD_EXTENSIONS='autocomplete;icu;fts;httpfs;json;parquet'"
hostmakedepends="pkg-config python3-build python3-installer python3-setuptools_scm
 python3-wheel python3-pybind11"
makedepends="openssl-devel"
short_desc="In-process SQL OLAP database management system"
maintainer="icp <pangolin@vivaldi.net>"
license="MIT"
homepage="https://duckdb.org"
changelog="https://github.com/duckdb/duckdb/releases"
distfiles="https://github.com/duckdb/duckdb/archive/refs/tags/v${version}.tar.gz"
checksum=a764cef80287ccfd8555884d8facbe962154e7c747043c0842cd07873b4d6752

case "${XBPS_TARGET_MACHINE}" in
	x86_64*) configure_args+=" -DDUCKDB_EXPLICIT_PLATFORM=linux_amd64" ;;
	aarch64*) configure_args+=" -DDUCKDB_EXPLICIT_PLATFORM=linux_arm64" ;;
esac

post_build() {
	SETUPTOOLS_SCM_PRETEND_VERSION="${version}" python3 -m build \
		--no-isolation --wheel tools/pythonpkg
}

post_install() {
	python3 -m installer --destdir "${DESTDIR}" --no-compile-bytecode \
		tools/pythonpkg/dist/duckdb-${version}-*-*-*.whl

	rm "${DESTDIR}/usr/"{includes,sources}.list
	rm -r "${DESTDIR}/usr/duckdb_build"

	vlicense LICENSE
}

duckdb-devel_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/cmake
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}

python3-duckdb_package() {
	short_desc+=" - python bindings"
	pkg_install() {
		vmove "${py3_sitelib}"
	}
}
