From 206f3b91c5b0c91e20eee42dc94d4cfbf471c041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Fri, 22 Nov 2024 10:47:29 +0800 Subject: [PATCH] Added setup.py --- .gitignore | 4 +++- README.md | 25 +++++++++++++++++++++++++ roc/__init__.py | 2 ++ setup.py | 34 ++++++++++++++++++++++++++++++++++ tests/main.py | 3 ++- 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 README.md create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index a47fb1d..5b01c98 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea -__pycache__ \ No newline at end of file +__pycache__ +dist +roc_py.egg-info \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c2e4def --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# Hyperf 多路复用 RPC 组件 Python 版本 + +## 如何使用 + +```python +import asyncio + +from roc.request import Request +from roc.socket import Client + + +async def main(): + client = Client(host="127.0.0.1", port=9502) + while True: + req = Request(path="/test/test", + params={"mobile": "123123", "data": "HelloWorld"}) + res = await client.request(req) + print(res.result) + await asyncio.sleep(1) + + +if __name__ == '__main__': + asyncio.run(main()) + +``` \ No newline at end of file diff --git a/roc/__init__.py b/roc/__init__.py index e69de29..984b96c 100644 --- a/roc/__init__.py +++ b/roc/__init__.py @@ -0,0 +1,2 @@ +from roc.request import Request +from roc.socket import Client diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..5afcbfe --- /dev/null +++ b/setup.py @@ -0,0 +1,34 @@ +import setuptools + +with open("README.md", "r") as fh: + long_description = fh.read() + +setuptools.setup( + # 包的分发名称,使用字母、数字、_、- + name="roc-py", + # 版本号, 版本号规范:https://www.python.org/dev/peps/pep-0440/ + version="0.1.0", + # 作者名 + author="limingxinleo", + # 作者邮箱 + author_email="l@hyperf.io", + # 包的简介描述 + description="Hyperf 多路复用 RPC 组件 Python 版本", + # 包的详细介绍(一般通过加载README.md) + long_description=long_description, + # 和上条命令配合使用,声明加载的是markdown文件 + long_description_content_type="text/markdown", + # 项目开源地址 + url="https://github.com/hyperf/roc-py", + # 如果项目由多个文件组成,我们可以使用find_packages()自动发现所有包和子包,而不是手动列出每个包,在这种情况下,包列表将是example_pkg + packages=setuptools.find_packages(), + # 关于包的其他元数据(metadata) + classifiers=[ + # 该软件包仅与Python3兼容 + "Programming Language :: Python :: 3", + # 根据MIT许可证开源 + "License :: OSI Approved :: MIT License", + # 与操作系统无关 + "Operating System :: OS Independent", + ], +) diff --git a/tests/main.py b/tests/main.py index 0867cb0..15d2cdc 100644 --- a/tests/main.py +++ b/tests/main.py @@ -14,4 +14,5 @@ async def main(): await asyncio.sleep(1) -asyncio.run(main()) +if __name__ == '__main__': + asyncio.run(main())