Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Support to change version by committing message in rapid_table module.

SWHLeaf8e162c094
diff --git a/.github/workflows/gen_whl_to_pypi_rapid_table.yml b/.github/workflows/gen_whl_to_pypi_rapid_table.yml
index a92bc45..f3704de 100644
--- a/.github/workflows/gen_whl_to_pypi_rapid_table.yml
+++ b/.github/workflows/gen_whl_to_pypi_rapid_table.yml
@@ -46,7 +46,7 @@ jobs:
move rapid_table_models\* python\rapid_structure\rapid_table\models\
cd python/rapid_structure
pip install -r requirements.txt
- pip install onnxruntime rapidocr_onnxruntime==1.1.19
+ pip install onnxruntime rapidocr_onnxruntime
cd tests
pytest test_table.py
@@ -73,7 +73,7 @@ jobs:
wget https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/rapid_table_models.zip
unzip rapid_table_models.zip
mv rapid_table_models/en_ppstructure_mobile_v2_SLANet.onnx rapid_table/models/
- python setup_table.py bdist_wheel
+ python setup_table.py bdist_wheel ${{ github.event.head_commit.message }}
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/[email protected]
diff --git a/python/rapid_structure/setup_table.py b/python/rapid_structure/setup_table.py
index f881a8e..34eb257 100644
--- a/python/rapid_structure/setup_table.py
+++ b/python/rapid_structure/setup_table.py
@@ -1,7 +1,9 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
+import re
import subprocess
+import sys
from pathlib import Path
import setuptools
@@ -12,8 +14,7 @@ def get_latest_version(package_name):
capture_output=True)
output = output.stdout.decode('utf-8')
if output:
- output = list(filter(lambda x: len(x) > 0, output.split('\n')))
- return output[0].strip().split(' ')[-1][1:-1]
+ return extract_version(output)
return None
@@ -35,10 +36,26 @@ def get_readme():
return readme
+def extract_version(message: str) -> str:
+ pattern = r'\d+\.(?:\d+\.)*\d+'
+ matched_versions = re.findall(pattern, message)
+ if matched_versions:
+ return matched_versions[0]
+ return ''
+
+
MODULE_NAME = 'rapid_table'
latest_version = get_latest_version(MODULE_NAME)
VERSION_NUM = version_add_one(latest_version)
+# 优先提取commit message中的语义化版本号,如无,则自动加1
+if len(sys.argv) > 2:
+ match_str = ' '.join(sys.argv[2:])
+ matched_versions = extract_version(match_str)
+ if matched_versions:
+ VERSION_NUM = matched_versions
+sys.argv = sys.argv[:2]
+
setuptools.setup(
name=MODULE_NAME,
version=VERSION_NUM,