prpc-python


Nameprpc-python JSON
Version 0.9.2 PyPI version JSON
download
home_pagehttps://github.com/SocialFinanceDigitalLabs/prpc
SummaryA very simple RPC-like library to make writing Pyodide applications easier. At the core of the library is a simple App + Decorator based approach inspired by Flask.
upload_time2022-12-20 23:41:46
maintainer
docs_urlNone
authorKaj Siebert
requires_python>=3.7,<4.0
licenseMIT
keywords rpc pyodide
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# prpc-python - Pyodide Remote Procedure Calls - Python Server

[![PyPI version](https://badge.fury.io/py/prpc-python.svg)](https://badge.fury.io/py/prpc-python)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/prpc-python.svg)](https://pypi.org/project/prpc-python/)
[![PyPI - License](https://img.shields.io/pypi/l/prpc-python.svg)](https://pypi.org/project/prpc-python/)
[![GitHub issues](https://img.shields.io/github/issues/SocialFinanceDigitalLabs/prpc.svg)](https://github.com/SocialFinanceDigitalLabs/prpc/issues)

Provides server-side bindings for [prpc][prpc] API. 

To expose a python function as a prpc method you first create
a prpc `RpcApp` and then decorate your function with `@app.call`. 

Create a file called `myapp.py` and add the following code:

```python
# myapp.py
from prpc_python import RpcApp

app = RpcApp("My Hello World App")


@app.call
def hello():
    return "World"
```

## Discovering your API

You can now discover your API using the `prpc` command line tool. To do this
you either have to specify the plugin ID of your app or "publish" the
plugin using the Python [plugin discovery][discovery] approach.

The ID of your plugin is the name of the module containing 
your `RpcApp` instance plus the name of the instance, e.g. 
`myapp:app` for the example above.

You can now use the command line tool to discover your API:

```bash
prpc commands -a myapp:app     
```

and you can even call your function from the command line:

```bash
prpc run -a myapp:app hello
```

## Publishing 

You don't always want to have to specify the plugin ID of your app. You can 
use the approach described in the [metadata][discovery] section of the packaging
spec to publish your plugin. If you have a `pyproject.toml` file, then add
the following section:

```toml
[tool.poetry.plugins."prpc_python"]
myapp = "myapp:app"
```

If your plugin is the only one in your installed dependencies, then it will
be automatically chosen, and you can omit the `-a myapp:app` argument.

## Files

prpc also supports file transfers. If you receive a file from the remote 
endpoint, you will receive a `prpc_python.RemoteFile` object. This object
has a standard `read` method, so you can use it as a file-like object.

It may also have `filename`, `size` and `content_type` attributes but it
depends on the source of the file whether these are available.

[prpc]: https://github.com/SocialFinanceDigitalLabs/prpc
[discovery]: https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata    

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SocialFinanceDigitalLabs/prpc",
    "name": "prpc-python",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "rpc,pyodide",
    "author": "Kaj Siebert",
    "author_email": "kaj@k-si.com",
    "download_url": "https://files.pythonhosted.org/packages/55/5f/29b9c4fea37aa2bcd7a6538fbac1f4d598056e6c1b40e5d246c1bb92241d/prpc_python-0.9.2.tar.gz",
    "platform": null,
    "description": "\n# prpc-python - Pyodide Remote Procedure Calls - Python Server\n\n[![PyPI version](https://badge.fury.io/py/prpc-python.svg)](https://badge.fury.io/py/prpc-python)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/prpc-python.svg)](https://pypi.org/project/prpc-python/)\n[![PyPI - License](https://img.shields.io/pypi/l/prpc-python.svg)](https://pypi.org/project/prpc-python/)\n[![GitHub issues](https://img.shields.io/github/issues/SocialFinanceDigitalLabs/prpc.svg)](https://github.com/SocialFinanceDigitalLabs/prpc/issues)\n\nProvides server-side bindings for [prpc][prpc] API. \n\nTo expose a python function as a prpc method you first create\na prpc `RpcApp` and then decorate your function with `@app.call`. \n\nCreate a file called `myapp.py` and add the following code:\n\n```python\n# myapp.py\nfrom prpc_python import RpcApp\n\napp = RpcApp(\"My Hello World App\")\n\n\n@app.call\ndef hello():\n    return \"World\"\n```\n\n## Discovering your API\n\nYou can now discover your API using the `prpc` command line tool. To do this\nyou either have to specify the plugin ID of your app or \"publish\" the\nplugin using the Python [plugin discovery][discovery] approach.\n\nThe ID of your plugin is the name of the module containing \nyour `RpcApp` instance plus the name of the instance, e.g. \n`myapp:app` for the example above.\n\nYou can now use the command line tool to discover your API:\n\n```bash\nprpc commands -a myapp:app     \n```\n\nand you can even call your function from the command line:\n\n```bash\nprpc run -a myapp:app hello\n```\n\n## Publishing \n\nYou don't always want to have to specify the plugin ID of your app. You can \nuse the approach described in the [metadata][discovery] section of the packaging\nspec to publish your plugin. If you have a `pyproject.toml` file, then add\nthe following section:\n\n```toml\n[tool.poetry.plugins.\"prpc_python\"]\nmyapp = \"myapp:app\"\n```\n\nIf your plugin is the only one in your installed dependencies, then it will\nbe automatically chosen, and you can omit the `-a myapp:app` argument.\n\n## Files\n\nprpc also supports file transfers. If you receive a file from the remote \nendpoint, you will receive a `prpc_python.RemoteFile` object. This object\nhas a standard `read` method, so you can use it as a file-like object.\n\nIt may also have `filename`, `size` and `content_type` attributes but it\ndepends on the source of the file whether these are available.\n\n[prpc]: https://github.com/SocialFinanceDigitalLabs/prpc\n[discovery]: https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-package-metadata    \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A very simple RPC-like library to make writing Pyodide applications easier. At the core of the library is a simple App + Decorator based approach inspired by Flask.",
    "version": "0.9.2",
    "split_keywords": [
        "rpc",
        "pyodide"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "176bbfa2994cbc6a04a003b64526eff5",
                "sha256": "1c51f97f753f2ad47de6894809f3bfd937a9051725196541e5d558a137c710e0"
            },
            "downloads": -1,
            "filename": "prpc_python-0.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "176bbfa2994cbc6a04a003b64526eff5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 8965,
            "upload_time": "2022-12-20T23:41:44",
            "upload_time_iso_8601": "2022-12-20T23:41:44.945935Z",
            "url": "https://files.pythonhosted.org/packages/a4/2a/516fcd05a171659b7199af668310bbfd5926cea9a5f701ee677dd1d85749/prpc_python-0.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "15e0cac412e75d9f5c68814e33a8317e",
                "sha256": "b8e92d8750523a1a83f72920eccabf02504cff670fe74f52955724b72304f061"
            },
            "downloads": -1,
            "filename": "prpc_python-0.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "15e0cac412e75d9f5c68814e33a8317e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 8188,
            "upload_time": "2022-12-20T23:41:46",
            "upload_time_iso_8601": "2022-12-20T23:41:46.486381Z",
            "url": "https://files.pythonhosted.org/packages/55/5f/29b9c4fea37aa2bcd7a6538fbac1f4d598056e6c1b40e5d246c1bb92241d/prpc_python-0.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-20 23:41:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "SocialFinanceDigitalLabs",
    "github_project": "prpc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "prpc-python"
}
        
Elapsed time: 0.02721s