#!/usr/bin/make -f

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

export PYBUILD_TEST_ARGS=--no-cov

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	# Use the changelog version in the wheel, then restore the source files.
	set -e; \
	backup_dir=$$(mktemp -d); \
	cp -p pyproject.toml airthings_ble/__init__.py "$$backup_dir/"; \
	trap 'mv "$$backup_dir/pyproject.toml" pyproject.toml; mv "$$backup_dir/__init__.py" airthings_ble/__init__.py; rmdir "$$backup_dir"' EXIT; \
	sed -i 's/^version = ".*"$$/version = "$(DEB_VERSION_UPSTREAM)"/' pyproject.toml; \
	sed -i 's/^__version__ = ".*"$$/__version__ = "$(DEB_VERSION_UPSTREAM)"/' airthings_ble/__init__.py; \
	dh_auto_build
