Skip to content

πŸ“„ Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Add actions about publishing to pypi

SWHL5dd04644b95b
diff --git a/.github/workflows/gen_whl_to_pypi.yml b/.github/workflows/gen_whl_to_pypi.yml
index 241299e..c8773b5 100644
--- a/.github/workflows/gen_whl_to_pypi.yml
+++ b/.github/workflows/gen_whl_to_pypi.yml
@@ -34,8 +34,17 @@ jobs:
cd ..
python setup.py bdist_wheel
-
- - name: Push to pypi
- run: |
- pip install twine -i https://pypi.douban.com/simple/
- twine upload dist/* -u ${{ secrets.TWINE_NAME }} -p ${{ secrets.TWINE_PWD }}
+ mv dist ../
+
+ # - name: Publish distribution πŸ“¦ to Test PyPI
+ # uses: pypa/[email protected]
+ # with:
+ # password: ${{ secrets.TEST_PYPI_API_TOKEN }}
+ # repository_url: https://test.pypi.org/legacy/
+ # packages_dir: dist/
+
+ - name: Publish distribution πŸ“¦ to PyPI
+ uses: pypa/[email protected]
+ with:
+ password: ${{ secrets.PYPI_API_TOKEN }}
+ packages_dir: dist/
diff --git a/docs/doc_whl_en.md b/docs/doc_whl_en.md
new file mode 100644
index 0000000..b198154
--- /dev/null
+++ b/docs/doc_whl_en.md
@@ -0,0 +1,31 @@
+## rapidocr-onnxruntime Package
+
+### Install package by pypi
+```bash
+pip install "rapidocr-onnxruntime"
+```
+
+### Install the models and config yaml.
+```bash
+wget https://github.com/RapidAI/RapidOCR/releases/download/v2.0.0/required_for_whl_v1.0.0.zip
+
+# or by gitee
+# wget https://gitee.com/RapidAI/RapidOCR/attach_files/1122519/download/required_for_whl_v1.0.0.zip
+
+unzip required_for_whl_v1.0.0.zip
+cd required_for_whl_v1.0.0
+
+```
+
+### Use by python script
+```python
+import cv2
+from rapidocr_onnxruntime import TextSystem
+
+text_sys = TextSystem('config.yaml')
+
+img = cv2.imread('test_images/ch_en_num.jpg')
+
+dt_boxes, rec_res = text_sys(img)
+print(rec_res)
+```
\ No newline at end of file
diff --git a/python/setup.py b/python/setup.py
index 72dfb00..f3e12b0 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -1,20 +1,53 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: [email protected]
+from pathlib import Path
import setuptools
+import subprocess
-with open('README.md', 'r') as f:
- README = f.read()
+def get_latest_version(package_name):
+ output = subprocess.run(["pip", "index", "versions", package_name],
+ capture_output=True)
+ output = output.stdout.decode('utf-8')
+ if output:
+ output = list(filter(lambda x: len(x) > 0, output.split('\n')))
+ latest_version = output[-1].split(':')[1].strip()
+ return latest_version
+ else:
+ return None
+
+
+def version_add_one(version, add_loc=-1):
+ if version:
+ version_list = version.split('.')
+ mini_version = str(int(version_list[add_loc]) + 1)
+ version_list[add_loc] = mini_version
+ new_version = '.'.join(version_list)
+ return new_version
+ else:
+ return None
+
+
+def get_readme():
+ root_dir = Path(__file__).resolve().parent.parent
+ readme_path = str(root_dir / 'docs' / 'doc_whl_en.md')
+ print(readme_path)
+ with open(readme_path, 'r') as f:
+ readme = f.read()
+ return readme
module_name = 'rapidocr_onnxruntime'
+latest_version = get_latest_version(module_name)
+version_num = version_add_one(latest_version)
+
setuptools.setup(
name=module_name,
- version="1.0.0",
+ version=version_num,
platforms="Windows & Linux & Mac",
description="RapidOCR",
- long_description=README,
+ long_description=get_readme(),
long_description_content_type='text/markdown',
author="SWHL",
author_email="[email protected]",
@@ -25,6 +58,9 @@ setuptools.setup(
"opencv_python>=4.5.1.48", "numpy>=1.19.3",
"six>=1.15.0", "Shapely>=1.7.1"],
package_dir={'': module_name},
- packages=setuptools.find_packages(where=module_name)
+ packages=setuptools.find_packages(where=module_name),
+ keywords=[
+ 'ocr textdetection textrecognition crnn east star-net rosetta ocrlite db chineseocr chinesetextdetection chinesetextrecognition'
+ ],
)