#!/usr/bin/make -f

PYTHONS:=$(shell pyversions -vr)

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

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

override_dh_clean:
	dh_clean -O--buildsystem=python_distutils
	rm -rf *.egg-info

override_dh_sphinxdoc:
	sphinx-build -b html docs $(CURDIR)/debian/python-concurrent.futures/usr/share/doc/python-concurrent.futures/html
	dh_sphinxdoc -O--buildsystem=python_distutils

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -e ; \
	for python in $(shell pyversions -r); do \
		# retrive the lib path \
		LIB=$$($$python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print b.build_purelib") ; \
		PYTHONPATH=$$LIB $$python ./test_futures.py ; \
	done
endif

override_dh_installexamples:
	dh_installexamples -O--buildsystem=python_distutils crawl.py primes.py
