dev-python/anthropic: use stainless-python.eclass

Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
This commit is contained in:
Florian Albrechtskirchinger
2026-07-06 20:45:52 +02:00
parent d7463e8a28
commit 0ebedaaabe
2 changed files with 11 additions and 112 deletions

View File

@@ -1,5 +1,5 @@
DIST anthropic-openapi-spec-0.116.0.yml 1719154 BLAKE2B 32be75b7450aa5062831d2f1a78a97303f2f783a94df1850e724882b2e587328bb58245225f0dc605a30c9d681f3ee7f5dea53e7988997343fd753e8ceac9fe2 SHA512 c9849308da448eaac0960006c01fde2f4f2f749fdcfe9316931be0fd11b9fcbee6d6897140722c6e5c211480e93b19f0ee274fd31ab1c2ec4193dd1ab3af77f2
DIST anthropic-sdk-python-0.116.0.gh.tar.gz 970819 BLAKE2B 74a310bffe030cce92c7be650cfd77c1cb41fe1ce660536a383502a8239fbe4ff49a83f574e3637354d743e585fc2760c1e4446830def8f7135192788e4838b3 SHA512 0efd6713463fb242427ed86bb963501c99dd54f6da455d9ee5124fc3309a2fc7490add508bf09037583199de77f8e38e8766bfa42854b085c1e6bb38cc385647
DIST npm-@stdy-cli-cli-0.22.1.tgz 7776 BLAKE2B ec66af59c4c864a4331dc7918ed0a82d452579427663c3666b94d6008e769cb8a61d00e1971a394c326ca180da7f3009597b15d4c6bea8d169bda56c87ae21fb SHA512 55d9c2a0afddd09588853a1a8c1c4075a813a4b097ff34dded18ae2b529d4f5d90e29667ffe792f7b82af78fa3bfa4db88c77ef5259e39db100a86a0a4b98d7c
DIST npm-@stdy-cli-linux-arm64-cli-linux-arm64-0.22.1.tgz 37635112 BLAKE2B f749d99342d9cffb831f0feea34ed74301a3beea7ec4c7e46cd5b942cacfea4b10c28632cc3e38a0ac00b565c2ca5889cb6587fcccb75f1557fa29dace58a343 SHA512 5c6432dd9a85e423aa4600151b109da16f5dcf19dfc710920070869a1a4573ea557e941c6077cf72736199686994c09eae24d4c8228b246fbf7c67728e2eded9
DIST npm-@stdy-cli-linux-x64-cli-linux-x64-0.22.1.tgz 38431354 BLAKE2B f6b49ce9f79ad98de58f6f01874e5ae03f728f062b09b91b092f1410e1bf3d2874d25dfb30038291429043eeffc4c5e3183e7e9307c6fb889521008b981df4f9 SHA512 bbbe7cd48dec73a47e3d4c0692f1056ef0ffc3a617bd193e893d0122658a3ed298036e9c3cfd7a96003b82abaeded00493eddcf581a7e71854a6109cf7a68b4a
DIST stdy-cli-0.22.1.npm.tgz 7776 BLAKE2B ec66af59c4c864a4331dc7918ed0a82d452579427663c3666b94d6008e769cb8a61d00e1971a394c326ca180da7f3009597b15d4c6bea8d169bda56c87ae21fb SHA512 55d9c2a0afddd09588853a1a8c1c4075a813a4b097ff34dded18ae2b529d4f5d90e29667ffe792f7b82af78fa3bfa4db88c77ef5259e39db100a86a0a4b98d7c
DIST stdy-cli-linux-arm64-0.22.1.npm.tgz 37635112 BLAKE2B f749d99342d9cffb831f0feea34ed74301a3beea7ec4c7e46cd5b942cacfea4b10c28632cc3e38a0ac00b565c2ca5889cb6587fcccb75f1557fa29dace58a343 SHA512 5c6432dd9a85e423aa4600151b109da16f5dcf19dfc710920070869a1a4573ea557e941c6077cf72736199686994c09eae24d4c8228b246fbf7c67728e2eded9
DIST stdy-cli-linux-x64-0.22.1.npm.tgz 38431354 BLAKE2B f6b49ce9f79ad98de58f6f01874e5ae03f728f062b09b91b092f1410e1bf3d2874d25dfb30038291429043eeffc4c5e3183e7e9307c6fb889521008b981df4f9 SHA512 bbbe7cd48dec73a47e3d4c0692f1056ef0ffc3a617bd193e893d0122658a3ed298036e9c3cfd7a96003b82abaeded00493eddcf581a7e71854a6109cf7a68b4a

View File

@@ -6,41 +6,24 @@ EAPI=8
DISTUTILS_USE_PEP517=hatchling
PYTHON_COMPAT=( python3_{12..14} )
inherit distutils-r1 optfeature
# See https://github.com/anthropics/anthropic-sdk-python/blob/main/.stats.yml
API_SPEC_BASE="https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic"
API_SPEC="anthropic-openapi-spec-${PV}.yml"
STAINLESS_SPEC_PATH=${PN}/${PN}-506a5ad71d522b4ae56ac3429380486647af1f92eddde80603480fb592d62b54.yml
# See https://github.com/anthropics/anthropic-sdk-python/blob/main/scripts/mock
STAINLESS_MOCK_SERVER_VERSION=0.22.1
STAINLESS_MOCK_SERVER_PACKAGE_JSON="${FILESDIR}/${PN}-0.116.0-mock-server-package.json"
inherit distutils-r1 optfeature stainless-python
MY_PN="anthropic-sdk-python"
MY_P="${MY_PN}-${PV}"
# See https://github.com/anthropics/anthropic-sdk-python/blob/main/scripts/mock
STDY_PV=0.22.1
DESCRIPTION="The official Python library for the anthropic API"
HOMEPAGE="
https://github.com/anthropics/anthropic-sdk-python
https://pypi.org/project/anthropic
"
SRC_URI="
SRC_URI+="
https://github.com/anthropics/${MY_PN}/archive/refs/tags/v${PV}.tar.gz
-> ${MY_P}.gh.tar.gz
test? (
${API_SPEC_BASE}/anthropic-506a5ad71d522b4ae56ac3429380486647af1f92eddde80603480fb592d62b54.yml
-> ${API_SPEC}
https://registry.npmjs.org/@stdy/cli/-/cli-${STDY_PV}.tgz
-> npm-@stdy-cli-cli-${STDY_PV}.tgz
amd64? (
https://registry.npmjs.org/@stdy/cli-linux-x64/-/cli-linux-x64-${STDY_PV}.tgz
-> npm-@stdy-cli-linux-x64-cli-linux-x64-${STDY_PV}.tgz
)
arm64? (
https://registry.npmjs.org/@stdy/cli-linux-arm64/-/cli-linux-arm64-${STDY_PV}.tgz
-> npm-@stdy-cli-linux-arm64-cli-linux-arm64-${STDY_PV}.tgz
)
)
"
S="${WORKDIR}/${MY_P}"
@@ -67,8 +50,6 @@ BDEPEND="
>=dev-python/httpx-aiohttp-0.1.9[${PYTHON_USEDEP}]
>=dev-python/rich-13.7.1[${PYTHON_USEDEP}]
>=dev-python/standardwebhooks-1.0.1[${PYTHON_USEDEP}]
net-libs/nodejs[npm]
net-misc/curl
)
"
@@ -82,88 +63,6 @@ EPYTEST_PLUGINS=(
)
distutils_enable_tests pytest
src_unpack() {
unpack "${MY_PN}-${PV}.gh.tar.gz"
}
src_test() {
einfo "Assembling npm cache..."
local -x npm_config_cache="${WORKDIR}/npm-cache"
mkdir -p "${npm_config_cache}" || die
for distfile in ${A}; do
if [[ "${distfile}" == npm-* ]]; then
npm cache add "${DISTDIR}/${distfile}" &>/dev/null || die
fi
done
einfo "Installing mock server..."
local mock_dir="${WORKDIR}/mock-server"
mkdir -p "${mock_dir}" || die
cp "${FILESDIR}/${PN}-0.116.0-mock-server-package.json" \
"${mock_dir}/package.json" || die
cp "${FILESDIR}/${PN}-0.116.0-mock-server-package-lock.json" \
"${mock_dir}/package-lock.json" || die
local mock_dir="${WORKDIR}/mock-server"
local mock="${mock_dir}/node_modules/.bin/steady"
pushd "${mock_dir}" >/dev/null || die
npm ci &>/dev/null || die
einfo "Starting mock server..."
# Replicate the logic from scripts/mock --daemon
"${mock}" --host 127.0.0.1 -p 4010 \
--validator-form-array-format=brackets \
--validator-query-array-format=brackets \
--validator-form-object-format=brackets \
--validator-query-object-format=brackets \
"${DISTDIR}/${API_SPEC}" &> .stdy.log &
local mock_pid=$!
is_mock_running() {
local -a args
readarray -d '' args < "/proc/${mock_pid}/cmdline" 2>/dev/null || return 1
# Check args[1] (native) or args[2] (QEMU user-mode emulation)
[[ "${args[1]}" == "${mock}" || "${args[2]}" == "${mock}" ]]
}
local attempts=0
while ! curl -sf "http://127.0.0.1:4010/_x-steady/health" &>/dev/null; do
if ! is_mock_running; then
cat .stdy.log
die "Mock server failed to start"
fi
attempts=$((attempts + 1))
if (( attempts >= 300 )); then
cat .stdy.log
die "Timed out waiting for mock server to start"
fi
sleep 0.1
done
# Oops; connected to another Steady instance running on 4010
is_mock_running || die
popd >/dev/null || die
nonfatal distutils-r1_src_test
local ret=${?}
if is_mock_running; then
einfo "Stopping mock server..."
kill "${mock_pid}" || die
fi
[[ ${ret} -ne 0 ]] && die
}
pkg_postinst() {
optfeature "alternative async HTTP client support" \
"dev-python/aiohttp >=dev-python/httpx-aiohttp-0.1.9"