summaryrefslogtreecommitdiff
path: root/dev-python/cloudflare/cloudflare-5.9.0.ebuild
blob: 5b53d6271f5d8239b07fa87e934d16a43740298b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 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_{13..14} )

inherit distutils-r1 eapi9-ver

MY_PV=$(ver_rs 3 -)
MY_P="cloudflare-python-${MY_PV}"
DESCRIPTION="The official Python library for the Cloudflare API"
HOMEPAGE="
	https://github.com/cloudflare/cloudflare-python
	https://pypi.org/project/cloudflare/
"
SRC_URI="
	https://github.com/cloudflare/cloudflare-python/archive/refs/tags/v${MY_PV}.tar.gz
		-> ${MY_P}.gh.tar.gz
"
S="${WORKDIR}/${MY_P}"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~ppc64"
PROPERTIES="test? ( test_network )"

# Note for maintainers: watch follow issue to switch for httpx2
# https://github.com/cloudflare/cloudflare-python/issues/2733
RDEPEND="
	>=dev-python/anyio-3.5.0[${PYTHON_USEDEP}]
	<dev-python/anyio-5[${PYTHON_USEDEP}]
	>=dev-python/distro-1.7.0[${PYTHON_USEDEP}]
	<dev-python/distro-2[${PYTHON_USEDEP}]
	>=dev-python/httpx-0.23.0[${PYTHON_USEDEP}]
	<dev-python/httpx-1[${PYTHON_USEDEP}]
	>=dev-python/pydantic-1.9.0[${PYTHON_USEDEP}]
	<dev-python/pydantic-3[${PYTHON_USEDEP}]
	dev-python/sniffio[${PYTHON_USEDEP}]
	>=dev-python/typing-extensions-4.14[${PYTHON_USEDEP}]
	<dev-python/typing-extensions-5[${PYTHON_USEDEP}]
"

# tests/api_resources needs the prism mock server (@stainless-api/prism-cli),
# an npm package that is not in the tree. Everything else is either pure unit
# tests or mocked with respx.
BDEPEND+="
	test? (
		>=dev-python/dirty-equals-0.6.0[${PYTHON_USEDEP}]
		>=dev-python/httpx-aiohttp-0.1.9[${PYTHON_USEDEP}]
	)
"

EPYTEST_PLUGINS=( pytest-asyncio respx )
distutils_enable_tests pytest

EPYTEST_IGNORE=( tests/api_resources )
# The generated tests expect a CLOUDFLARE_API_VERSION environment variable and
# api_version format validation that the generated client does not implement.
# https://github.com/cloudflare/cloudflare-python/issues/2745
EPYTEST_DESELECT=(
	tests/test_client.py::TestAsyncCloudflare::test_api_version_env_var
	tests/test_client.py::TestAsyncCloudflare::test_api_version_omitted_when_empty
	tests/test_client.py::TestAsyncCloudflare::test_api_version_rejects_invalid_format
	tests/test_client.py::TestCloudflare::test_api_version_env_var
	tests/test_client.py::TestCloudflare::test_api_version_omitted_when_empty
	tests/test_client.py::TestCloudflare::test_api_version_rejects_invalid_format
)

src_prepare() {
	distutils-r1_src_prepare

	# Drop -n auto, pytest-xdist is not worth pulling in for a 10 s suite
	sed -i -e '/^addopts = /d' pyproject.toml || die
}