summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2025-11-24 16:14:44 +0100
committerSharlatan Hellseher <sharlatanus@gmail.com>2025-12-01 23:23:52 +0000
commit5d2a8a4a1b0582ebd548439109e17cf976b95574 (patch)
tree99121edbe1cb5a3be8671bdc23caa3fe752a43c3 /gnu
parentdc155f82a02fbcc9917fdfa6424e92e3d7525bce (diff)
gnu: ocrodjvu: Switch to pyproject.
* gnu/packages/djvu.scm (ocrodjvu): [arguments]: Relocate field, improve style. <#:modules, #:imported-modules>: Switch to pyproject modules. <#:phases>: Wrap with pyproject-guile-json extension. [native-inputs]: Replace python-nose by python-pynose. Change-Id: Ic0009a5986a74fe27551f7aadf3ddb83cf17827b Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/djvu.scm112
1 files changed, 57 insertions, 55 deletions
diff --git a/gnu/packages/djvu.scm b/gnu/packages/djvu.scm
index 5845daf32a6..90ceb1e69e0 100644
--- a/gnu/packages/djvu.scm
+++ b/gnu/packages/djvu.scm
@@ -49,6 +49,7 @@
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-build)
+ #:use-module (gnu packages python-check)
#:use-module (gnu packages python-web)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages qt)
@@ -373,8 +374,63 @@ and background layers of images, which can then be encoded into a DjVu file.")
(base32
"0x64hg9ysrk8sismxb4jgk0sq7r9j90v2i9765xhmxpiy6f0lpni"))))
(build-system gnu-build-system)
+ (arguments
+ (list
+ #:modules '((guix build gnu-build-system)
+ ((guix build pyproject-build-system) #:prefix python:)
+ (guix build utils))
+ #:imported-modules `(,@%default-gnu-imported-modules
+ ,@%pyproject-build-system-modules)
+ #:test-target "test"
+ #:phases
+ (with-extensions (list (pyproject-guile-json))
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (add-after 'unpack 'fix-for-python-3.11
+ (lambda _
+ (substitute* "lib/cli/ocrodjvu.py"
+ ;; The getargspec function has been removed in python 3.11.
+ (("init_args, _, _, _ = inspect.getargspec\\(cls.__init__\\)")
+ "init_args = inspect.getfullargspec(cls.__init__).args"))))
+ (add-before 'check 'disable-failing-test
+ (lambda _
+ (substitute* "tests/test_ipc.py"
+ ;; test_wait_signal gets stuck forever
+ (("yield self\\._test_signal, name")
+ "return True")
+ ;; test_path fails to find a file it should have created
+ (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
+ "return True"))
+ ;; Disable tests with tesseract. They can't work without
+ ;; the language files that must downloaded by the final user
+ ;; as they are not packaged in Guix.
+ (substitute* "tests/ocrodjvu/test.py"
+ (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
+ "engines = ['ocrad']"))
+ (substitute* "tests/ocrodjvu/test_integration.py"
+ (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
+ "engines = 'ocrad'"))))
+ (replace 'install
+ (lambda _
+ (invoke "make" "install"
+ "DESTDIR=" (string-append "PREFIX=" #$output))))
+ (add-after 'install 'wrap-python
+ (assoc-ref python:%standard-phases 'wrap))
+ (add-after 'wrap-python 'wrap-path
+ (lambda* (#:key outputs #:allow-other-keys)
+ (for-each (lambda (file)
+ (wrap-program (search-input-file outputs file)
+ `("PATH" ":" prefix
+ (,(string-append
+ #$(this-package-input "djvulibre") "/bin:"
+ #$(this-package-input "ocrad") "/bin:"
+ #$(this-package-input "tesseract-ocr")
+ "/bin")))))
+ '("bin/djvu2hocr"
+ "bin/hocr2djvused"
+ "bin/ocrodjvu"))))))))
(native-inputs
- (list (libc-utf8-locales-for-target) libxml2 python-nose python-pillow))
+ (list (libc-utf8-locales-for-target) libxml2 python-pynose python-pillow))
(inputs
(list bash-minimal
djvulibre
@@ -387,60 +443,6 @@ and background layers of images, which can then be encoded into a DjVu file.")
python-regex
python-wrapper
tesseract-ocr))
- (arguments
- (list
- #:modules '((guix build gnu-build-system)
- ((guix build python-build-system) #:prefix python:)
- (guix build utils))
- #:imported-modules `(,@%default-gnu-imported-modules
- (guix build python-build-system))
- #:test-target "test"
- #:phases
- #~(modify-phases %standard-phases
- (delete 'configure)
- (add-after 'unpack 'fix-for-python-3.11
- (lambda _
- (substitute* "lib/cli/ocrodjvu.py"
- ;; The getargspec function has been removed in python 3.11.
- (("init_args, _, _, _ = inspect.getargspec\\(cls.__init__\\)")
- "init_args = inspect.getfullargspec(cls.__init__).args"))))
- (add-before 'check 'disable-failing-test
- (lambda _
- (substitute* "tests/test_ipc.py"
- ;; test_wait_signal gets stuck forever
- (("yield self\\._test_signal, name")
- "return True")
- ;; test_path fails to find a file it should have created
- (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
- "return True"))
- ;; Disable tests with tesseract. They can't work without
- ;; the language files that must downloaded by the final user
- ;; as they are not packaged in Guix.
- (substitute* "tests/ocrodjvu/test.py"
- (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
- "engines = ['ocrad']"))
- (substitute* "tests/ocrodjvu/test_integration.py"
- (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
- "engines = 'ocrad'"))))
- (replace 'install
- (lambda _
- (invoke "make" "install"
- "DESTDIR=" (string-append "PREFIX=" #$output))))
- (add-after 'install 'wrap-python
- (assoc-ref python:%standard-phases 'wrap))
- (add-after 'wrap-python 'wrap-path
- (lambda* (#:key outputs #:allow-other-keys)
- (for-each (lambda (file)
- (wrap-program (search-input-file outputs file)
- `("PATH" ":" prefix
- (,(string-append
- #$(this-package-input "djvulibre") "/bin:"
- #$(this-package-input "ocrad") "/bin:"
- #$(this-package-input "tesseract-ocr")
- "/bin")))))
- '("bin/djvu2hocr"
- "bin/hocr2djvused"
- "bin/ocrodjvu")))))))
(synopsis "Program to perform OCR on DjVu files")
(description
"@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform