#!/usr/bin/make -f

export DH_ALWAYS_EXCLUDE=__pycache__
export PYBUILD_TEST_PYTEST=1

# Some things have to be done for a smooth run of tests using pytest:
#   - pytest has to find tests in the source tree.
#   - resources expected for tests have to be copied to build dir.
#   - egg-info has to be available so pkg_resources can find the module.
export PYBUILD_TEST_ARGS={build_dir}/tests
export PYBUILD_BEFORE_TEST=cp -r {dir}/docs {dir}/README.rst {build_dir}; {interpreter} {dir}/setup.py egg_info -e {build_dir}
export PYBUILD_AFTER_TEST=cd {build_dir}; rm -rf docs README.rst *.egg-info

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

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .eggs

override_dh_installchangelogs:
	 dh_installchangelogs CHANGES.rst

override_dh_auto_install:
	dh_auto_install
	cd docs ; env PYTHONPATH=$(CURDIR) make html

override_dh_auto_test:
	env PYTHONPATH=$(CURDIR) dh_auto_test
