#!/usr/bin/make -f

export PYBUILD_NAME=pyflakes

# Some tests require that the bin/pyflakes script be available one directory
# up relative to the package directory.  When the tests are run during the
# build, this won't be the case, because pybuild cd's to a directory that
# doesn't have this installed.  Create the necessary paths, run the tests,
# then delete the paths.
export PYBUILD_BEFORE_TEST=mkdir -p {build_dir}/bin && ln -s $(CURDIR)/bin/pyflakes {build_dir}/bin/pyflakes
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/bin


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

override_dh_installchangelogs:
	dh_installchangelogs NEWS.txt

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/pyflakes/usr/bin
	mkdir -p debian/pyflakes3/usr/bin
	mv debian/python-pyflakes/usr/bin/pyflakes debian/pyflakes/usr/bin/pyflakes
	mv debian/python3-pyflakes/usr/bin/pyflakes debian/pyflakes3/usr/bin/pyflakes3
	sed -i '1s/3.*/2.7/' ./debian/pyflakes/usr/bin/pyflakes
	sed -i '1s/3.*/3/' ./debian/pyflakes3/usr/bin/pyflakes3
