#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

export PYBUILD_TEST_ARGS=--pyargs codespell_lib -k "not test_permission_error"
export PYBUILD_AFTER_TEST=find {dir} -name junit-results.xml -delete

%:
	dh $@ --buildsystem=pybuild

override_dh_installman:
	PYTHONPATH=`ls -d ./debian/codespell/usr/lib/python3*/dist-packages/` \
	help2man ./debian/codespell/usr/bin/codespell --include codespell.1.include --no-info --output codespell.1 --no-discard-stderr
	if grep "ModuleNotFoundError: No module named" codespell.1; then exit 1; fi
	sed -i '/\.SS \"Usage/,+2d' codespell.1
	dh_installman

override_dh_clean:
	rm -rf codespell.egg-info .cache .coverage dist venv
	dh_clean
