#! /usr/bin/make -f

# export DH_VERBOSE=1
# export DH_OPTIONS=-v
# export PYBUILD_VERBOSE=1

export PYBUILD_TEST_ARGS=-m "not webtest" -k "not (test_suite or test_graph_update or test_create_input_source or test_block_file or test_with_mock or test_query_url_construct_format or TestSPARQLConnector or test_base or test_served or test_guess_format_for_parse or TestGraphHTTP or test_iri_source or test_query_construct_format or TestSPARQLMock or TestSPARQLStoreFakeDBPedia or test_f or test_warning or test_graph_redirect_new_host)"

# test_create_input_source, test_block_file, test_with_mock, test_query_url_construct_format, TestSPARQLConnector, test_base, test_served, test_guess_format_for_parse, TestGraphHTTP, test_iri_source, test_query_construct_format, TestSPARQLMock, TestSPARQLStoreFakeDBPedia, test_graph_redirect_new_host: needs internet
# test_f: breakage from Pytest 8.x
# test_warning: a log message is produced, but no warning; bad test? -> https://github.com/RDFLib/rdflib/issues/2748

export PYBUILD_BEFORE_TEST=cp -r {dir}/examples {build_dir}/
export PYBUILD_AFTER_TEST=rm -Rf {build_dir}/examples

export PYBUILD_NAME=rdflib

# Install (only) those into the -tools package
export PYBUILD_AFTER_INSTALL=rm -rf 'debian/python-rdflib-tools/usr/bin'; mv '{destdir}/usr/bin' 'debian/python-rdflib-tools/usr/'

# upstream requires more recent sphinx now, which we have in stock Debian.
# Dynamically enable nodoc profile if sphinx is too old to simplify backports
SPHINX_VER = $(shell dpkg --compare-versions `dpkg-query -W python3-sphinx | awk '{print $$2;}'` ge 7.1 && echo new || echo old )
ifeq "$(SPHINX_VER)" "old"
    export DEB_BUILD_PROFILES += nodoc
    export DEB_BUILD_OPTIONS += nodoc
endif

ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
    export PYBUILD_AFTER_BUILD={interpreter} -m sphinx {dir}/docs {dir}/build/sphinx/html
endif


%:
	dh $@ --buildsystem=pybuild

override_dh_installexamples:
	dh_installexamples -X.pyc

override_dh_python3:
	dh_python3 --recommends-section=html --recommends-section=berkeleydb --recommends-section=lxml --recommends-section=networkx --recommends-section=orjson
