Skip to main content

Python bindings for Eclipse uProtocol Rust implementation

Project description

up-py-rs

CI Status PyPI version Python 3.8+ License

Python bindings for the Eclipse uProtocol Rust implementation (up-rust). This package provides high-performance Python APIs for uProtocol communication patterns by leveraging Rust's speed and safety.

Features

  • 🚀 High Performance: Rust-powered implementations with minimal Python overhead
  • 🔒 Type Safe: Full type hints and stub files for excellent IDE support
  • 📡 Complete uProtocol Support: Publishers, Notifiers, and Transport implementations
  • 🐍 Pythonic API: Easy-to-use interfaces that feel natural in Python
  • Async Ready: Built on Tokio async runtime for efficient I/O operations

Installation

Install from PyPI:

# Basic installation (includes LocalTransport and core features)
pip install up-py-rs

# With Zenoh network transport
pip install up-py-rs[zenoh]

# With all optional features
pip install up-py-rs[all]

Or using uv:

uv add up-py-rs
# or with extras
uv add up-py-rs --extra zenoh

Optional Dependencies

up-py-rs supports modular installation through extras:

Extra Description Install Command
zenoh Zenoh network transport pip install up-py-rs[zenoh]
discovery Service discovery support pip install up-py-rs[discovery]
subscription Advanced subscription management pip install up-py-rs[subscription]
twin Digital twin support pip install up-py-rs[twin]
cloudevents CloudEvents format support pip install up-py-rs[cloudevents]
all All optional features pip install up-py-rs[all]
test Testing utilities pip install up-py-rs[test]

Note: Currently all Rust features are included in the wheel. Extras are provided for documentation and future Python runtime dependencies.

Quick Start

Simple Publisher (Local Transport)

For in-process communication without network overhead:

from up_py_rs import StaticUriProvider
from up_py_rs.local_transport import LocalTransport
from up_py_rs.communication import SimplePublisher, UPayload

# Setup
uri_provider = StaticUriProvider("my-vehicle", 0xa34b, 0x01)
transport = LocalTransport()
publisher = SimplePublisher(transport, uri_provider)

# Publish a message
payload = UPayload.from_string("Hello from Python!")
publisher.publish(0xb4c1, payload)

Zenoh Publisher (Network Transport)

For distributed communication across network boundaries:

from up_py_rs import StaticUriProvider
from up_py_rs.zenoh_transport import UPTransportZenoh
from up_py_rs.communication import SimplePublisher, UPayload

# Setup Zenoh transport
uri_provider = StaticUriProvider("publisher", 0x3b1da, 1)
transport = UPTransportZenoh.builder("publisher").build()
publisher = SimplePublisher(transport, uri_provider)

# Publish messages
for i in range(1, 11):
    payload = UPayload.from_string(f"event {i}")
    publisher.publish(0x8001, payload)

Note: Requires pip install up-py-rs[zenoh]

Simple Notifier

from up_py_rs import StaticUriProvider
from up_py_rs.local_transport import LocalTransport
from up_py_rs.communication import SimpleNotifier, UPayload

def notification_handler(msg):
    text = msg.extract_string()
    if text:
        print(f"Received: {text}")

# Setup
uri_provider = StaticUriProvider("my-vehicle", 0xa34b, 0x01)
transport = LocalTransport()
notifier = SimpleNotifier(transport, uri_provider)

# Register listener
topic = uri_provider.get_resource_uri(0xd100)
notifier.start_listening(topic, notification_handler)

# Send notification
payload = UPayload.from_string("Alert!")
destination = uri_provider.get_source_uri()
notifier.notify(0xd100, destination, payload)

# Cleanup
notifier.stop_listening(topic, notification_handler)

Components

LocalTransport

In-process message transport for testing and local communication without network overhead. Best for single-process applications and testing.

UPTransportZenoh

Zenoh-based network transport for distributed communication across network boundaries. Enables pub/sub patterns between different processes, devices, or vehicles. Requires zenoh extra.

StaticUriProvider

Creates and manages uProtocol URIs for identifying entities in the network.

SimplePublisher

High-level API for publishing messages to specific resources. Works with any transport (Local or Zenoh).

SimpleNotifier

Send and receive notifications between uEntities with listener callbacks.

UPayload

Message payload wrapper supporting strings and raw bytes with protobuf format.

Development

Building from Source

Requirements:

  • Python 3.8+
  • Rust toolchain (for building)
  • uv or pip
# Clone the repository
git clone https://github.com/sachinkum0009/up-py-rs.git
cd up-py-rs

# Build in development mode
uv run maturin develop

# Run tests
uv run pytest

# Run examples
uv run python examples/simple_publish.py
uv run python examples/simple_notify.py

# Run Zenoh examples (requires zenoh extra)
uv add up-py-rs --extra zenoh

# Terminal 1: Start subscriber
uv run python examples/simple_zenoh_subscriber.py

# Terminal 2: Start publisher
uv run python examples/simple_zenoh_publisher.py

Building Wheels

# Build release wheel
uv run maturin build --release

# Build and publish to PyPI
uv run maturin publish

Architecture

up-py-rs bridges Python and Rust using PyO3:

  • Rust Core: High-performance implementations from up-rust
  • PyO3 Bindings: Zero-cost abstractions between Python and Rust
  • Python API: Pythonic interfaces with full type hints

Each async operation maintains its own Tokio runtime for thread-safe execution across the Python/Rust boundary.

Contributing

Contributions are welcome! Please see the contribution guidelines for details.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Links

Acknowledgments

Built with:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

up_py_rs-0.0.9.tar.gz (63.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ i686

up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ i686

up_py_rs-0.0.9-cp38-abi3-win_amd64.whl (838.6 kB view details)

Uploaded CPython 3.8+Windows x86-64

up_py_rs-0.0.9-cp38-abi3-win32.whl (755.6 kB view details)

Uploaded CPython 3.8+Windows x86

up_py_rs-0.0.9-cp38-abi3-manylinux_2_34_x86_64.whl (7.4 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.34+ x86-64

up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ i686

up_py_rs-0.0.9-cp38-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

up_py_rs-0.0.9-cp38-abi3-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file up_py_rs-0.0.9.tar.gz.

File metadata

  • Download URL: up_py_rs-0.0.9.tar.gz
  • Upload date:
  • Size: 63.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for up_py_rs-0.0.9.tar.gz
Algorithm Hash digest
SHA256 9e09582ed3328261ec7650d18870baebddc2bc0f422e087e89e6d11d00f2c8ba
MD5 d25c95d3591b85d7f4893374f5beddb2
BLAKE2b-256 f328ee30d746b1028d59a75fe5c0fbf64001da2127d5b7adaf19c7d6efe6fd13

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8eb633362c33f44e42e14b4fcd34745ffd35cbe0730ef9964e1e7c18c0436ec6
MD5 8038dc1b446ffeaaef2fb42f6f5c3e33
BLAKE2b-256 128883b9a9d1756dee5086aa8c40883dfddd82a840ffde8c1dd58b280dd403b4

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 168961d87dc94fca1f9701a6dc0c1fa1c29e54ac44a03f5bc10bfffb52542b10
MD5 b213990e3ccbfb736795e4aa3b824c1f
BLAKE2b-256 f22bf577c3e6daad35e1066409b681d03416afb38997259525a6c5a13d5db790

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 76f93ad44d3fdec8db16490d8f2fe26ff802c7c112e663a9c2ca1534b4883ea2
MD5 6d56dfb8a14625a6dd924d2947b33f7a
BLAKE2b-256 2612a0632d98d8ed3e7a86c323e9aba8f1bc2777d562174c5d083094d1992bde

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 6d6580495f13d4f00bb7b1caad6dd57b532659a67af93a4112ae310554487970
MD5 a8c19875f83f5bdd2e74f6c3ee23ecd1
BLAKE2b-256 ed62009f7ed0867c1547cd0d0e60eabd90a818df6cb7c8cc0e035e42c67d76ac

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: up_py_rs-0.0.9-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 838.6 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 57071f2d445217fdccd7a87eed040aab3dacc66b1ad695377bfc6cb45005caee
MD5 4c71f0fe85a46036f6f5c1eeb8431ef5
BLAKE2b-256 9eb918d96c36b7570d0424eef324a0ff82fe9a0ff618884e4d1bc27e16bfb150

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-win32.whl.

File metadata

  • Download URL: up_py_rs-0.0.9-cp38-abi3-win32.whl
  • Upload date:
  • Size: 755.6 kB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 6d907253db6c8bbf8ad77aa57e8c68cdbd9704d1dbeab2a76a7bc69cc980d79d
MD5 ee2dc809d4d414fed02dd0f06e36fcc0
BLAKE2b-256 ce44a0a9981e6a8b516e18798ad81b49d4b8fc6b196af0fc8824277f3a31a072

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bd71cef2c0f2c015b34651668c6f5f79247b8bdaa4456d04289b800eacd43542
MD5 1d46a8499984397ae213aaf26e0d32be
BLAKE2b-256 794cf3a133efa7e292e32df1f4753674615546a870b6a3adf2aae70703877970

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 98531761400c6153261a1c81f6210f0f95554c18b43e93d8367514b1343c2d2b
MD5 018be649e299e41e1f5e92ebe3ee80e9
BLAKE2b-256 9dd0f1baefd4f85b9f92ee30986c76cc0fec5965cb662b6481ef3821e3005d80

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 3431fb7d432e74dd09ef29d7e150638e85aeec776360c0ba5488c623aee0370d
MD5 dc6eab939bb706426f7d5f98b2b7e07e
BLAKE2b-256 6efb9f6b68145f08cb331459abfaf04dce9fce08a55ee3c9376df10f1dd1505e

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ecfb02b80c8dc5069f2055d33254be04826c406f0ed863094925f853bf581e7d
MD5 3e4dbae489607e31f7faa87a4fca8575
BLAKE2b-256 29144a31f5f847197af4b5d9b8a0592ed862b5d13a31b1a7b952627947cd615b

See more details on using hashes here.

File details

Details for the file up_py_rs-0.0.9-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for up_py_rs-0.0.9-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 855228f0744918e48964130a23642bf710f9f77fb2f3d77022c1731c1a7930ab
MD5 e091bf3f8f3e7631721828737088777a
BLAKE2b-256 1cb02ac75f387e8886271c47d963be0905fa1eb35d3e8c69e7f740b68fb71a39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page