-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【OCR Issue No.12】Modify the setuptools configuration from SETUP.py into PYPROJECT.toml #12013
Changes from 16 commits
f8672be
29eab17
47dcf25
8d37b93
17ea8dc
53e1a0a
3a232d9
fd15c1a
59fbdf0
941dbdd
d58ba0f
5ed0c62
8ec404a
144f31f
b6ab5d4
2e02b16
11b7406
4299680
99e6086
9baed76
9e5e2c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.8.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,9 @@ | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import importlib.metadata as importlib_metadata | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个文件,我觉得不需要改动。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果这个文件不需要改动,其实也不需要使用setuptools_scm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我意思是不要自己实现这个功能,而是用 setuptools_scm 这样的标准化工具来实现。 |
||
|
||
try: | ||
__version__ = importlib_metadata.version(__package__ or __name__) | ||
except importlib_metadata.PackageNotFoundError: | ||
__version__ = "0.0.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
[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"} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在这里添加类似
的配置。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个文件应该不需要了吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个可以留着,用来兼容以前的在命令行下运行 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加了这个文件的话,就得对 paddleocr.py 进行改造了。
可以试试,在 pyproject.toml 中用 setuptools_scm 自动生成一个 version.py , 然后让 paddleocr.py 从这里获取版本号。 可以参考一下 paddle2onnx 里的做法。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.github/workflows/python-publish.yml
这个也要改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果希望setuptools_scm 生成version,则需要在ppocr/init.py中import这个version.py,打包就会采用默认生成的编号了。这样做将会彻底撇开VERSION_NUMBER。
按照pp2onnx的写法,最终应该还是在读VERSION_NUMBER的版本号。