Skip to main content

RevTurbine SDK — Python

Headless, in-memory entitlement and placement decisioning for Python services. RevTurbineCustomerSdk (plan 33 TASK-7) decides in-process from a caller-supplied user context + Playbook snapshot — no network, no persistence beyond memory. Its decision output is byte-identical to the canonical TypeScript LocalRuntime (cross-language parity is gate-enforced via revturbine-sdk-internal/tests/parity/).

Full docs: the published Astro docs site — Getting Started → Python SDK (source: pages-build/src/content/docs/getting-started/python.mdx).

Install

Published on PyPI as revturbine. Requires Python ≥ 3.10.

pip install revturbine

Releases are tag-driven and version-locked with @revturbine/sdk — the same version number always ships for both. (Contributors developing in this repo use the editable install under Local development instead. The old GitHub-Release distribution on the now-archived revt-eng/revturbine-external is retired.)

Quick start

import json
from revturbine import RevTurbineCustomerSdk

with open("playbook.json") as f:
    playbook = json.load(f)

sdk = RevTurbineCustomerSdk(
    user_context={"tenant_id": "tenant_abc", "user_id": "user_123", "plan_handle": "pro"},
    playbook=playbook,
)

if not sdk.check_entitlement("advanced_analytics")["allowed"]:
    raise PermissionError("not entitled")

decision = sdk.get_placement_decision(
    {"placement_id": "pl_dashboard_upsell", "user_id": "user_123"}
)

Public API

  • RevTurbineCustomerSdk(*, user_context, playbook) — keyword-only; user_context requires tenant_id + user_id (optional plan_handle, plan_name, usage). Stateless / in-memory — no storage parameter.
  • check_entitlement(handle, context=None) -> EntitlementCheckResult
  • can(handle, context=None) — the advertised alias of check_entitlement (same canonical/alias pair as the scaffold SDK function surface and the server-node port)
  • get_placement_decision(input) -> PlacementDecision
  • get_placement_decisions(inputs) -> list[PlacementDecision]

That is the entire public surface. Browser/full-SDK concerns (React, hooks, HTTP/dual-mode, decision cache, segment/targeting derivation, identify/dismiss/snooze/convert/get_trial_status/capture/…) are intentionally not ported — plan 33 REQ-14 non-goals.

Project layout

server-python/
├── pyproject.toml          ← package metadata + tool config (ruff, mypy, pytest)
├── tox.ini                 ← test/lint/type matrix
├── .pre-commit-config.yaml ← ruff + mypy hooks (scoped to this dir)
├── src/revturbine/         ← the headless SDK (sdk.py + core/ port)
├── revturbine_server/      ← legacy thin-RPC client (see below)
└── tests/                  ← pytest suite (incl. tests/test_public_api.py)

Legacy revturbine_server

A historical thin-RPC HTTP client (from revturbine_server import RevTurbineServer) also ships in this package. It is independent of and unrelated to RevTurbineCustomerSdk — not folded in, not a dual-mode of it. It currently depends on an unmaintained generated revturbine.types module (plan REQ-4 / TASK-2) and is not standalone-importable until that generator lands. Prefer RevTurbineCustomerSdk for all new server integrations.

Local development

pip install -e ".[dev]"
pytest                  # unit + smoke + parity-contract tests
mypy                    # strict type-check of src/ and tests/
ruff check src tests    # lint (CI scope)
ruff format --check src tests
tox                     # full matrix (py310–py313 + lint + type)

Cross-language parity (run from the SDK repo root):

node scripts/run-parity.mjs   # TS + Python runners, byte-diff (the gate)

Regenerating vendored types

src/revturbine/types.py is a copy of the Pydantic models revturbine-scaffold generates — never hand-edit it. @revt-eng/schema ships the generated file, so the copy comes from the installed package: after a pin change, run pnpm install and then pnpm sync:python-types (and pnpm sync:rust-types for the Rust copy) from the SDK repo root, and commit the result.

pnpm check:vendored-types (part of pnpm verify) compares both copies with the pinned package's files. A pin that leaves the types alone needs no commit here; one that changes them fails the check until the copies are refreshed.

To try types that are not published yet, set REVTURBINE_SCAFFOLD_DIR to a revturbine-scaffold checkout (after npm run generate there) and run the sync scripts; the check fails until the pin ships those types.

Dependencies

  • Runtime: pydantic>=2.0.
  • Stdlib only otherwise. The legacy revturbine_server client uses only urllib / json / uuid (plus the unmaintained generated-types import noted above).

Metadata

Release files for revturbine 0.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for revturbine 0.18.0
File Size Uploaded Provenance Actions
revturbine-0.18.0.tar.gz 404.1 kB With provenance Details for revturbine-0.18.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for revturbine 0.18.0
File Interpreter ABI Platform Actions
revturbine-0.18.0-py3-none-any.whl Python 3 none any Details for revturbine-0.18.0-py3-none-any.whl

Total release size: 654.8 kB

Release files / revturbine-0.18.0.tar.gz

Download URL revturbine-0.18.0.tar.gz
Size 404.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c0c601a9791824a2189ba07f8782153bbb196ae4642bb66e1cf64669fcdd701e
BLAKE2b-256 checksum
How to use checksums
fa37b33ec073d997db8e982914eab8643ed63df1b563722ccf71bed9b6076f62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / revturbine-0.18.0-py3-none-any.whl

Download URL revturbine-0.18.0-py3-none-any.whl
Size 250.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c2b6d30e4e5179a32bb2dc46c511ca8e166588fb1daff8c703645ee4330beae
BLAKE2b-256 checksum
How to use checksums
d33e001faf3259ff7c7f5b4f9b50df642f005e124084a8ea813477bd100647ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for revturbine 0.18.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for revturbine-0.18.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.18.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page