#!/usr/bin/make -f

export PYBUILD_NAME = quark-engine
export DH_VIRTUALENV_INSTALL_ROOT = /usr/share/

PYTHON_VERSION := $(shell python3 -c "import sys; v = sys.version_info; print(f'{v.major}.{v.minor}')")
PYTHON_NEXT_VERSION := $(shell python3 -c "import sys; v = sys.version_info; print(f'{v.major}.{v.minor + 1}')")

%:
	dh $@ --with python-virtualenv

# Workaround outdated buildsystem:
# ```
# dh_auto_configure: warning: Please use the third-party "pybuild" build system instead of python-distutils
# dh_auto_configure: error: This feature was removed in compat 12.
# make: *** [debian/rules:7: binary] Error 255
# ```
# Drop this workaround when upstream switches to pyproject or something.
# References: #984767 and https://github.com/spotify/dh-virtualenv/issues/326
override_dh_auto_configure:
	echo -e 'clean:\n\trm Makefile' > Makefile

override_dh_auto_test:
	# Skip tests, need network

# Package needs a rebuild when a new python3 version becomes the default
override_dh_gencontrol:
	dh_gencontrol -- -Vpython3:Depends="python3 (>= $(PYTHON_VERSION)), python3 (<< $(PYTHON_NEXT_VERSION))"

# Don't let dh touch shared libraries, cf. howtos.rst
override_dh_dwz:

override_dh_strip:
	dh_strip --exclude=/site-packages/

override_dh_shlibdeps:
	dh_shlibdeps --exclude=/site-packages/
