rustbridge-python
Python bindings for rustbridge - call Rust shared libraries from Python using ctypes.
Installation
pip install rustbridge
Development
To install from source for development:
pip install -e ".[dev]"
Quick Start
Direct Library Loading
from rustbridge import NativePluginLoader, PluginConfig, LogLevel
# Simple loading
with NativePluginLoader.load("libmyplugin.so") as plugin:
response = plugin.call("echo", '{"message": "hello"}')
print(response)
# With configuration
config = PluginConfig.defaults().log_level(LogLevel.DEBUG)
with NativePluginLoader.load_with_config("libmyplugin.so", config) as plugin:
response = plugin.call("echo", '{"message": "hello"}')
Bundle Loading (with signature verification)
from rustbridge import BundleLoader, PluginConfig
# Load with signature verification (default)
loader = BundleLoader(verify_signatures=True)
with loader.load("my-plugin-1.0.0.rbp") as plugin:
response = plugin.call("echo", '{"message": "hello"}')
# Skip verification for development
loader = BundleLoader(verify_signatures=False)
with loader.load("my-plugin-1.0.0.rbp") as plugin:
...
With Log Callback
from rustbridge import NativePluginLoader, PluginConfig, LogLevel
def on_log(level: LogLevel, target: str, message: str):
print(f"[{level.name}] {target}: {message}")
config = PluginConfig.defaults().log_level(LogLevel.DEBUG)
with NativePluginLoader.load_with_config("libmyplugin.so", config, log_callback=on_log) as plugin:
response = plugin.call("echo", '{"message": "hello"}')
Configuration
from rustbridge import PluginConfig, LogLevel
config = (PluginConfig.defaults()
.log_level(LogLevel.DEBUG) # Set log level
.worker_threads(4) # Set worker threads
.max_concurrent_ops(500) # Max concurrent operations
.shutdown_timeout_ms(10000) # Shutdown timeout
.set("custom_key", "value") # Custom configuration
.init_param("db_url", "...")) # Initialization parameter
API Reference
Core Types
LogLevel- Log level enum (TRACE, DEBUG, INFO, WARN, ERROR, OFF)LifecycleState- Plugin lifecycle state (INSTALLED, STARTING, ACTIVE, STOPPING, STOPPED, FAILED)PluginConfig- Configuration builderPluginException- Exception with error codeResponseEnvelope- JSON response wrapper
Native Plugin
NativePluginLoader.load(path)- Load a pluginNativePluginLoader.load_with_config(path, config, callback)- Load with configurationplugin.call(type_tag, request)- Make a JSON callplugin.call_typed(type_tag, request)- Make a typed call (auto JSON serialization)plugin.state- Get lifecycle stateplugin.set_log_level(level)- Set log levelplugin.shutdown()- Shutdown the plugin
Bundle Loading
BundleLoader(verify_signatures=True)- Create a loaderloader.load(path)- Load plugin from bundleloader.load_with_config(path, config, callback)- Load with configurationloader.get_manifest(path)- Read bundle manifestBundleLoader.get_current_platform()- Get current platform string
Development
# Install development dependencies
pip install -e ".[dev]"
# Run tests
python -m pytest tests/ -v
# Run specific test
python -m pytest tests/test_log_level.py -v
# Build hello-plugin for integration tests
cargo build -p hello-plugin --release
Requirements
- Python 3.10+
- PyNaCl (for Ed25519 signature verification)
License
MIT
Metadata
Release files for rustbridge 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rustbridge-1.0.1.tar.gz | 36.1 kB | Without provenance | Details for rustbridge-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rustbridge-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for rustbridge-1.0.1-py3-none-any.whl |
Total release size: 63.3 kB
Release files / rustbridge-1.0.1.tar.gz
| Download URL | rustbridge-1.0.1.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b974efa25fbe9e1371656a77dc177653b7f02b94f93c2644363057a7890b8af
|
|
BLAKE2b-256 checksum How to use checksums |
5046b19b216921ce452bb193090c382942372e1c03835959cae8970ce25f71e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / rustbridge-1.0.1-py3-none-any.whl
| Download URL | rustbridge-1.0.1-py3-none-any.whl |
|---|---|
| Size | 27.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10164b1972d734f302296f3db0a3cd8ba51665a1d744a308f5d771a2bd66cee0
|
|
BLAKE2b-256 checksum How to use checksums |
ec24c488fbeda324fc362be1ad20dd0a473c17b10d229950f8fd90abe39116b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for rustbridge 1.0.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.