-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add Python bindings via PyO3 #578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements issue #563 - Python bindings for Redis Cloud and Enterprise APIs. Features: - CloudClient for Redis Cloud API (subscriptions, databases) - EnterpriseClient for Redis Enterprise API (cluster, databases, nodes, users) - Both async and sync API variants for all methods - Raw API access methods (get, post, put, delete) - Proper error mapping to Python exceptions - Type stubs for IDE support Built with: - PyO3 0.23 for Rust-Python interop - pyo3-async-runtimes for async/await support (Tokio <-> asyncio) - maturin for building wheels Usage: from redisctl import CloudClient, EnterpriseClient # Sync client = CloudClient(api_key='...', api_secret='...') subs = client.subscriptions_sync() # Async subs = await client.subscriptions()
The Redis Enterprise API uses /v1/{resource}/stats/{uid} pattern,
not /v1/{resource}/{uid}/stats. Fixed:
- bdb.rs: stats() and metrics() paths
- nodes.rs: stats() path
Discovered while testing Python bindings against Docker instance.
Supports multiple environment variable names for compatibility: - API Key: REDIS_CLOUD_API_KEY, REDIS_CLOUD_ACCOUNT_KEY - API Secret: REDIS_CLOUD_API_SECRET, REDIS_CLOUD_SECRET_KEY, REDIS_CLOUD_USER_KEY - Base URL: REDIS_CLOUD_BASE_URL, REDIS_CLOUD_API_URL
- Add GitHub Actions workflow for building Python wheels on Linux, macOS, Windows - Add 17 unit tests for CloudClient and EnterpriseClient - Add comprehensive README with usage examples - Update type stubs with CloudClient.from_env() method
- Updated pyo3 from 0.23 to 0.27 - Updated pyo3-async-runtimes from 0.23 to 0.27 - Replaced deprecated Python::with_gil with Python::attach - Replaced deprecated PyObject with Py<PyAny> - Replaced deprecated py.allow_threads with py.detach - Replaced deprecated downcast with cast This addresses the security vulnerability RUSTSEC-2025-0020 in PyO3 versions prior to 0.24.1.
The Python bindings crate uses lib name 'redisctl' which collides with the main CLI crate when generating docs. Since Python bindings have their own documentation via type stubs (.pyi) and README, we disable rustdoc generation for this crate.
Use if-let with && condition instead of is_some() + unwrap()
- Builds wheels for Linux (x86_64, aarch64), macOS (x86_64, arm64), Windows - Uses PyO3/maturin-action for optimized builds - Supports both TestPyPI and PyPI via workflow_dispatch - Triggers automatically on GitHub releases - Uses trusted publishing (OIDC) - no API tokens needed
This was referenced Jan 20, 2026
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements #563 - Python bindings for Redis Cloud and Enterprise APIs using PyO3.
Features
CloudClient (Redis Cloud API)
from_env()with flexible env var supportEnterpriseClient (Redis Enterprise API)
from_env()constructorDeveloper Experience
.pyi) for IDE autocompleteTested Against
Usage
Building
CI
Bug Fixes
This PR also fixes incorrect stats endpoint paths in
redis-enterprise:/v1/bdbs/stats/{uid}(was/v1/bdbs/{uid}/stats)/v1/nodes/stats/{uid}(was/v1/nodes/{uid}/stats)Technical Details
TODO (follow-up work)
Closes #563