#!/usr/bin/make -f

PKGS = $(shell dh_listpackages)

export PYBUILD_NAME=django-registration
export PYBUILD_TEST_CUSTOM=1
export PYBUILD_TEST_ARGS=cd {dir}; PYTHONPATH={dir}/src {interpreter} {dir}/runtests.py

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

override_dh_auto_clean:
	rm -rf docs/_build/
	dh_auto_clean

override_dh_auto_build:
	cd src/django_registration && /usr/bin/django-admin compilemessages
	cd docs && $(MAKE) html
	dh_auto_build

override_dh_auto_install:
	# dh_auto_install expects the following directory to exist (before it
	# is created?)
	mkdir -p debian/python-django-registration-doc
	dh_auto_install
	# Drop .po files and keep only .mo files (compiled)
	$(foreach P,$(PKGS),find debian/$(P)/ -name '*.po' -exec rm -v {} \; ;)
