{"id":13494560,"url":"https://github.com/python-trio/purerpc","last_synced_at":"2025-03-28T14:31:20.574Z","repository":{"id":42004459,"uuid":"107417587","full_name":"python-trio/purerpc","owner":"python-trio","description":"Native, async Python gRPC client and server implementation supporting asyncio, uvloop, and trio","archived":false,"fork":false,"pushed_at":"2024-04-07T23:34:31.000Z","size":277,"stargazers_count":211,"open_issues_count":15,"forks_count":15,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-14T19:10:21.272Z","etag":null,"topics":["asynchronous","asyncio","cpython","grpc","networking","pure-python","pypi","pypy","python","remote-procedure-call","rpc","rpc-framework","trio","uvloop"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-trio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"python-trio","open_collective":"python-trio"}},"created_at":"2017-10-18T14:12:30.000Z","updated_at":"2024-04-16T07:21:43.348Z","dependencies_parsed_at":"2024-04-16T07:21:31.366Z","dependency_job_id":"dec9671e-2dff-4d23-8b68-820437546758","html_url":"https://github.com/python-trio/purerpc","commit_stats":{"total_commits":161,"total_committers":10,"mean_commits":16.1,"dds":0.3229813664596274,"last_synced_commit":"a3c17dd885d8f36bcf3a78c7506e35f7bc33cccc"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fpurerpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fpurerpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fpurerpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-trio%2Fpurerpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-trio","download_url":"https://codeload.github.com/python-trio/purerpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244365716,"owners_count":20441569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","asyncio","cpython","grpc","networking","pure-python","pypi","pypy","python","remote-procedure-call","rpc","rpc-framework","trio","uvloop"],"created_at":"2024-07-31T19:01:26.030Z","updated_at":"2025-03-28T14:31:20.551Z","avatar_url":"https://github.com/python-trio.png","language":"Python","readme":"# purerpc\n\n\u003c!-- start-badges --\u003e\n[![Build Status](https://img.shields.io/github/actions/workflow/status/python-trio/purerpc/ci.yml)](https://github.com/python-trio/purerpc/actions/workflows/ci.yml)\n[![PyPI version](https://img.shields.io/pypi/v/purerpc.svg?style=flat)](https://pypi.org/project/purerpc/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/purerpc.svg)](https://pypi.org/project/purerpc)\n\u003c!-- end-badges --\u003e\n\n_purerpc_ is a native, async Python gRPC client and server implementation supporting\n[asyncio](https://docs.python.org/3/library/asyncio.html),\n[uvloop](https://github.com/MagicStack/uvloop), and\n[trio](https://github.com/python-trio/trio) (achieved with [anyio](https://github.com/agronholm/anyio) compatibility layer).\n\nThis project is in maintenance mode.  Updates will primarily be limited to fixing\nsevere bugs, keeping the package usable for actively developed projects, and\neasing maintenance.\n\nFor use cases limited to asyncio, consider the Python package published by the\nmain [grpc](https://github.com/grpc/grpc) project instead.\n\n## Requirements\n\n* CPython \u003e= 3.8\n* ? PyPy \u003e= 3.8\n\n## Installation\n\nLatest PyPI version:\n\n```bash\npip install purerpc[grpc]\n```\n\nNOTE: for PyPy, replace \"grpc\" with \"grpc-pypy\".  Support is tentative, as\n  [grpc does not officially support PyPy](https://github.com/grpc/grpc/issues/4221).\n\nLatest development version:\n\n```bash\npip install git+https://github.com/python-trio/purerpc.git[grpc]\n```\n\nThese invocations will include dependencies for the grpc runtime and\ngeneration of service stubs.\n\nTo install extra dependencies for running tests or examples, using the\n`test_utils` module, etc., apply the `[dev]` suffix (e.g.\n`pip install purerpc[dev]`).\n\n## protoc plugin\n\npurerpc adds `protoc-gen-purerpc` plugin for `protoc` to your `PATH` environment variable\nso you can use it to generate service definition and stubs: \n\n```bash\nprotoc --purerpc_out=. --python_out=. -I. greeter.proto\n```\n\nor, if you installed the `grpcio-tools` Python package:\n\n```bash\npython -m grpc_tools.protoc --purerpc_out=. --python_out=. -I. greeter.proto\n```\n\n## Usage\n\nNOTE: `greeter_grpc` module is generated by purerpc's `protoc-gen-purerpc` plugin.\n\n### Server\n\n```python\nfrom purerpc import Server\nfrom greeter_pb2 import HelloRequest, HelloReply\nfrom greeter_grpc import GreeterServicer\n\n\nclass Greeter(GreeterServicer):\n    async def SayHello(self, message):\n        return HelloReply(message=\"Hello, \" + message.name)\n\n    async def SayHelloToMany(self, input_messages):\n        async for message in input_messages:\n            yield HelloReply(message=f\"Hello, {message.name}\")\n\n\nif __name__ == '__main__':\n    server = Server(50055)\n    server.add_service(Greeter().service)\n    # NOTE: if you already have an async loop running, use \"await server.serve_async()\"\n    import anyio\n    anyio.run(server.serve_async)  # or set explicit backend=\"asyncio\" or \"trio\"\n```\n\n### Client\n\n```python\nimport purerpc\nfrom greeter_pb2 import HelloRequest, HelloReply\nfrom greeter_grpc import GreeterStub\n\n\nasync def gen():\n    for i in range(5):\n        yield HelloRequest(name=str(i))\n\n\nasync def listen():\n    async with purerpc.insecure_channel(\"localhost\", 50055) as channel:\n        stub = GreeterStub(channel)\n        reply = await stub.SayHello(HelloRequest(name=\"World\"))\n        print(reply.message)\n\n        async with stub.SayHelloToMany(gen()) as stream:\n            async for reply in stream:\n                print(reply.message)\n\n\nif __name__ == '__main__':\n    # NOTE: if you already have an async loop running, use \"await listen()\"\n    import anyio\n    anyio.run(listen)  # or set explicit backend=\"asyncio\" or \"trio\"\n```\n\nYou can mix server and client code, for example make a server that requests something using purerpc from another gRPC server, etc.\n\nMore examples in `misc/` folder\n\n# Project history\n\npurerpc was originally written by [Andrew Stepanov](https://github.com/standy66)\nand used the curio async event loop.  Later it\nwas migrated to the [anyio](https://github.com/agronholm/anyio) API, supporting\nasyncio, curio, uvloop, and trio (though curio support has since been dropped\nfrom the API).\n\nAfter going a few years unmaintained, the project was adopted by the [python-trio\norganization](https://github.com/python-trio) with the intent of ensuring a\ncontinued gRPC solution for Trio users.\n","funding_links":["https://github.com/sponsors/python-trio","https://opencollective.com/python-trio"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-trio%2Fpurerpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-trio%2Fpurerpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-trio%2Fpurerpc/lists"}