#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

ifneq (,${PYBUILD_AUTOPKGTEST})
TESTDIR=/usr/lib/python3/dist-packages/pyresample/test
else
TESTDIR=pyresample/test
endif

export PYBUILD_NAME=pyresample
export USE_CYTHON=True
export PYBUILD_TEST_ARGS=\
-k "not test_compare_to_legacy \
and not test_get_sample_from_bil_info_1d \
and not test_to_odc_geobox \
and not test_area_def_cartopy_installed \
and not test_area_repr_w_static_files \
and not test_area_repr_wo_static_files" \
--ignore $(TESTDIR)/test_resamplers/test_nearest.py \
--ignore $(TESTDIR)/test_resamplers/test_resampler.py \
--ignore $(TESTDIR)/test_dask_ewa.py \
--ignore $(TESTDIR)/test_formatting.py \
--ignore $(TESTDIR)/test_geometry/test_area.py \
--ignore $(TESTDIR)/test_geometry/test_area_boundary.py \
--ignore $(TESTDIR)/test_geometry/test_swath.py \
--ignore $(TESTDIR)/test_geometry/test_swath_boundary.py \
--ignore $(TESTDIR)/test_geometry_legacy.py \
--ignore $(TESTDIR)/test_resamplers/test_resampler_registry.py \
--ignore $(TESTDIR)/test_utils.py \
--pyargs ${PYBUILD_NAME}

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build: export http_proxy=127.0.0.1:9
execute_after_dh_auto_build: export https_proxy=127.0.0.1:9
execute_after_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	env PYTHONPATH=$(shell pybuild --build -i python3 -s custom --build-args 'echo {build_dir}') \
	sphinx-build -N -E -T -b html $(CURDIR)/docs/source $(CURDIR)/.pybuild/docs/html
	$(RM) -r $(CURDIR)/.pybuild/docs/html/_static/images
	$(RM) -r $(CURDIR)/.pybuild/docs/html/.doctrees
else
	mkdir -p $(CURDIR)/.pybuild/docs/html
endif


override_dh_auto_install:
	dh_auto_install -ppython-pyresample-test --buildsystem=pybuild
	dh_auto_install -X.dat -X.npz --buildsystem=pybuild --remaining-packages
	$(RM) -r debian/python3-pyresample/usr/lib/python3*/dist-packages/pyresample/test/test_files
	$(RM) debian/python3-pyresample/usr/lib/python3*/dist-packages/test_areas.yaml

override_dh_installchangelogs:
	dh_installchangelogs README.md

override_dh_numpy3:
	dh_numpy3 -p python3-pyresample
