#!/usr/bin/make -f

PYTHONS:=$(shell pyversions -vr)
PYTHON3S:=$(shell py3versions -vr)

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

override_dh_install:
	set -e ; for pyvers in $(PYTHONS); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python-repoze.who; \
	done
	set -e ; for pyvers in $(PYTHON3S); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python3-repoze.who; \
	done
	rm -rf $(CURDIR)/debian/python*/usr/lib/python*/dist-packages/*.pth

	find $(CURDIR)/debian/python-repoze.who -iname __pycache__ -exec rm -rf {} \;

override_dh_clean:
	dh_clean -O--buildsystem=python_distutils
	rm -rf docs/.build build

override_dh_auto_build:
	$(MAKE) -C docs/ html

override_dh_auto_install:
	dh_auto_install
	find debian/ -name '*.pth' -delete


override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	nosetests
	nosetests3
endif
