#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	# Release tarballs have no Git metadata for uv-dynamic-versioning.
	set -eu; \
	backup=$$(mktemp); \
	cp -p pyproject.toml "$$backup"; \
	trap 'mv "$$backup" pyproject.toml' EXIT; \
	sed -i -e 's/^dynamic = \["version"\]$$/version = "$(DEB_VERSION_UPSTREAM)"/' \
		-e 's/^requires = \["hatchling", "uv-dynamic-versioning"\]$$/requires = ["hatchling"]/' \
		-e '/^\[tool\.hatch\.version\]$$/,/^$$/d' \
		pyproject.toml; \
	dh_auto_build
