#!/usr/bin/make -f

export PYBUILD_TEST_CUSTOM=1
# Exclude testrunner-eggsupport.rst because zope.testrunner isn't
# sufficiently installed while running its tests here for ftest to show up
# as an entry point.
export PYBUILD_TEST_ARGS={interpreter} -m zope.testrunner --test-path . -vv -t '!testrunner-eggsupport\.rst'

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

PACKAGE_PYTHON3=python3-zope.testrunner

PYTHON3=$(shell py3versions -r)

override_dh_auto_install:
	dh_auto_install
	
	ln -sf zope-testrunner \
	  debian/$(PACKAGE_PYTHON3)/usr/bin/zope-testrunner3

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3 -X tests
	
override_dh_gencontrol:
	dh_gencontrol
	
	# Workaround for dh_python3 not removing python-setuptools from requires.txt
	find debian/$(PACKAGE_PYTHON3) -name requires.txt -exec sed -i '/^setuptools$$/d' {} \;

override_dh_installchangelogs:
	dh_installchangelogs CHANGES.rst
