Skip to content

Commit

Permalink
Fix a series of issues (#533)
Browse files Browse the repository at this point in the history
* Using poetry as dependencies management & publishing tools

* Rename rocketmq-client to rocketmq

* Add publishing Steps

* Add logging module support

* Format code

* fix style & license issues

* add license for python client protocol

---------

Co-authored-by: Aaron Ai <[email protected]>
Co-authored-by: Aaron Ai <[email protected]>
  • Loading branch information
3 people committed Jun 2, 2023
1 parent c8a94f2 commit e96712e
Show file tree
Hide file tree
Showing 26 changed files with 1,667 additions and 445 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- run: python -m pip install flake8
- name: flake8
run: |
flake8 --ignore=E501,W503 --exclude python/protocol python
flake8 --ignore=E501,W503 --exclude python/rocketmq/protocol python
isort:
runs-on: ubuntu-latest
steps:
Expand All @@ -28,7 +28,7 @@ jobs:
- run: python -m pip install isort
- name: isort
run: |
isort --check --diff --skip python/protocol python
isort --check --diff --skip python/rocketmq/protocol python
black:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ golang/*.exe
*.pyo
*.pyd
python/myvenv/
python/__pycache__/
python/__pycache__/
python/dist
33 changes: 19 additions & 14 deletions python/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@

## 快速开始

推荐使用 Python 虚拟环境进行开发,可以按照以下步骤操作:

首先切换到当前仓库的 `python` 子目录,然后执行以下命令创建一个新的虚拟环境:

```sh
python3 -m venv myvenv
我们使用 Poetry 作为依赖管理和发布的工具。你可以在 Poetry 的[官方网站]((https://python-poetry.org/))了解到关于它的更多信息。这里是一些在开发阶段你会使用到的 Poetry 命令:

```shell
# 创建并激活 python3 的虚拟环境
poetry env use python3
# 自动安装工程相关的依赖
poetry install
# 进入虚拟环境中的 shell
poetry shell
```

其次开始激活虚拟环境。激活方法取决于具体的操作系统:
我们使用 pytest 来作为当前项目的测试框架,你可以通过直接执行 `pytest` 命令来运行所有的测试。

* 对于Windows,执行:`myvenv\Scripts\activate.bat`
* 对于macOS/Linux:执行:`source myvenv/bin/activate`
## 发布步骤

执行以下命令以安装所需的依赖库
我们使用 PyPi 来帮助用户更好地在自己的工程中引入并使用客户端。为了将客户端发布到 PyPi,可以执行以下命令

```sh
pip install -r requirements.txt
```shell
# 构建包
poetry build
# 将包发布到远程仓库
poetry publish -u username -p password
```

## 目前进展

* 协议层代码生成完毕
* rpcClient完成部分
* 协议层代码生成完毕
* `rpc_client.py` 完成部分。
32 changes: 18 additions & 14 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,31 @@ Here are some preparations you may need to know (or refer to [here](https://rock

## Getting Started

Clone the current repository to your local machine and set up a virtual environment for development, which will help you manage dependencies more efficiently. Follow the steps below:

Navigate to the `python` subdirectory and execute the command below to create a new virtual environment:

```sh
python3 -m venv myvenv
We are using Poetry as the dependency management & publishing tool. You can find out more details about Poetry from its [website](https://python-poetry.org/). Here is the related command of Poetry you may use for development.

```shell
# Create a virtual environment and activate it.
poetry env use python3
# Installs the project dependencies.
poetry install
# Spawns a shell within the virtual environment.
poetry shell
```

Activate the virtual environment. The activation method depends on your operating system:
We use pytest as the testing framework for the current project, and you can execute `pytest` directly to run all tests.

* For Windows, execute: `myvenv\Scripts\activate.bat`
* For macOS/Linux: execute: `source myvenv/bin/activate`
## Publishing Steps

Install the required dependency libraries by executing the following command:
We utilize PyPI to help users easily introduce and use the Python client in their projects. To publish a package to PyPI, please register an account in advance, then execute the following command.

```sh
pip install -r requirements.txt
```shell
# Builds a package, as a tarball and a wheel by default.
poetry build
# Publishes a package to a remote repository.
poetry publish -u username -p password
```

## Current Progress

* Protocol layer code generation is completed.

* Partial completion of rpcClient.
* Partial completion of `rpc_client.py`.
106 changes: 0 additions & 106 deletions python/client/rpc_client.py

This file was deleted.

Loading

0 comments on commit e96712e

Please sign in to comment.