Skip to main content

Eazy gRPC: dynamic protobuf generation from Python type hints

Project description

egrpc (eazy gRPC)

CI PyPI Python License

egrpc is a Python framework for transparent inter-process communication over gRPC. It generates protobuf definitions and gRPC services automatically from Python type hints at import time, eliminating the need for .proto files or manual code generation. Just add decorators and your functions and classes become callable across process boundaries.

Installation

pip install egrpc

Usage

Remote functions

@egrpc.function makes a function callable over gRPC. Arguments and return values are serialized automatically based on type hints.

import egrpc

@egrpc.function
def add(x: int, y: int) -> int:
    return x + y

Supported types include int, float, str, bool, None, list, dict, tuple, Union, Optional, slice, and nested combinations.

Dataclasses

@egrpc.dataclass defines a value type that is passed by value (serialized by field) across the RPC boundary.

@egrpc.dataclass
class Point:
    x: float
    y: float

@egrpc.function
def distance(p1: Point, p2: Point) -> float:
    return ((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2) ** 0.5

Remote classes

@egrpc.remoteclass defines a stateful object that lives on the server. The client holds a lightweight reference and calls methods via gRPC.

@egrpc.remoteclass
class Counter:
    @egrpc.method
    def __init__(self, initial: int = 0):
        self._count = initial

    @egrpc.property
    def count(self) -> int:
        return self._count

    @egrpc.method
    def increment(self) -> None:
        self._count += 1

Server / Client

Server:

egrpc.serve(port=12345)

Client:

egrpc.connect("localhost", 12345)

print(add(1, 2))  # 3
print(distance(Point(0, 0), Point(3, 4)))  # 5.0

c = Counter(10)
c.increment()
print(c.count)  # 11

egrpc.disconnect()

Development

This project is managed using uv.

Test:

uv run pytest

Type check:

uv run mypy --strict src/ test/

License

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

Copyright 2025 TOYOTA MOTOR CORPORATION.

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

egrpc-0.1.2.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

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

egrpc-0.1.2-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file egrpc-0.1.2.tar.gz.

File metadata

  • Download URL: egrpc-0.1.2.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for egrpc-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f2c30e4e50ad98cd947be4508c648ce29500b5d2a4834cf0837c78209e1cc439
MD5 aef502358095dff65b5c4118cd259654
BLAKE2b-256 c0c5f38c7c4c7129e8a7d84ad0cb04a8e435837dc671cfc1a64909bc6d54d5f8

See more details on using hashes here.

File details

Details for the file egrpc-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: egrpc-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for egrpc-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85113ea83a794ab57b987f1c254163f4d4cc9f5d4b68b853cda3584b0a296f5a
MD5 bb14fdf6bf40bf75b546542eed02e973
BLAKE2b-256 0067a2bc1debfd7a29b295bec70cd6d801e0bb358f2f676185ff9d2f7ef87dcf

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