#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYVERS:=$(shell pyversions -s)

%:
	dh  $@ --with python2

override_dh_auto_install:
	dh_auto_install
	rm -rf $(CURDIR)/debian/python-unittest2/usr/bin/unit2.py

override_dh_auto_test:
ifeq "$(filter nocheck,$(DEB_BUILD_OPTIONS))" ""
	for python in $(PYVERS) ; 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") ; \
	    # retrieve the script path 
	    SCRIPT=$$($$python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print b.build_scripts") ; \
	    # call the unit2 test script discovering the current LIB dir 
	    PYTHONPATH=$$LIB $$python $$SCRIPT/unit2 discover -s $$LIB ; \
	done
endif
