#!/usr/bin/make -f

include /usr/share/openstack-pkg-tools/pkgos.make

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

override_dh_auto_clean:
	rm -rf build .pybuild
	rm -rf .stestr *.egg-info .coverage
	find . -iname '*.pyc' -delete
	for i in $$(find . -type d -iname __pycache__) ; do rm -rf $$i ; done

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_install:
	pkgos-dh_auto_install --no-py2

	# Activates the mistraldashboard plugin in Horizon
	# mistraldashboard/enabled/_50_mistral.py
	mkdir -p $(CURDIR)/debian/python3-mistral-dashboard/usr/lib/python3/dist-packages/openstack_dashboard/enabled
	cp $(CURDIR)/mistraldashboard/enabled/_[0-9]*.py $(CURDIR)/debian/python3-mistral-dashboard/usr/lib/python3/dist-packages/openstack_dashboard/enabled

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	DJANGO_SETTINGS_MODULE=mistraldashboard.test.settings \
		python3-coverage run \
		$(CURDIR)/manage.py test mistraldashboard --settings=mistraldashboard.test.settings
	## Delete __pycache__
	find . -name __pycache__ -prune -exec rm -rf {} +;
endif
