#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export PYBUILD_NAME=backports.zstd

# Use Debian's zstd library
export PYBUILD_BUILD_ARGS = --config-setting="--build-option=--system-zstd"

# These test requires installation to system before testing
DISABLE_TESTS =
DISABLE_TESTS +=     not test_bad_use
DISABLE_TESTS += and not test_create_command
DISABLE_TESTS += and not test_create_command_compressed
DISABLE_TESTS += and not test_create_command_dot_started_filename
DISABLE_TESTS += and not test_create_command_dotless_filename
DISABLE_TESTS += and not test_extract_command
DISABLE_TESTS += and not test_extract_command_different_directory
DISABLE_TESTS += and not test_extract_command_invalid_file
DISABLE_TESTS += and not test_list_command_invalid_file
DISABLE_TESTS += and not test_test_command
DISABLE_TESTS += and not test_test_command_invalid_file

# Ignore test failure on Hurd
ifeq ($(DEB_HOST_ARCH_OS),hurd)
DISABLE_TESTS += and not test_realpath_limit_attack
endif

export PYBUILD_TEST_ARGS = -k "$(DISABLE_TESTS)"

# Module does not build successfully with Python 3.14 (segfaults during tests)
export PYBUILD_DISABLE=python3.14

%:
	dh $@ --buildsystem=pybuild

# We need the package to be installable with Python 3.14 and so removing the
# versioned restrictions against 3.14 (python3 << 3.14) is needed. For
# Python 3.14, packages wanting zstd should be using it from stdlib not this
# package
execute_after_dh_python3:
	sed -i s/3.14/3.15/ debian/python3-backports.zstd.substvars
