# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_USE_PEP517=hatchling
PYTHON_COMPAT=( python3_{12..14} )

inherit distutils-r1

DESCRIPTION="Async client for aws services using botocore and aiohttp"
HOMEPAGE="http://aiobotocore.readthedocs.io"
SRC_URI="https://github.com/aio-libs/aiobotocore/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="httpx"
PROPERTIES="test_network"
RESTRICT="test"

# Upstream caps botocore <1.43.118 (a tested-with bound, not an exact pin). Both hosts
# already run botocore 1.44.9 and step 12's rule is that no machine in the pair is ever
# stepped back, so the cap is widened here: a deliberate, recorded deviation from upstream
# metadata. Measured 2026-11-26 for 2026.12.0_beta0; aiobotocore 3.10.0 is HA's own pin.
RDEPEND="
	>=dev-python/aiohttp-3.14.0[${PYTHON_USEDEP}]
	<dev-python/aiohttp-4.0.0[${PYTHON_USEDEP}]
	>=dev-python/aioitertools-0.5.1[${PYTHON_USEDEP}]
	<dev-python/aioitertools-1.0.0[${PYTHON_USEDEP}]
	>=dev-python/botocore-1.43.115[${PYTHON_USEDEP}]
	>=dev-python/jmespath-0.7.1[${PYTHON_USEDEP}]
	<dev-python/jmespath-2.0.0[${PYTHON_USEDEP}]
	>=dev-python/multidict-6.0.0[${PYTHON_USEDEP}]
	<dev-python/multidict-8.0.0[${PYTHON_USEDEP}]
	>=dev-python/python-dateutil-2.1[${PYTHON_USEDEP}]
	<dev-python/python-dateutil-4.1[${PYTHON_USEDEP}]
	>=dev-python/wrapt-1.10.10[${PYTHON_USEDEP}]
	<dev-python/wrapt-3.0.0[${PYTHON_USEDEP}]
	httpx? (
		>=dev-python/anyio-4.11.0[${PYTHON_USEDEP}]
		<dev-python/anyio-5.0.0[${PYTHON_USEDEP}]
		>=dev-python/httpx-0.25.1[${PYTHON_USEDEP}]
		<dev-python/httpx-0.29.0[${PYTHON_USEDEP}]
	)
"
BDEPEND="
	test? (
		dev-python/dill[${PYTHON_USEDEP}]
		dev-python/docker[${PYTHON_USEDEP}]
		dev-python/docutils[${PYTHON_USEDEP}]
		dev-python/flask-cors[${PYTHON_USEDEP}]
		dev-python/moto[${PYTHON_USEDEP}]
		dev-python/openapi-spec-validator[${PYTHON_USEDEP}]
		dev-python/pip[${PYTHON_USEDEP}]
		dev-python/pyyaml[${PYTHON_USEDEP}]
		>=dev-python/anyio-4.11.0[${PYTHON_USEDEP}]
	)
"


EPYTEST_XDIST=1
EPYTEST_PLUGINS=( anyio time-machine )
distutils_enable_tests pytest
distutils_enable_sphinx docs

EPYTEST_IGNORE=(
	# test_lambda uses moto.awslambda, which requires a running Docker service
	# See: https://github.com/spulec/moto/issues/3276
	tests/test_lambda.py
)

EPYTEST_DESELECT=(
	'tests/test_patches.py::test_patches[BaseClient._make_api_call-digests12]'
	'tests/test_patches.py::test_patches[Config-digests21]'
	'tests/test_patches.py::test_patches[EndpointRulesetResolver._get_provider_params-digests117]'
	'tests/test_patches.py::test_patches[Session.create_client-digests123]'
	'tests/test_patches.py::test_patches[Waiter.wait-digests191]'
	'tests/test_patches.py::test_patches[aiohttp-ClientCreator._register_retries-digests8]'
	'tests/test_patches.py::test_patches[aiohttp-Endpoint._do_get_response-digests87]'
	'tests/test_patches.py::test_patches[aiohttp-get_response-digests123]'
	'tests/test_patches.py::test_patches[aiohttp-EndpointRulesetResolver.construct_endpoint-digests120]'
	'tests/test_patches.py::test_patches[aiohttp-RequestSigner.get_auth_instance-digests139]'
	'tests/test_patches.py::test_patches[aiohttp-RequestSigner.get_auth_instance-digests140]'
	'tests/test_sns.py::test_topic_attributes[aiohttp]'
)

python_prepare_all() {
	# Work-around test failures with moto 5.x
	# See: https://github.com/aio-libs/aiobotocore/issues/1108
	use test && { sed -i "s/pip._vendor.//" tests/test_version.py || die ; }

	distutils-r1_python_prepare_all
}

distutils_enable_tests pytest