@@ -103,6 +103,7 @@ (define-module (gnu packages pdf)
#:use-module (gnu packages sdl)
#:use-module (gnu packages sphinx)
#:use-module (gnu packages sqlite)
+ #:use-module (gnu packages swig)
#:use-module (gnu packages tex)
#:use-module (gnu packages time)
#:use-module (gnu packages tcl)
@@ -906,6 +907,63 @@ (define-public mupdf
license:silofl1.1 ;resources/fonts/{han,noto,sil,urw}
license:asl2.0)))) ; resources/fonts/droid
+(define-public python-pymupdf
+ (package
+ (name "python-pymupdf")
+ (version "1.22.5")
+ (source
+ (origin
+ ;; Not pypi because it download the third_party tarball.
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/pymupdf/PyMuPDF")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0n2dvszry5h163x8nn2n33mb2rhjgfjsyllhr02n4fz9madv4rx8"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:test-flags #~(list "-k" "not test_color_count")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-before 'build 'set-build-env
+ (lambda _
+ (let ((include-mupdf
+ #$(file-append (this-package-input "mupdf") "/include")))
+ (substitute* "setup.py"
+ (("^include_dirs = .*$")
+ (string-append
+ "include_dirs = [ \"" include-mupdf "/mupdf\", \""
+ #$(file-append
+ (this-package-input "freetype") "/include/freetype2")
+ "\"]\n"))
+ (("^extra_swig_args = .*$")
+ (string-append
+ "extra_swig_args = [ \"-I" include-mupdf "\" ]\n"))))
+ (setenv "CC" "gcc")
+ (setenv "USE_SYSTEM_LIBS" "yes")
+ (setenv "PYMUPDF_SETUP_MUPDF_BUILD" "")
+ (setenv "PYMUPDF_SETUP_MUPDF_THIRD" "0"))))))
+ (inputs (list mupdf
+ freetype
+ gumbo-parser
+ harfbuzz
+ jbig2dec
+ libjpeg-turbo
+ openjpeg
+ tesseract-ocr))
+ (native-inputs (list gcc
+ pkg-config
+ swig
+ python-pytest
+ python-fonttools))
+ (home-page "https://github.com/pymupdf/PyMuPDF")
+ (synopsis "Python bindings for the PDF toolkit and renderer MuPDF")
+ (description "This package provides a Python library for data extraction,
+analysis, conversion & manipulation of PDF (and other) documents.")
+ (license license:agpl3+)))
+
(define-public qpdf
(package
(name "qpdf")