python313Packages.rapidocr-onnxruntime: fix build (#436289)

This commit is contained in:
Yt
2025-08-24 13:11:23 -04:00
committed by GitHub
2 changed files with 39 additions and 32 deletions
@@ -7,8 +7,10 @@
replaceVars,
setuptools,
colorlog,
pyclipper,
opencv-python,
omegaconf,
numpy,
six,
shapely,
@@ -62,44 +64,46 @@ buildPythonPackage {
];
postPatch = ''
mv setup_onnxruntime.py setup.py
mkdir -p rapidocr_onnxruntime/models
mkdir -p rapidocr/models
ln -s ${models}/* rapidocr_onnxruntime/models
ln -s ${models}/* rapidocr/models
# Magic patch from upstream - what does this even do??
echo "from .rapidocr_onnxruntime.main import RapidOCR, VisRes" > __init__.py
echo "from .rapidocr.main import RapidOCR, VisRes" > __init__.py
'';
# Upstream expects the source files to be under rapidocr_onnxruntime/rapidocr_onnxruntime
# instead of rapidocr_onnxruntime for the wheel to build correctly.
# Upstream expects the source files to be under rapidocr/rapidocr
# instead of rapidocr for the wheel to build correctly.
preBuild = ''
mkdir rapidocr_onnxruntime_t
mv rapidocr_onnxruntime rapidocr_onnxruntime_t
mv rapidocr_onnxruntime_t rapidocr_onnxruntime
mkdir rapidocr_t
mv rapidocr rapidocr_t
mv rapidocr_t rapidocr
'';
# Revert the above hack
postBuild = ''
mv rapidocr_onnxruntime rapidocr_onnxruntime_t
mv rapidocr_onnxruntime_t/* .
mv rapidocr rapidocr_t
mv rapidocr_t/* .
'';
build-system = [ setuptools ];
dependencies = [
pyclipper
opencv-python
colorlog
numpy
six
shapely
pyyaml
pillow
omegaconf
onnxruntime
opencv-python
pillow
pyclipper
pyyaml
requests
shapely
six
tqdm
];
pythonImportsCheck = [ "rapidocr_onnxruntime" ];
pythonImportsCheck = [ "rapidocr" ];
# As of version 2.1.0, 61 out of 70 tests require internet access.
# It's just not plausible to manually pick out ones that actually work
@@ -115,6 +119,6 @@ buildPythonPackage {
homepage = "https://github.com/RapidAI/RapidOCR";
license = with lib.licenses; [ asl20 ];
maintainers = with lib.maintainers; [ pluiedev ];
mainProgram = "rapidocr_onnxruntime";
mainProgram = "rapidocr";
};
}
@@ -1,22 +1,25 @@
diff --git i/setup_onnxruntime.py w/setup_onnxruntime.py
index e9572e9..f5f3b32 100644
--- i/setup_onnxruntime.py
+++ w/setup_onnxruntime.py
diff --git a/setup.py b/setup.py
index 16938a4..5167972 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,6 @@ from pathlib import Path
from typing import List, Union
import setuptools
-from get_pypi_latest_version import GetPyPiLatestVersion
def read_txt(txt_path: Union[Path, str]) -> List[str]:
@@ -25,17 +24,7 @@ def get_readme():
MODULE_NAME = "rapidocr_onnxruntime"
@@ -25,20 +24,7 @@ def get_readme():
MODULE_NAME = "rapidocr"
-
-obtainer = GetPyPiLatestVersion()
-latest_version = obtainer(MODULE_NAME)
-try:
- latest_version = obtainer(MODULE_NAME)
-except Exception as e:
- latest_version = "0.0.0"
-VERSION_NUM = obtainer.version_add_one(latest_version, add_patch=True)
-
-if len(sys.argv) > 2:
@@ -26,6 +29,6 @@ index e9572e9..f5f3b32 100644
- VERSION_NUM = matched_versions
-sys.argv = sys.argv[:2]
+VERSION_NUM = "@version@"
project_urls = {
"Documentation": "https://rapidai.github.io/RapidOCRDocs",