#!/usr/bin/make -f
# -*- makefile -*-

export PYBUILD_NAME=pytest

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

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(CURDIR) $(MAKE) -C doc/en man html
	cp doc/en/_build/man/pytest.1 debian/py.test.1
	cp debian/py.test.1 debian/py.test-3.1
	sed -i 's/PYTEST/PY.TEST/g' debian/py.test.1
	sed -i 's/PYTEST/PY.TEST-3/g' debian/py.test-3.1
	sed -i 's/py\.test/py.test-3/g' debian/py.test-3.1

# 2015-12-16 barry@debian.org: Because pytest does not clean up after itself,
# use a custom temporary directory (which is easier to clean up manually,
# e.g. in an sbuild).
override_dh_auto_test:
	mkdir -p debian/tmp/test-working-directory
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="cd debian/tmp/test-working-directory && {interpreter} -m pytest --lsof -rfsxX --ignore={dir}/testing/cx_freeze {dir}/testing" dh_auto_test

override_dh_auto_install:
	dh_auto_install
	mv debian/python3-pytest/usr/bin/py.test \
	   debian/python3-pytest/usr/bin/py.test-3

override_dh_auto_clean:
	rm -rf doc/en/_build
	rm -rf pytest.egg-info .cache
	dh_auto_clean
