#! /usr/bin/make -f
export DH_VERBOSE = 1
export PYBUILD_NAME=fastapi

# tests/test_tutorial/test_sql_databases/test_tutorial -> avoids circular dependency loop with sqlmodel
# test_fastapi_cli -> executes coverage directly and expects fastapi to be fully installed
# ignore::ResourceWarning -> see https://github.com/encode/starlette/pull/2693#issuecomment-2487626977
# tests/test_multipart_installation.py -> now that both multipart and python-multipart are in debian, we need to relax some of these tests, since dont install our own multipart proxy
# tests/test_tutorial/test_graphql, they require https://github.com/strawberry-graphql/strawberry too big to package for a single test
# telemetry tests of the integration with opentelemetry-instrumentation-fastapi and logfire -> neither is available in Debian
# tests/test_translate.py -> tests upstream's docs translation tooling in scripts/, not shipped, and needs git
export PYBUILD_TEST_ARGS=-W ignore::DeprecationWarning \
                         -W ignore::ResourceWarning \
                         --ignore=docs_src/ \
			 --ignore-glob=tests/test_tutorial/test_sql_databases/test_tutorial* \
			 --ignore=tests/test_multipart_installation.py \
			 --ignore=tests/test_tutorial/test_graphql \
			 --ignore=tests/test_translate.py \
			 -k "not test_fastapi_cli \
			     and not test_background_task_integrations \
			     and not test_current_contrib \
			     and not test_current_logfire \
			     and not test_logfire_global_provider_without_fastapi_instrumentor \
			     and not test_logfire_native_spans_and_exception_logs \
			     and not test_registration_provider_prefers_public_metric_reader \
			     and not test_concurrent_provider_owner_wins[True] \
			     and not (test_environment_export_with_existing_integrations and logfire)"

# the telemetry tests export to an OTLP collector on 127.0.0.1, but pybuild
# only exempts localhost from its unreachable http_proxy
export no_proxy=localhost,127.0.0.1

%:
	dh $@ --buildsystem=pybuild

override_dh_installchangelogs:
	dh_installchangelogs docs/en/docs/release-notes.md

# the fastapi command needs fastapi-cli, which is not available in Debian
execute_after_dh_auto_install:
	rm -r debian/python3-fastapi/usr/bin
