#!/usr/bin/make -f
#
# Build Debian package using https://github.com/spotify/dh-virtualenv
#
# Note that this only works after applying
#   https://github.com/spotify/dh-virtualenv/pull/43
# (at least with some versions of virtualenv)

# The below targets create a clean copy of the workdir via
# using "sdist", else "pip" goes haywire when installing from
# sourcedir ".", because that includes the debian build stage,
# and a recursive explosion ensues when symlinks are followed.

DH_VENV_ARGS=--with python-virtualenv --setuptools --python /usr/bin/python #-v

clean:
	test ! -d dist || rm -rf dist
	test ! -d debian/sdist || rm -rf debian/sdist
	dh $@ $(DH_VENV_ARGS)

build-arch:
	/usr/bin/python setup.py sdist --formats tar
	mkdir -p debian/sdist
	tar -x -C debian/sdist --strip-components=1 --exclude '*.egg-info' -f dist/*.tar
	dh $@ $(DH_VENV_ARGS) --sourcedir debian/sdist

%:
	dh $@ $(DH_VENV_ARGS) --sourcedir debian/sdist
