#!/usr/bin/make -f

PYTHON3=$(shell py3versions -vr)

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

override_dh_auto_install:
	dh_auto_install

	# rename the module
	mv debian/python3-pycallgraph/usr/lib/python3.7/dist-packages/pycallgraph2 debian/python3-pycallgraph/usr/lib/python3.7/dist-packages/pycallgraph
	mv debian/python3-pycallgraph/usr/lib/python3.7/dist-packages/pycallgraph2-1.1.3.egg-info debian/python3-pycallgraph/usr/lib/python3.7/dist-packages/pycallgraph-1.1.3.egg-info

	# and make sure every module/script imports get renamed too
	find debian/python3-pycallgraph/usr/ -type f -exec sed -i 's/pycallgraph2/pycallgraph/g' {} \;

override_dh_auto_test:
	dh_auto_test -- \
		--before-test "cp -r scripts/ {build_dir}" \
		--after-test  "rm -r {build_dir}/scripts {build_dir}//pycallgraph.gdf {build_dir}//pycallgraph.png"

override_dh_installexamples:
	dh_installexamples examples/*

override_dh_installdocs:
	dh_installdocs README.md
