#! /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 -> needs strawberry-graphql, which build-depends on fastapi (a b-d cycle) and is not in testing
# 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
# telemetry tests exporting via OTLP HTTP -> opentelemetry-exporter-otlp-proto-http 1.45.1-1 can't be imported (#1151142); re-enable once fixed
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) \
			     and not test_request_objects_are_not_exported \
			     and not test_environment_export_with_existing_integrations \
			     and not test_sentry_standard_log_processor \
			     and not test_real_otlp_export_and_repeated_lifespans \
			     and not test_concurrent_provider_owner_wins[False] \
			     and not test_environment_export_initializes_after_fork \
			     and not test_real_otlp_exception_export_without_traces_or_metrics \
			     and not test_unsupported_provider_warns_without_preventing_startup \
			     and not test_failed_registration_closes_new_exporter"

# 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
