#!/usr/bin/make -f
#export DH_VERBOSE=1
export PYBUILD_NAME=pies

PIES2OVERRIDES_PKG=debian/python-pies2overrides

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

override_dh_auto_build:
	dh_auto_build -O--buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install -O--buildsystem=pybuild
	# manual install of pies2overrides because dh_python2 can't handle two
	# packages, and pyinstall can't install to empty namespace
	$(foreach dir,html http xmlrpc,$(shell mkdir -p $(PIES2OVERRIDES_PKG)/usr/lib/python2.7/dist-packages/$(dir)))
	for file in $$(tail -n+2 pies2overrides/MANIFEST | grep -v setup.py); do \
		cp pies2overrides/$$file \
			$(PIES2OVERRIDES_PKG)/usr/lib/python2.7/dist-packages/$$file; \
	done
	# Don't install xmlrpc since it conflicts with python-future and is
	# not used by anything in the archive
	rm -rf $(PIES2OVERRIDES_PKG)/usr/lib/python2.7/dist-packages/xmlrpc
