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,39 +399,47 @@ 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
(let ((revision "0")
(commit "0dd3364462fc77d5674b4457fcc8230835323c30"))
(package (package
(name "ocrodjvu") (name "ocrodjvu")
(version "0.12") (version (git-version "0.12" revision commit))
(source (source (origin
(origin (method git-fetch)
(method url-fetch) (uri (git-reference
(uri (string-append ;; Use the following fork repository, as upstream
"https://github.com/jwilk/ocrodjvu/releases/download/" version ;; doesn't seem too concerned with Python 3
"/ocrodjvu-" version ".tar.xz")) ;; compatibility.
(url "https://github.com/rmast/ocrodjvu")
(commit commit)))
(file-name (git-file-name name version))
(sha256 (sha256
(base32 "09w9rqr7z2jd5kwp178zz2yrsc82mxs7gksipg92znxzgzhmw2ng")))) (base32
"0x64hg9ysrk8sismxb4jgk0sq7r9j90v2i9765xhmxpiy6f0lpni"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(native-inputs (native-inputs
(list libxml2 python2-nose python2-pillow)) (list libxml2 python-nose python-pillow))
(inputs (inputs
`(("djvulibre" ,djvulibre) (list djvulibre
("ocrad" ,ocrad) ocrad
("python" ,python-2) python-djvulibre
("python2-djvulibre" ,python2-djvulibre) python-future
("python2-html5lib" ,python2-html5lib) python-html5lib
("python2-lxml" ,python2-lxml) python-lxml
("python2-pyicu" ,python2-pyicu) python-pyicu
("python2-subprocess32" ,python2-subprocess32) python-regex
("tesseract-ocr" ,tesseract-ocr))) python-wrapper
tesseract-ocr))
(arguments (arguments
`(#:modules ((guix build gnu-build-system) (list
#:modules '((guix build gnu-build-system)
((guix build python-build-system) #:prefix python:) ((guix build python-build-system) #:prefix python:)
(guix build utils)) (guix build utils))
#:imported-modules (,@%gnu-build-system-modules #:imported-modules `(,@%gnu-build-system-modules
(guix build python-build-system)) (guix build python-build-system))
#:test-target "test" #:test-target "test"
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(delete 'configure) (delete 'configure)
(add-before 'check 'disable-failing-test (add-before 'check 'disable-failing-test
(lambda _ (lambda _
@ -451,32 +460,27 @@ and background layers of images, which can then be encoded into a DjVu file.")
(("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'") (("engines = 'tesseract', 'cuneiform', 'gocr', 'ocrad'")
"engines = 'ocrad'")))) "engines = 'ocrad'"))))
(replace 'install (replace 'install
(lambda* (#:key outputs #:allow-other-keys) (lambda _
(let ((out (assoc-ref outputs "out"))) (invoke "make" "install"
(invoke "make" "DESTDIR=" (string-append "PREFIX=" #$output))))
"DESTDIR="
(string-append "PREFIX=" out)
"install"))))
(add-after 'install 'wrap-python (add-after 'install 'wrap-python
(assoc-ref python:%standard-phases 'wrap)) (assoc-ref python:%standard-phases 'wrap))
(add-after 'wrap-python 'wrap-path (add-after 'wrap-python 'wrap-path
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(djvulibre (assoc-ref inputs "djvulibre"))
(ocrad (assoc-ref inputs "ocrad"))
(tesseract (assoc-ref inputs "tesseract-ocr")))
(for-each (lambda (file) (for-each (lambda (file)
(wrap-program (string-append out "/bin/" file) (wrap-program (search-input-file outputs file)
`("PATH" ":" prefix `("PATH" ":" prefix
(,(string-append djvulibre "/bin:" (,(string-append
ocrad "/bin:" #$(this-package-input "djvulibre") "/bin:"
tesseract "/bin"))))) #$(this-package-input "ocrad") "/bin:"
'("djvu2hocr" #$(this-package-input "tesseract-ocr")
"hocr2djvused" "/bin")))))
"ocrodjvu")))))))) '("bin/djvu2hocr"
"bin/hocr2djvused"
"bin/ocrodjvu")))))))
(synopsis "Program to perform OCR on DjVu files") (synopsis "Program to perform OCR on DjVu files")
(description (description
"@code{ocrodjvu} is a wrapper for OCR systems, that allows you to perform "@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))))