Files
guru/dev-python/cloudflare/cloudflare-5.1.0.ebuild
T
ingenarel (NeoJesus) d56f4baa37 */*: Use [[ ${PV} ... ]] instead of POSIX [ ${PV} ... ]
as per the coding style guide:
https://projects.gentoo.org/qa/policy-guide/ebuild-format.html#pg0101

if it previously used [ ${PV} ... ] it uses [[ ${PV} ... ]] now
if it previously used [[ ${PV} = b ]] or [ ${PV} = b ], it uses
[[ ${PV} == b ]] now

the changes were generated using these two commands:

```
find -name '*.ebuild' -exec sed -i -E \
's|([^[])\[+(\s+)(\S*\$\S*PV\S*)(\s+)(\S+)(\s+)(\S+)(\s+)\]+([^]])|\1\[\[\2\3\4\5\6\7\8\]\]\9|g' \
{} \+

find -name '*.ebuild' -exec sed -i -E \
's|\[(\s+)(\S*\$\S*PV\S*)(\s+)==?(\s+)(\S+)(\s+)\]|\[\1\2\3==\4\5\6\]|g' \
{} \+
```

this is aimed to be a series of commits meant to replace all instance of
POSIX [ ... ] to bash's [[ ... ]], to make guru up to date with the
coding style guide

this process is divided up into a series of commits in order to make
review and testing more easy

Signed-off-by: ingenarel (NeoJesus) <ingenarel_neojesus@disroot.org>
Part-of: https://codeberg.org/gentoo/guru/pulls/6
Signed-off-by: Michał Górny <mgorny@gentoo.org>
2026-09-25 18:48:54 +02:00

91 lines
2.7 KiB
Bash

# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
PYTHON_COMPAT=( python3_{12..14} )
DISTUTILS_USE_PEP517="hatchling"
inherit distutils-r1 eapi9-ver
DESCRIPTION="Python wrapper for the Cloudflare v4 API"
HOMEPAGE="https://pypi.org/project/cloudflare/"
if [[ "${PV}" == 9999 ]]; then
EGIT_REPO_URI="https://github.com/cloudflare/cloudflare-python"
inherit git-r3
RESTRICT="test"
else
MYPV=$(ver_rs 3 -)
MYPV=${MYPV/beta/beta.}
MYPN="cloudflare-python"
SRC_URI="
https://github.com/cloudflare/cloudflare-python/archive/refs/tags/v${MYPV}.tar.gz -> ${MYPN}-${MYPV}.gh.tar.gz
test? ( https://github.com/Phoenix591/${MYPN}/releases/download/${MYPV}/${MYPN}-${MYPV}-prism.tar.gz )"
#Prism archive generated by workflow
# https://github.com/Phoenix591/cloudflare-python/blob/master/.github/workflows/test-tar.yml
S="${WORKDIR}/${MYPN}-${MYPV}"
KEYWORDS="~amd64 ~arm64"
fi
LICENSE="MIT"
SLOT="0"
RDEPEND=" ${DEPEND}
>=dev-python/httpx-0.23.0[${PYTHON_USEDEP}]
>=dev-python/pydantic-2.9.2[${PYTHON_USEDEP}]
>=dev-python/typing-extensions-4.7.0[${PYTHON_USEDEP}]
>=dev-python/anyio-4.3.0[${PYTHON_USEDEP}]
>=dev-python/distro-1.7.0[${PYTHON_USEDEP}]
>=dev-python/sniffio-1.3.1[${PYTHON_USEDEP}]
"
BDEPEND="test? (
>=dev-python/httpx-aiohttp-0.1.9[${PYTHON_USEDEP}]
>=net-libs/nodejs-18.20.1
dev-python/time-machine[${PYTHON_USEDEP}]
dev-python/dirty-equals[${PYTHON_USEDEP}]
${RDEPEND}
)"
EPYTEST_PLUGINS=( pytest-asyncio pytest-xdist respx )
EPYTEST_DESELECT=(
tests/test_client.py::TestCloudflare::test_validate_headers
tests/test_client.py::TestAsyncCloudflare::test_validate_headers
)
distutils_enable_tests pytest
RESTRICT+=" !test? ( test )"
DOCS=( docs/migration-guides/v5.0.0-migration-guide.md )
src_unpack() {
unpack "${MYPN}-${MYPV}.gh.tar.gz"
use test && cd "${S}" && unpack "cloudflare-python-${MYPV}-prism.tar.gz"
}
src_test() {
start_mock
distutils-r1_src_test
stop_mock
}
start_mock() {
# Run prism mock api server, this is what needs nodejs
node --no-warnings node_modules/@stainless-api/prism-cli/dist/index.js mock \
"cloudflare-spec.yml" >prism.log || die "Failed starting prism" &
echo $! >"${T}/mock.pid" || die
# Wait for server to come online
einfo "Waiting for mockserver"
while ! grep -q "✖ fatal\|Prism is listening" "prism.log" ; do
sleep 0.5
done
if grep -q "✖ fatal" prism.log; then
die "Prism mock server failed"
fi
}
stop_mock() {
kill $(<"${T}/mock.pid") || die
}
pkg_postinst() {
if ver_replacing -lt "5.0.0_beta1"; then
elog "Cloudflare 5 has several breaking changes"
elog "See /usr/share/doc/${P}/docs/v5.0.0-migration-guide.md"
elog "It also includes a new optional dependency on httpx-aiohttp"
elog "Check the README for details"
fi
}