Skip to content

Commit

Permalink
【OCR Issue No.12】Modify the setuptools configuration from SETUP.py in…
Browse files Browse the repository at this point in the history
…to PYPROJECT.toml (#12013)

Modify the setuptools configuration from SETUP.py into PYPROJECT.toml
  • Loading branch information
Liyulingyue authored May 24, 2024
1 parent e73eb76 commit 3a66efc
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions VERSION_NUMBER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.8.0
6 changes: 5 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion paddleocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")

Expand Down
70 changes: 70 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"}
64 changes: 1 addition & 63 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 3a66efc

Please sign in to comment.