me
/
guix
Archived
1
0
Fork 0

gnu: ocrodjvu: Use a Python 3 compatible fork.

* gnu/packages/djvu.scm (ocrodjvu)[source]: Update URL to Python 3 fork.
[inputs]: Use new style.  Remove python2-subprocess32.  Replace all other
Python 2 inputs by their Python 3 equivalent.  Add python-future and
python-regex.
[arguments]: Use gexps, and adjust accordingly, using this-package-input and
search-input-file.
Maxim Cournoyer 2022-04-29 17:08:04 -04:00
parent 1c865e8e1c
commit 1db8080591
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 85 additions and 81 deletions

View File

@ -24,6 +24,7 @@
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix git-download) #:use-module (guix git-download)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix build-system python) #:use-module (guix build-system python)
@ -398,85 +399,88 @@ and background layers of images, which can then be encoded into a DjVu file.")
(license license:gpl2))) (license license:gpl2)))
(define-public ocrodjvu (define-public ocrodjvu
(package (let ((revision "0")
(name "ocrodjvu") (commit "0dd3364462fc77d5674b4457fcc8230835323c30"))
(version "0.12") (package
(source (name "ocrodjvu")
(origin (version (git-version "0.12" revision commit))
(method url-fetch) (source (origin
(uri (string-append (method git-fetch)
"https://github.com/jwilk/ocrodjvu/releases/download/" version (uri (git-reference
"/ocrodjvu-" version ".tar.xz")) ;; Use the following fork repository, as upstream
(sha256 ;; doesn't seem too concerned with Python 3
(base32 "09w9rqr7z2jd5kwp178zz2yrsc82mxs7gksipg92znxzgzhmw2ng")))) ;; compatibility.
(build-system gnu-build-system) (url "https://github.com/rmast/ocrodjvu")
(native-inputs (commit commit)))
(list libxml2 python2-nose python2-pillow)) (file-name (git-file-name name version))
(inputs (sha256
`(("djvulibre" ,djvulibre) (base32
("ocrad" ,ocrad) "0x64hg9ysrk8sismxb4jgk0sq7r9j90v2i9765xhmxpiy6f0lpni"))))
("python" ,python-2) (build-system gnu-build-system)
("python2-djvulibre" ,python2-djvulibre) (native-inputs
("python2-html5lib" ,python2-html5lib) (list libxml2 python-nose python-pillow))
("python2-lxml" ,python2-lxml) (inputs
("python2-pyicu" ,python2-pyicu) (list djvulibre
("python2-subprocess32" ,python2-subprocess32) ocrad
("tesseract-ocr" ,tesseract-ocr))) python-djvulibre
(arguments python-future
`(#:modules ((guix build gnu-build-system) python-html5lib
((guix build python-build-system) #:prefix python:) python-lxml
(guix build utils)) python-pyicu
#:imported-modules (,@%gnu-build-system-modules python-regex
(guix build python-build-system)) python-wrapper
#:test-target "test" tesseract-ocr))
#:phases (arguments
(modify-phases %standard-phases (list
(delete 'configure) #:modules '((guix build gnu-build-system)
(add-before 'check 'disable-failing-test ((guix build python-build-system) #:prefix python:)
(lambda _ (guix build utils))
(substitute* "tests/test_ipc.py" #:imported-modules `(,@%gnu-build-system-modules
;; test_wait_signal gets stuck forever (guix build python-build-system))
(("yield self\\._test_signal, name") #:test-target "test"
"return True") #:phases
;; test_path fails to find a file it should have created #~(modify-phases %standard-phases
(("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)") (delete 'configure)
"return True")) (add-before 'check 'disable-failing-test
;; Disable tests with tesseract. They can't work without (lambda _
;; the language files that must downloaded by the final user (substitute* "tests/test_ipc.py"
;; as they are not packaged in Guix. ;; test_wait_signal gets stuck forever
(substitute* "tests/ocrodjvu/test.py" (("yield self\\._test_signal, name")
(("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)") "return True")
"engines = ['ocrad']")) ;; test_path fails to find a file it should have created
(substitute* "tests/ocrodjvu/test_integration.py" (("path = os\\.getenv\\('PATH'\\)\\.split\\(':'\\)")
(("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'") "return True"))
"engines = 'ocrad'")))) ;; Disable tests with tesseract. They can't work without
(replace 'install ;; the language files that must downloaded by the final user
(lambda* (#:key outputs #:allow-other-keys) ;; as they are not packaged in Guix.
(let ((out (assoc-ref outputs "out"))) (substitute* "tests/ocrodjvu/test.py"
(invoke "make" (("engines = stdout\\.getvalue\\(\\)\\.splitlines\\(\\)")
"DESTDIR=" "engines = ['ocrad']"))
(string-append "PREFIX=" out) (substitute* "tests/ocrodjvu/test_integration.py"
"install")))) (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
(add-after 'install 'wrap-python "engines = 'ocrad'"))))
(assoc-ref python:%standard-phases 'wrap)) (replace 'install
(add-after 'wrap-python 'wrap-path (lambda _
(lambda* (#:key inputs outputs #:allow-other-keys) (invoke "make" "install"
(let ((out (assoc-ref outputs "out")) "DESTDIR=" (string-append "PREFIX=" #$output))))
(djvulibre (assoc-ref inputs "djvulibre")) (add-after 'install 'wrap-python
(ocrad (assoc-ref inputs "ocrad")) (assoc-ref python:%standard-phases 'wrap))
(tesseract (assoc-ref inputs "tesseract-ocr"))) (add-after 'wrap-python 'wrap-path
(for-each (lambda (file) (lambda* (#:key outputs #:allow-other-keys)
(wrap-program (string-append out "/bin/" file) (for-each (lambda (file)
`("PATH" ":" prefix (wrap-program (search-input-file outputs file)
(,(string-append djvulibre "/bin:" `("PATH" ":" prefix
ocrad "/bin:" (,(string-append
tesseract "/bin"))))) #$(this-package-input "djvulibre") "/bin:"
'("djvu2hocr" #$(this-package-input "ocrad") "/bin:"
"hocr2djvused" #$(this-package-input "tesseract-ocr")
"ocrodjvu")))))))) "/bin")))))
(synopsis "Program to perform OCR on DjVu files") '("bin/djvu2hocr"
(description "bin/hocr2djvused"
"@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform "bin/ocrodjvu")))))))
(synopsis "Program to perform OCR on DjVu files")
(description
"@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform
OCR on DjVu files.") OCR on DjVu files.")
(home-page "https://jwilk.net/software/ocrodjvu") (home-page "https://jwilk.net/software/ocrodjvu")
(license license:gpl2))) (license license:gpl2))))