#!/usr/bin/make -f

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

export PYBUILD_NAME=sushy

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

override_dh_auto_clean:
	echo "Do nothing..."

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)))
	PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages pkgos-dh_auto_test --no-py2
endif

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# Only run sushy’s own tests; skip sushy_oem_idrac entirely
        # sushy-oem-idrac has not been updated in over a year and 
        # has many failing unit tests (LP: #2126697)
	OS_TEST_PATH=sushy/tests/unit \
	PYTHONPATH=$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages \
	pkgos-dh_auto_test --no-py2 --no-parallel
endif

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=. PYTHON=python3 python3 -m sphinx -b html doc/source debian/python-sushy-doc/usr/share/doc/python-sushy-doc/html
	dh_sphinxdoc -O--buildsystem=pybuild
endif

override_dh_clean:
	dh_clean -O--buildsystem=pybuild
	rm -rf build
