Unverified Commit d23f9d34 authored by dotlambda's avatar dotlambda Committed by GitHub
Browse files

open-webui: fix build (#438551)

parents b86e775e 898a1df7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ python3Packages.buildPythonApplication {
    pyjson5 # Google Lens
    google-cloud-vision
    manga-ocr
    rapidocr-onnxruntime
    rapidocr
    requests # winRT OCR
  ];

+2 −2
Original line number Diff line number Diff line
@@ -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 ];
+2 −2
Original line number Diff line number Diff line
@@ -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 = [
+3 −3
Original line number Diff line number Diff line
@@ -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
+41 −32
Original line number Diff line number Diff line
@@ -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" ];

  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"
  ];

  # 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;
  # 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";
  };
}
Loading