#!/usr/bin/make -f

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

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

override_dh_auto_install:
	# Install the docs with sphinx
	PYTHONPATH=$(CURDIR) sphinx-build -b html -a -c docs/source docs/source \
	    $(CURDIR)/debian/python-cliff-doc/usr/share/doc/python-cliff-doc/html
	set -e && for pyvers in $(PYTHONS); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python-cliff; \
	done
	set -e && for pyvers in $(PYTHON3S); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python3-cliff; \
	done

override_dh_installchangelogs:
	dh_installchangelogs -O--buildsystem=python_distutils docs/source/history.rst

override_dh_clean:
	dh_clean
	rm -rf cliff.egg-info build pbr-*.egg

override_dh_python2:
	dh_python2 -O--buildsystem=python_distutils -ppython-cliff

override_dh_python3:
	dh_python3 -O--buildsystem=python_distutils -ppython3-cliff

override_dh_sphinxdoc:
	dh_sphinxdoc -O--buildsystem=python_distutils -ppython-cliff-doc

override_dh_compress:
	dh_compress -O--buildsystem=python_distutils -i -X.rst -X.js -X.html -X.txt -X.py

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	set -e -x; \
	PYTHONPATH=$(CURDIR)/build/lib.* python setup.py nosetests
endif

