#!/usr/bin/make -f
# -*- makefile -*-
export PYBUILD_NAME = mne
# The below environment variables are important test parameters.
export HOME = $(CURDIR)/build
export MNE_DONTWRITE_HOME = true
export MNE_SKIP_SAMPLE_DATASET_TESTS = true
export MNE_FORCE_SERIAL = true
export MNE_SKIP_NETWORK_TESTS = 1
# to avoid cannot set toolkit to qt4 because it has already been set to wx
export ETS_TOOLKIT = qt4

%:
	dh $@ --buildsystem pybuild

execute_before_dh_clean:
	rm -rf *.egg-info

# FIXME: reinstate these tests with resolution of [1].
# [1]: https://github.com/mne-tools/mne-python/issues/13193
# [2]: huanghe ships scikit-learn 1.7.2 / NumPy 2.3.5 / SciPy 1.16.3, which are
#      newer than what upstream 1.9.0 was validated against. The new
#      sklearn __sklearn_tags__ machinery raises warnings that MNE's test
#      suite promotes to errors (see mne/conftest.py) and changes the sparse
#      tag, so the tests below fail on this toolchain; drop them for now.
PYTEST_SPECS = -k 'not test_spherical_conversions and not test_tps and \
not check_estimator_sparse_tag and not test_receptive_field_basic and \
not test_search_light and not test_generalization_light and not test_other_systems'
SCREEN_CONFIG=-screen 0 1024x768x24 -ac +extension GLX +render -noreset
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p build
	xvfb-run \
		--auto-servernum \
		--server-num=20 \
		-s "$(SCREEN_CONFIG)" \
		py.test $(PYTEST_SPECS) -s -v mne
endif

execute_after_dh_fixperms:
	find `find debian -name data -type d` -type f -exec chmod -x \{\} \;
