#!/usr/bin/make -f

export DH_VERBOSE=1
export PYBUILD_NAME=enable

# Install egg-info directories
DEB_PYTHON_INSTALL_ARGS_ALL += --single-version-externally-managed
PY3VERS := $(shell py3versions -r)

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

override_dh_compress:
	dh_compress -X.py

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	xvfb-run -a dh_auto_test
endif

override_dh_install:
	dh_install
	for PYTHON in $(PY3VERS); do \
		rm debian/python3-enable/usr/lib/$$PYTHON/dist-packages/*.png; \
		rm debian/python3-enable/usr/lib/$$PYTHON/dist-packages/*.bmp; \
	done

override_dh_fixperms:
	dh_fixperms
	find debian/python3-enable/usr/lib/python3/ -name "*.py" -type f | xargs sed -i -e "1s#usr/bin/env\s\+python\s*\$$#usr/bin/env python3#"
	chmod -x debian/python3-enable/usr/lib/python3/dist-packages/kiva/agg/tests/gcmemtest.py

get-orig-source:
	-uscan --force-download --rename
