open-webui: fix build (#438551)
This commit is contained in:
@@ -39,7 +39,7 @@ python3Packages.buildPythonApplication {
|
||||
pyjson5 # Google Lens
|
||||
google-cloud-vision
|
||||
manga-ocr
|
||||
rapidocr-onnxruntime
|
||||
rapidocr
|
||||
requests # winRT OCR
|
||||
];
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
# optional dependencies
|
||||
tesserocr,
|
||||
rapidocr-onnxruntime,
|
||||
rapidocr,
|
||||
onnxruntime,
|
||||
ray,
|
||||
|
||||
@@ -68,7 +68,7 @@ buildPythonPackage rec {
|
||||
optional-dependencies = {
|
||||
tesserocr = [ tesserocr ];
|
||||
rapidocr = [
|
||||
rapidocr-onnxruntime
|
||||
rapidocr
|
||||
onnxruntime
|
||||
];
|
||||
ray = [ ray ];
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
websockets,
|
||||
tesserocr,
|
||||
typer,
|
||||
rapidocr-onnxruntime,
|
||||
rapidocr,
|
||||
onnxruntime,
|
||||
torch,
|
||||
torchvision,
|
||||
@@ -81,7 +81,7 @@ buildPythonPackage rec {
|
||||
tesserocr
|
||||
];
|
||||
rapidocr = [
|
||||
rapidocr-onnxruntime
|
||||
rapidocr
|
||||
onnxruntime
|
||||
];
|
||||
cpu = [
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
pypdfium2,
|
||||
python-docx,
|
||||
python-pptx,
|
||||
rapidocr-onnxruntime,
|
||||
rapidocr,
|
||||
requests,
|
||||
rtree,
|
||||
scipy,
|
||||
@@ -90,7 +90,7 @@ buildPythonPackage rec {
|
||||
pypdfium2
|
||||
python-docx
|
||||
python-pptx
|
||||
rapidocr-onnxruntime
|
||||
rapidocr
|
||||
requests
|
||||
rtree
|
||||
scipy
|
||||
@@ -112,7 +112,7 @@ buildPythonPackage rec {
|
||||
];
|
||||
rapidocr = [
|
||||
onnxruntime
|
||||
rapidocr-onnxruntime
|
||||
rapidocr
|
||||
];
|
||||
tesserocr = [
|
||||
tesserocr
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
replaceVars,
|
||||
|
||||
setuptools,
|
||||
colorlog,
|
||||
pyclipper,
|
||||
opencv-python,
|
||||
omegaconf,
|
||||
numpy,
|
||||
six,
|
||||
shapely,
|
||||
@@ -23,13 +21,13 @@
|
||||
requests,
|
||||
}:
|
||||
let
|
||||
version = "3.3.1";
|
||||
version = "1.4.4";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "RapidAI";
|
||||
repo = "RapidOCR";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-EgVBMQX+E8ejUd/6FUQ+uJoWjrQSVznpPcc2gA2wAOE=";
|
||||
hash = "sha256-x0VELDKOffxbV3v0aDFJFuDC4YfsGM548XWgINmRc3M=";
|
||||
};
|
||||
|
||||
models =
|
||||
@@ -64,51 +62,62 @@ buildPythonPackage {
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p rapidocr/models
|
||||
mv setup_onnxruntime.py setup.py
|
||||
|
||||
ln -s ${models}/* rapidocr/models
|
||||
ln -s ${models}/* rapidocr_onnxruntime/models
|
||||
|
||||
# Magic patch from upstream - what does this even do??
|
||||
echo "from .rapidocr.main import RapidOCR, VisRes" > __init__.py
|
||||
echo "from .rapidocr_onnxruntime.main import RapidOCR, VisRes" > __init__.py
|
||||
'';
|
||||
|
||||
# Upstream expects the source files to be under rapidocr/rapidocr
|
||||
# instead of rapidocr for the wheel to build correctly.
|
||||
# Upstream expects the source files to be under rapidocr_onnxruntime/rapidocr_onnxruntime
|
||||
# instead of rapidocr_onnxruntime for the wheel to build correctly.
|
||||
preBuild = ''
|
||||
mkdir rapidocr_t
|
||||
mv rapidocr rapidocr_t
|
||||
mv rapidocr_t rapidocr
|
||||
mkdir rapidocr_onnxruntime_t
|
||||
mv rapidocr_onnxruntime rapidocr_onnxruntime_t
|
||||
mv rapidocr_onnxruntime_t rapidocr_onnxruntime
|
||||
'';
|
||||
|
||||
# Revert the above hack
|
||||
postBuild = ''
|
||||
mv rapidocr rapidocr_t
|
||||
mv rapidocr_t/* .
|
||||
mv rapidocr_onnxruntime rapidocr_onnxruntime_t
|
||||
mv rapidocr_onnxruntime_t/* .
|
||||
'';
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
dependencies = [
|
||||
colorlog
|
||||
numpy
|
||||
omegaconf
|
||||
onnxruntime
|
||||
opencv-python
|
||||
pillow
|
||||
pyclipper
|
||||
pyyaml
|
||||
requests
|
||||
shapely
|
||||
opencv-python
|
||||
numpy
|
||||
six
|
||||
shapely
|
||||
pyyaml
|
||||
pillow
|
||||
onnxruntime
|
||||
tqdm
|
||||
];
|
||||
|
||||
pythonImportsCheck = [ "rapidocr" ];
|
||||
pythonImportsCheck = [ "rapidocr_onnxruntime" ];
|
||||
|
||||
# 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
|
||||
# in a hermetic build environment anymore :(
|
||||
doCheck = false;
|
||||
nativeCheckInputs = [
|
||||
pytestCheckHook
|
||||
requests
|
||||
];
|
||||
|
||||
# These are tests for different backends.
|
||||
disabledTestPaths = [
|
||||
"tests/test_vino.py"
|
||||
"tests/test_paddle.py"
|
||||
];
|
||||
|
||||
disabledTests = [
|
||||
# Needs Internet access
|
||||
"test_long_img"
|
||||
];
|
||||
|
||||
# rapidocr-onnxruntime has been renamed to rapidocr by upstream since 2.0.0. However, some packages like open-webui still requires rapidocr-onnxruntime 1.4.4. Therefore we set no auto update here.
|
||||
# nixpkgs-update: no auto update
|
||||
passthru.skipBulkUpdate = true;
|
||||
|
||||
meta = {
|
||||
# This seems to be related to https://github.com/microsoft/onnxruntime/issues/10038
|
||||
@@ -117,8 +126,8 @@ buildPythonPackage {
|
||||
changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}";
|
||||
description = "Cross platform OCR Library based on OnnxRuntime";
|
||||
homepage = "https://github.com/RapidAI/RapidOCR";
|
||||
license = with lib.licenses; [ asl20 ];
|
||||
maintainers = with lib.maintainers; [ pluiedev ];
|
||||
mainProgram = "rapidocr";
|
||||
license = lib.licenses.asl20;
|
||||
maintainers = with lib.maintainers; [ wrvsrx ];
|
||||
mainProgram = "rapidocr_onnxruntime";
|
||||
};
|
||||
}
|
||||
|
||||
+13
-16
@@ -1,25 +1,22 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 16938a4..5167972 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
diff --git i/setup_onnxruntime.py w/setup_onnxruntime.py
|
||||
index e9572e9..f5f3b32 100644
|
||||
--- i/setup_onnxruntime.py
|
||||
+++ w/setup_onnxruntime.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,20 +24,7 @@ def get_readme():
|
||||
|
||||
|
||||
MODULE_NAME = "rapidocr"
|
||||
@@ -25,17 +24,7 @@ def get_readme():
|
||||
|
||||
|
||||
MODULE_NAME = "rapidocr_onnxruntime"
|
||||
-
|
||||
-obtainer = GetPyPiLatestVersion()
|
||||
-try:
|
||||
- latest_version = obtainer(MODULE_NAME)
|
||||
-except Exception as e:
|
||||
- latest_version = "0.0.0"
|
||||
-latest_version = obtainer(MODULE_NAME)
|
||||
-VERSION_NUM = obtainer.version_add_one(latest_version, add_patch=True)
|
||||
-
|
||||
-if len(sys.argv) > 2:
|
||||
@@ -29,6 +26,6 @@ index 16938a4..5167972 100644
|
||||
- VERSION_NUM = matched_versions
|
||||
-sys.argv = sys.argv[:2]
|
||||
+VERSION_NUM = "@version@"
|
||||
|
||||
|
||||
project_urls = {
|
||||
"Documentation": "https://rapidai.github.io/RapidOCRDocs",
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchFromGitHub,
|
||||
|
||||
fetchzip,
|
||||
replaceVars,
|
||||
|
||||
setuptools,
|
||||
colorlog,
|
||||
pyclipper,
|
||||
opencv-python,
|
||||
omegaconf,
|
||||
numpy,
|
||||
six,
|
||||
shapely,
|
||||
pyyaml,
|
||||
pillow,
|
||||
onnxruntime,
|
||||
tqdm,
|
||||
|
||||
pytestCheckHook,
|
||||
requests,
|
||||
}:
|
||||
let
|
||||
version = "3.3.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "RapidAI";
|
||||
repo = "RapidOCR";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-EgVBMQX+E8ejUd/6FUQ+uJoWjrQSVznpPcc2gA2wAOE=";
|
||||
};
|
||||
|
||||
models =
|
||||
fetchzip {
|
||||
url = "https://github.com/RapidAI/RapidOCR/releases/download/v1.1.0/required_for_whl_v1.3.0.zip";
|
||||
hash = "sha256-j/0nzyvu/HfNTt5EZ+2Phe5dkyPOdQw/OZTz0yS63aA=";
|
||||
stripRoot = false;
|
||||
}
|
||||
+ "/required_for_whl_v1.3.0/resources/models";
|
||||
in
|
||||
buildPythonPackage {
|
||||
pname = "rapidocr";
|
||||
inherit version src;
|
||||
pyproject = true;
|
||||
|
||||
sourceRoot = "${src.name}/python";
|
||||
|
||||
# HACK:
|
||||
# Upstream uses a very unconventional structure to organize the packages, and we have to coax the
|
||||
# existing infrastructure to work with it.
|
||||
# See https://github.com/RapidAI/RapidOCR/blob/02829ef986bc2a5c4f33e9c45c9267bcf2d07a1d/.github/workflows/gen_whl_to_pypi_rapidocr_ort.yml#L80-L92
|
||||
# for the "intended" way of building this package.
|
||||
|
||||
# The setup.py supplied by upstream tries to determine the current version by
|
||||
# fetching the latest version of the package from PyPI, and then bumping the version number.
|
||||
# This is not allowed in the Nix build environment as we do not have internet access,
|
||||
# hence we patch that out and get the version from the build environment directly.
|
||||
patches = [
|
||||
(replaceVars ./setup-py-override-version-checking.patch {
|
||||
inherit version;
|
||||
})
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
mkdir -p rapidocr/models
|
||||
|
||||
ln -s ${models}/* rapidocr/models
|
||||
|
||||
echo "from .rapidocr.main import RapidOCR, VisRes" > __init__.py
|
||||
'';
|
||||
|
||||
# Upstream expects the source files to be under rapidocr/rapidocr
|
||||
# instead of rapidocr for the wheel to build correctly.
|
||||
preBuild = ''
|
||||
mkdir rapidocr_t
|
||||
mv rapidocr rapidocr_t
|
||||
mv rapidocr_t rapidocr
|
||||
'';
|
||||
|
||||
# Revert the above hack
|
||||
postBuild = ''
|
||||
mv rapidocr rapidocr_t
|
||||
mv rapidocr_t/* .
|
||||
'';
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
dependencies = [
|
||||
colorlog
|
||||
numpy
|
||||
omegaconf
|
||||
onnxruntime
|
||||
opencv-python
|
||||
pillow
|
||||
pyclipper
|
||||
pyyaml
|
||||
requests
|
||||
shapely
|
||||
six
|
||||
tqdm
|
||||
];
|
||||
|
||||
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
|
||||
# in a hermetic build environment anymore :(
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
# This seems to be related to https://github.com/microsoft/onnxruntime/issues/10038
|
||||
# Also some related issue: https://github.com/NixOS/nixpkgs/pull/319053#issuecomment-2167713362
|
||||
badPlatforms = [ "aarch64-linux" ];
|
||||
changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}";
|
||||
description = "Cross platform OCR Library based on OnnxRuntime";
|
||||
homepage = "https://github.com/RapidAI/RapidOCR";
|
||||
license = with lib.licenses; [ asl20 ];
|
||||
maintainers = with lib.maintainers; [ pluiedev ];
|
||||
mainProgram = "rapidocr";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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,20 +24,7 @@ def get_readme():
|
||||
|
||||
|
||||
MODULE_NAME = "rapidocr"
|
||||
-
|
||||
-obtainer = GetPyPiLatestVersion()
|
||||
-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:
|
||||
- match_str = " ".join(sys.argv[2:])
|
||||
- matched_versions = obtainer.extract_version(match_str)
|
||||
- if matched_versions:
|
||||
- VERSION_NUM = matched_versions
|
||||
-sys.argv = sys.argv[:2]
|
||||
+VERSION_NUM = "@version@"
|
||||
|
||||
project_urls = {
|
||||
"Documentation": "https://rapidai.github.io/RapidOCRDocs",
|
||||
@@ -15589,6 +15589,8 @@ self: super: with self; {
|
||||
|
||||
rapidgzip = callPackage ../development/python-modules/rapidgzip { inherit (pkgs) nasm; };
|
||||
|
||||
rapidocr = callPackage ../development/python-modules/rapidocr { };
|
||||
|
||||
rapidocr-onnxruntime = callPackage ../development/python-modules/rapidocr-onnxruntime { };
|
||||
|
||||
rapt-ble = callPackage ../development/python-modules/rapt-ble { };
|
||||
|
||||
Reference in New Issue
Block a user