#!/usr/bin/make -f

export PACKAGE_VERSION=$(shell dpkg-parsechangelog -S Version | sed -e 's/^[[:digit:]]*://' -e 's/[-].*//' -e 's/~/.0/')

PYTHON3:=$(shell py3versions -r)
py3sdo=set -ex; $(foreach py, $(PYTHON3), $(py) $(1);)

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

%:
	dh $@ --with python2,python3

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	nosetests -v
	nosetests3 -v
endif

override_dh_auto_build:
	echo $$PACKAGE_VERSION  | sed s/\\./-/g >version.txt
	dh_auto_build
	$(call py3sdo, setup.py build)

override_dh_auto_install:
	dh_auto_install
	$(call py3sdo, setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb)

override_dh_auto_clean:
	echo $$PACKAGE_VERSION  | sed s/\\./-/g >version.txt
	dh_auto_clean
	rm -rf build version.txt jsonschema/_version.py
	rm -rf __pycache__
