diff options
Diffstat (limited to 'pkgs/development/python-modules/manga-ocr')
-rw-r--r-- | pkgs/development/python-modules/manga-ocr/default.nix | 65 | ||||
-rw-r--r-- | pkgs/development/python-modules/manga-ocr/package_data.patch | 12 |
2 files changed, 77 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/manga-ocr/default.nix b/pkgs/development/python-modules/manga-ocr/default.nix new file mode 100644 index 0000000000000..7f0371c356ae3 --- /dev/null +++ b/pkgs/development/python-modules/manga-ocr/default.nix @@ -0,0 +1,65 @@ +{ + lib, + fetchFromGitHub, + buildPythonPackage, + fire, + fugashi, + jaconv, + loguru, + numpy, + pillow, + pyperclip, + torch, + transformers, + unidic-lite, + pythonOlder, +}: +buildPythonPackage rec { + pname = "manga-ocr"; + version = "0.1.11"; + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "kha-white"; + repo = pname; + rev = "refs/tags/v${version}"; + hash = "sha256-cLmgHBt6HvhY6Hb9yQ425Gk181axnMr+Mp2LxSmPoDg="; + }; + + preBuild = '' + # remove subproject dedicated to model training + rm -rf manga_ocr_dev + # copy assets/example.jpg inside the package + # required by https://github.com/kha-white/manga-ocr/blob/ba1b0d94a8ef6676b618ba4e5ffe8ce2ab655270/manga_ocr/ocr.py#L27-L30 + # see also package_data.patch + mkdir manga_ocr/assets + cp assets/example.jpg manga_ocr/assets/example.jpg + ''; + + patches = [ + # instruct setuptool to copy assets/example.jpg to package when building wheel + ./package_data.patch + ]; + + propagatedBuildInputs = [ + # taken from requirements.txt + fire + fugashi + jaconv + loguru + numpy + pillow + pyperclip + torch + transformers + unidic-lite + ]; + + meta = with lib; { + description = "Optical character recognition for Japanese text, with the main focus being Japanese manga"; + homepage = "https://github.com/kha-white/manga-ocr"; + changelog = "https://github.com/kha-white/manga-ocr/releases/tag/${version}"; + license = licenses.asl20; + maintainers = with maintainers; [laurent-f1z1]; + }; +} diff --git a/pkgs/development/python-modules/manga-ocr/package_data.patch b/pkgs/development/python-modules/manga-ocr/package_data.patch new file mode 100644 index 0000000000000..6c643f669d3c8 --- /dev/null +++ b/pkgs/development/python-modules/manga-ocr/package_data.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +--- a/setup.py ++++ b/setup.py +@@ -18,6 +18,9 @@ setup( + ], + packages=['manga_ocr'], + include_package_data=True, ++ package_data={ ++ 'manga_ocr': ['assets/example.jpg'], ++ }, + install_requires=[ + "fire", \ No newline at end of file |