diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index a35a1836f7..f78eec15b1 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -33,7 +33,7 @@ jobs: pip install setuptools pip install wheel - name: Build package - run: python setup.py bdist_wheel + run: python -m build - name: Publish package uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 with: diff --git a/VERSION_NUMBER b/VERSION_NUMBER new file mode 100644 index 0000000000..834f262953 --- /dev/null +++ b/VERSION_NUMBER @@ -0,0 +1 @@ +2.8.0 diff --git a/__init__.py b/__init__.py index b085589dea..7233b3c0ed 100644 --- a/__init__.py +++ b/__init__.py @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. from .paddleocr import * +import importlib.metadata as importlib_metadata -__version__ = paddleocr.VERSION +try: + __version__ = importlib_metadata.version(__package__ or __name__) +except importlib_metadata.PackageNotFoundError: + __version__ = "0.0.0" __all__ = [ "PaddleOCR", "PPStructure", diff --git a/paddleocr.py b/paddleocr.py index 57f5aa7ac4..6e8c66ed3c 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -78,7 +78,6 @@ def _import_file(module_name, file_path, make_importable=False): ] SUPPORT_DET_MODEL = ["DB"] -VERSION = "2.8.0" SUPPORT_REC_MODEL = ["CRNN", "SVTR_LCNet"] BASE_DIR = os.path.expanduser("~/.paddleocr/") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..8eb238dfa0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,70 @@ +[build-system] +requires = ["setuptools", "setuptools-scm", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "paddleocr" +# After each version release, the version number needs to be incremented +dynamic = ["version"] +description = "Awesome OCR toolkits based on PaddlePaddle(8.6M ultra-lightweight pre-trained model, support training and deployment among server, mobile, embedded and IoT devices)" +authors = [ + {name = "PaddlePaddle", email = "Paddle-better@baidu.com"}, +] +maintainers = [ + {name = "PaddlePaddle", email = "Paddle-better@baidu.com"}, +] +readme = "README.md" +requires-python = ">=3.8" +keywords = [ + "ocr", + "textdetection", + "textrecognition", + "paddleocr", + "crnn", + "east", + "star-net", + "rosetta", + "ocrlite", + "db", + "chineseocr", + "chinesetextdetection", + "chinesetextrecognition", +] +license = {text = "Apache License 2.0"} +classifiers = [ + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Natural Language :: Chinese (Simplified)", + "Programming Language :: Python :: 3", + "Topic :: Utilities", +] +dependencies = [ + "shapely", + "scikit-image", + "imgaug", + "pyclipper", + "lmdb", + "tqdm", + "numpy", + "rapidfuzz", + "opencv-python<=4.6.0.66", + "opencv-contrib-python<=4.6.0.66", + "cython", + "Pillow>=10.0.0", + "pyyaml", + "python-docx", + "beautifulsoup4", + "fonttools>=4.24.0", + "fire>=0.3.0", +] + +[project.scripts] +paddleocr = "paddleocr.paddleocr:main" + +[tool.setuptools] +packages = ["paddleocr"] +package-dir = { "paddleocr" = "" } +include-package-data = true + +[tool.setuptools.dynamic] +version = {file = "VERSION_NUMBER"} diff --git a/setup.py b/setup.py index 7c06586ff0..f1e3f1b73f 100644 --- a/setup.py +++ b/setup.py @@ -13,68 +13,6 @@ # limitations under the License. from setuptools import setup -from io import open -import subprocess -# get version by matchiing, so will not need to setup complex env in github aciton -p = subprocess.Popen( - "grep ^VERSION ./paddleocr.py | awk '{print $3}' | tr -d '\"'", - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True, -) -raw_VERSION, _ = p.communicate() -VERSION = raw_VERSION.decode().strip() - -def load_requirements(file_list=None): - if file_list is None: - file_list = ["requirements.txt"] - if isinstance(file_list, str): - file_list = [file_list] - requirements = [] - for file in file_list: - with open(file, encoding="utf-8-sig") as f: - requirements.extend(f.readlines()) - return requirements - - -def readme(): - with open("doc/doc_en/whl_en.md", encoding="utf-8-sig") as f: - README = f.read() - return README - - -setup( - name="paddleocr", - packages=["paddleocr"], - package_dir={"paddleocr": ""}, - include_package_data=True, - entry_points={"console_scripts": ["paddleocr= paddleocr.paddleocr:main"]}, - version=VERSION, - install_requires=load_requirements( - ["requirements.txt", "ppstructure/recovery/requirements.txt"] - ), - license="Apache License 2.0", - description="Awesome OCR toolkits based on PaddlePaddle(8.6M ultra-lightweight pre-trained model, support training and deployment among server, mobile, embedded and IoT devices)", - long_description=readme(), - long_description_content_type="text/markdown", - url="https://github.com/PaddlePaddle/PaddleOCR", - download_url="https://github.com/PaddlePaddle/PaddleOCR.git", - keywords=[ - "ocr textdetection textrecognition paddleocr crnn east star-net rosetta ocrlite db chineseocr chinesetextdetection chinesetextrecognition" - ], - classifiers=[ - "Intended Audience :: Developers", - "Operating System :: OS Independent", - "Natural Language :: Chinese (Simplified)", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Topic :: Utilities", - ], -) +setup()