#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
PYTHONS:=$(shell pyversions -vr)
PYTHON3S:=$(shell py3versions -vr)
PYVERS=$(shell pyversions -r)
PY3VERS=$(shell py3versions -r)

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

override_dh_auto_install:
	set -e && for pyvers in $(PYTHONS); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python-pep8; \
	done

	set -e && for pyvers in $(PYTHON3S); do \
		python$$pyvers setup.py install --install-layout=deb \
			--root $(CURDIR)/debian/python3-pep8; \
	done
	rm -rf debian/python-pep8/usr/bin
	rm -rf debian/python3-pep8/usr/bin

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -xe; \
	for py in $(PYVERS) $(PY3VERS); do \
		$$py setup.py test; \
	done
endif

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
