#!/usr/bin/make -f
PYTHON2_VERSIONS=$(shell pyversions -vr)
PYTHON3_VERSIONS=$(shell py3versions -vr)
export PYBUILD_NAME = pexpect

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

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .coverage
#	rm -rf tests/log

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Testsuite disabled because it timeouts
test-python2-%:
	#PYTHON=python$* py.test

test-python3-%:
	#PYTHON=python$* py.test-3

override_dh_auto_test: $(foreach pyversion,${PYTHON2_VERSIONS},$(pyversion:%=test-python2-%)) $(foreach pyversion,${PYTHON3_VERSIONS},$(pyversion:%=test-python3-%))
endif

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml doc/ build/html

override_dh_installdocs:
	dh_installdocs -ppython-pexpect-doc build/html
	dh_installdocs -A

override_dh_install:
	dh_install
	# async.py is python3 only and can't be compiled for python2
	# https://github.com/pexpect/pexpect/issues/290
	rm $(CURDIR)/debian/python-pexpect/usr/lib/python2.7/dist-packages/pexpect/async.py
