#!/usr/bin/make -f

SHELL := /bin/bash

override_dh_auto_build:
	dh_auto_build
	mkdir -p build/$(shell python3 -c "import sys; print('scripts-%d.%d' % sys.version_info[:2])")
	python3 setup.py bdist_wheel

override_dh_auto_install:
	ln -s setuptools/_distutils distutils
	PYTHONPATH=. dh_auto_install --destdir=debian/tmp
	unlink distutils
	install -Dpm644 -t debian/tmp/usr/lib/python*/*-packages _distutils_system_mod.py
	install -Dpm755 -d debian/tmp/usr/share/python-wheels
	install -Dpm644 -t debian/tmp/usr/share/python-wheels dist/*.whl
	rm -rf debian/tmp/usr/lib/python*/*-packages/pkg_resources/tests
	find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \;
	fdupes -qnrps debian/tmp/usr/lib/python*/*-packages

override_dh_auto_test:

override_dh_auto_clean:

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