#!/usr/bin/make -f
#export DH_VERBOSE=1
#export DEB_BUILD_OPTIONS=nocheck
export PYBUILD_NAME=pydocstyle
export PYBUILD_AFTER_INSTALL=rm -rf {destdir}/usr/bin

# skip test_integration (install_package needs fix, doesn't run with py3, writes into /usr/local etc.)
# https://github.com/PyCQA/pydocstyle/issues/177
export PYBUILD_BEFORE_TEST=cp -r src/tests {build_dir}
export PYBUILD_TEST_ARGS=-x tests/test_d*
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/tests

DEBDATE := $(shell dpkg-parsechangelog -Sdate | date -u +%F -f -)

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	python3 setup.py install_scripts --skip-build \
		--install-dir=debian/$(PYBUILD_NAME)/usr/bin

override_dh_installchangelogs:
	dh_installchangelogs docs/release_notes.rst

override_dh_installman:
	PYTHONPATH=./src python3 -m sphinx -D today_fmt="$(DEBDATE)" -N -bman docs .pybuild
	dh_installman .pybuild/pydocstyle.1
