From a07b9c27a7d7c60ef017a73c9cd399fa9cc15ee5 Mon Sep 17 00:00:00 2001 From: SWHL Date: Tue, 15 Oct 2024 10:17:40 +0800 Subject: [PATCH] fix(rapidocr_api): Fixed issue #223 --- api/rapidocr_api/{api.py => main.py} | 4 ++-- api/setup.py | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) rename api/rapidocr_api/{api.py => main.py} (92%) diff --git a/api/rapidocr_api/api.py b/api/rapidocr_api/main.py similarity index 92% rename from api/rapidocr_api/api.py rename to api/rapidocr_api/main.py index 471f3028e..5ac113c3d 100644 --- a/api/rapidocr_api/api.py +++ b/api/rapidocr_api/main.py @@ -45,7 +45,7 @@ def __call__(self, img: Image.Image) -> Dict: @app.get("/") async def root(): - return {"message": "Welcome to RapidOCR Server!"} + return {"message": "Welcome to RapidOCR API Server!"} @app.post("/ocr") @@ -71,7 +71,7 @@ def main(): parser.add_argument("-p", "--port", type=int, default=9003, help="IP port") args = parser.parse_args() - uvicorn.run("api:app", host=args.ip, port=args.port, reload=True) + uvicorn.run("rapidocr_api.main:app", host=args.ip, port=args.port, reload=True) if __name__ == "__main__": diff --git a/api/setup.py b/api/setup.py index 54e6df1ce..9b5f7c339 100644 --- a/api/setup.py +++ b/api/setup.py @@ -3,11 +3,21 @@ # @Contact: liekkaskono@163.com import sys from pathlib import Path +from typing import List import setuptools from get_pypi_latest_version import GetPyPiLatestVersion +def read_txt(txt_path: str) -> List: + if not isinstance(txt_path, str): + txt_path = str(txt_path) + + with open(txt_path, "r", encoding="utf-8") as f: + data = list(map(lambda x: x.rstrip("\n"), f)) + return data + + def get_readme(): root_dir = Path(__file__).resolve().parent.parent readme_path = str(root_dir / "docs" / "doc_whl_rapidocr_api.md") @@ -22,7 +32,7 @@ def get_readme(): try: latest_version = obtainer(MODULE_NAME) except ValueError: - latest_version = "0.0.0" + latest_version = "0.0.1" VERSION_NUM = obtainer.version_add_one(latest_version) if len(sys.argv) > 2: @@ -45,12 +55,7 @@ def get_readme(): download_url="https://github.com/RapidAI/RapidOCR.git", license="Apache-2.0", include_package_data=True, - install_requires=[ - "requests", - "rapidocr_onnxruntime", - "fastapi", - "uvicorn[standard]", - ], + install_requires=read_txt("requirements.txt"), packages=[MODULE_NAME], package_data={"": ["*.ico", "*.css", "*.js", "*.html"]}, keywords=[ @@ -68,7 +73,7 @@ def get_readme(): python_requires=">=3.6,<3.13", entry_points={ "console_scripts": [ - f"{MODULE_NAME}={MODULE_NAME}.api:main", + f"{MODULE_NAME}={MODULE_NAME}.main:main", ], }, )