#!/usr/bin/make -f

export PYBUILD_NAME=tooz

UPSTREAM_GIT := https://github.com/openstack/tooz.git
include /usr/share/openstack-pkg-tools/pkgos.make

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

override_dh_auto_clean:
	rm -rf build TEST_PID_MEMCACHE.pid .stestr

override_dh_auto_build:
	echo "Do nothing..."

override_dh_auto_install:
	for i in $(PYTHON3S) ; do \
		python3 setup.py install -f --install-layout=deb --root=$(CURDIR)/debian/tmp ; \
	done
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	chmod +x $(CURDIR)/debian/check-memcached-off $(CURDIR)/debian/check-memcached-runs
	$(CURDIR)/debian/check-memcached-runs
	PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages TOOZ_TEST_URL="ipc://" pkgos-dh_auto_test --no-py2 'tooz\.tests\.(?!(.*test_coordination\.TestAPI\.test_get_lock_multiple_coords.*|drivers\.test_mysql\.TestMySQLDriver\.test_parsing_blocking_settings|drivers\.test_mysql\.TestMySQLDriver\.test_parsing_timeout_settings|test_coordination\.TestAPI\.test_lock_context_manager_acquire_argument))'
	$(CURDIR)/debian/check-memcached-off
endif

override_dh_auto_test:
	echo "Do nothing..."

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	python3 -m sphinx -b html doc/source $(CURDIR)/debian/python-tooz-doc/usr/share/doc/python-tooz-doc/html
	dh_sphinxdoc
endif
