#!/usr/bin/make -f

UPSTREAM_GIT := https://github.com/django/django-formtools.git
include /usr/share/openstack-pkg-tools/pkgos.make

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

override_dh_auto_clean:
	rm -rf build

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_test:
	echo "Do nothing..."

override_dh_auto_install:
	pkgos-dh_auto_install --no-py2

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	set -e ; set -x ; for pyvers in $(PYTHON3S); do \
		PYMAJOR=`echo $$pyvers | cut -d'.' -f1` ; \
		echo "===> Testing with python$$pyvers (python$$PYMAJOR)" ; \
		if [ $$PYMAJOR = "2" ] ; then \
			LIBDIR_END=$$pyvers ; \
		else \
			LIBDIR_END=$$PYMAJOR ; \
		fi ; \
		PYTHONPATH=. DJANGO_SETTINGS_MODULE=tests.settings PYTHON=python$${pyvers} python$${PYMAJOR}-coverage run /usr/lib/python$$LIBDIR_END/dist-packages/django/bin/django-admin.py test tests ; \
	done
endif


override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. python3 -m sphinx -b html docs debian/python-django-formtools-doc/usr/share/doc/python-django-formtools-doc/html
	dh_sphinxdoc
endif
