# Python plugin over gRPC
## install SDK
Before you develop your python plugin, you need to install an dependency as SDK.
```bash
$ python3 -m pip install funppy
```
## create plugin functions
Then you can write your plugin functions in python. The functions can be very flexible, only the following restrictions should be complied with.
- function should return at most one value and one error.
- `funppy.register()` must be called to register plugin functions and `funppy.serve()` must be called to start a plugin server process.
Here is some plugin functions as example.
```python
import logging
from typing import List
import funppy
def sum_two_int(a: int, b: int) -> int:
return a + b
def sum_ints(*args: List[int]) -> int:
result = 0
for arg in args:
result += arg
return result
def Sum(*args):
result = 0
for arg in args:
result += arg
return result
if __name__ == '__main__':
funppy.register("sum_two_int", sum_two_int)
funppy.register("sum_ints", sum_ints)
funppy.register("sum", Sum)
funppy.serve()
```
You can get more examples at [funppy/examples/].
## build plugin
Python plugins do not need to be complied, just make sure its file suffix is `.py` by convention and should not be changed.
## use plugin functions
Finally, you can use `Init` to initialize plugin via the `xxx.py` path, and you can call the plugin API to handle plugin functionality.
[funppy/examples/]: ../funppy/examples/
Raw data
{
"_id": null,
"home_page": "https://github.com/httprunner/funplugin",
"name": "funppy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "debugtalk",
"author_email": "mail@debugtalk.com",
"download_url": "https://files.pythonhosted.org/packages/b1/8f/a734c6cb96e72189c4137b251536436d12a50ae8f63c0a8cc5cc00cab370/funppy-0.5.2.tar.gz",
"platform": null,
"description": "# Python plugin over gRPC\n\n## install SDK\n\nBefore you develop your python plugin, you need to install an dependency as SDK.\n\n```bash\n$ python3 -m pip install funppy\n```\n\n## create plugin functions\n\nThen you can write your plugin functions in python. The functions can be very flexible, only the following restrictions should be complied with.\n\n- function should return at most one value and one error.\n- `funppy.register()` must be called to register plugin functions and `funppy.serve()` must be called to start a plugin server process.\n\nHere is some plugin functions as example.\n\n```python\nimport logging\nfrom typing import List\n\nimport funppy\n\n\ndef sum_two_int(a: int, b: int) -> int:\n return a + b\n\ndef sum_ints(*args: List[int]) -> int:\n result = 0\n for arg in args:\n result += arg\n return result\n\ndef Sum(*args):\n result = 0\n for arg in args:\n result += arg\n return result\n\n\nif __name__ == '__main__':\n funppy.register(\"sum_two_int\", sum_two_int)\n funppy.register(\"sum_ints\", sum_ints)\n funppy.register(\"sum\", Sum)\n funppy.serve()\n```\n\nYou can get more examples at [funppy/examples/].\n\n## build plugin\n\nPython plugins do not need to be complied, just make sure its file suffix is `.py` by convention and should not be changed.\n\n## use plugin functions\n\nFinally, you can use `Init` to initialize plugin via the `xxx.py` path, and you can call the plugin API to handle plugin functionality.\n\n\n[funppy/examples/]: ../funppy/examples/\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Python plugin over gRPC for funplugin",
"version": "0.5.2",
"project_urls": {
"Homepage": "https://github.com/httprunner/funplugin",
"Repository": "https://github.com/httprunner/funplugin"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "885717478f5b44110c3f5e5a88853d83749199fcadf1415cd490ff3c818ba488",
"md5": "883eb27203debe55f7fb19b5ef37f759",
"sha256": "85a9ced74a4a9560e179ae5c57cf262e8db2d023d13760d1a5261a9b3e8cb58b"
},
"downloads": -1,
"filename": "funppy-0.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "883eb27203debe55f7fb19b5ef37f759",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6,<4.0",
"size": 9602,
"upload_time": "2023-08-10T14:42:49",
"upload_time_iso_8601": "2023-08-10T14:42:49.815598Z",
"url": "https://files.pythonhosted.org/packages/88/57/17478f5b44110c3f5e5a88853d83749199fcadf1415cd490ff3c818ba488/funppy-0.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b18fa734c6cb96e72189c4137b251536436d12a50ae8f63c0a8cc5cc00cab370",
"md5": "b0c1c63e8a47b8478c3ce7f0dac02a70",
"sha256": "0a65b14da7b1507118e944141d9401ad2ba199262bf6e35b4ef35554dcb817e9"
},
"downloads": -1,
"filename": "funppy-0.5.2.tar.gz",
"has_sig": false,
"md5_digest": "b0c1c63e8a47b8478c3ce7f0dac02a70",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6,<4.0",
"size": 8212,
"upload_time": "2023-08-10T14:42:51",
"upload_time_iso_8601": "2023-08-10T14:42:51.052426Z",
"url": "https://files.pythonhosted.org/packages/b1/8f/a734c6cb96e72189c4137b251536436d12a50ae8f63c0a8cc5cc00cab370/funppy-0.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-10 14:42:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "httprunner",
"github_project": "funplugin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "funppy"
}