#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYTHON3=$(shell py3versions -r)

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

override_dh_installexamples:
	dh_installexamples -A examples/*.py

override_dh_install:
	set -e; \
	for python in $(PYTHON3); do \
		$$python setup.py install --install-layout=deb --root $(CURDIR)/debian/python3-mysql.connector ; \
	done
	dh_install

override_dh_installdocs:
	dh_installdocs -A docs/README_DOCS.txt README.txt

override_dh_auto_test:
	echo pass
# dont try to run the test suite anymore: it's becoming more and more
# difficult to maintain compatibility between mysql and mariadb; last straw was
# tha mariadb now requires to run `mysql_install_db` to initialize a new instance, while
# mysql still allows to run `mysqld --bootstrap` to do that; too much time was
# spent to make it possibile to use mariadb but it was ultimately wased
# as now tests/mysqldb.py:bootstrap() should invoke `mysql_install_db` +
# start mysqld on the bootstrapped datadir - this is too much
#ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
#	-for python in $(PYTHON2) $(PYTHON3); do \
#		LIB=$$($$python -c "from distutils.command.build import build ; from distutils.core import Distribution ; b = build(Distribution()) ; b.finalize_options() ; print (b.build_purelib)") ;\
#		mkdir -p $(CURDIR)/mysql_myconnpy/ ; \
#		PYTHONPATH=$(CURDIR)/$$LIB $$python unittests.py --with-mysql=/usr/ --mysql-topdir=$(CURDIR)/mysql_myconnpy/ --verbosity=2 --bind-address=:: --host=::1 --stats ; \
#		rm -rf $(CURDIR)/mysql_myconnpy/ ; \
#	done
#endif
