[PATCH 0/4 pdf-crop-margins python package]

  • Open
  • quality assurance status badge
Details
One participant
  • Nicolas Graves
Owner
unassigned
Submitted by
Nicolas Graves
Severity
normal
N
N
Nicolas Graves wrote on 7 Sep 2023 17:18
(address . guix-patches@gnu.org)
87edjaj9kb.fsf@ngraves.fr
--
Best regards,
Nicolas Graves
N
N
Nicolas Graves wrote on 8 Sep 2023 01:32
[PATCH 2/4] gnu: Add python-pysimplegui.
(address . 65806@debbugs.gnu.org)(address . ngraves@ngraves.fr)
67b3d1810b1f05aa13fd896020a47254f4774577.1694129533.git.ngraves@ngraves.fr
* gnu/packages/python-xyz.scm (python-pysimplegui): New variable.
---
gnu/packages/python-xyz.scm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

Toggle diff (32 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index c0e4b62418..61a8c57f1e 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -5531,6 +5531,25 @@ (define-public python-pysdl2
common SDL2 functionality.")
(license license:cc0)))
+(define-public python-pysimplegui
+ (package
+ (name "python-pysimplegui")
+ (version "4.60.4")
+ (source (origin
+ (method url-fetch)
+ (uri (pypi-uri "PySimpleGUI" version))
+ (sha256
+ (base32
+ "1fi39fmh2iw88h2jh5ifd2vdrc6fpihc0pb0pqsyl6m5071q537q"))))
+ (build-system pyproject-build-system)
+ (inputs (list `(,python "tk")))
+ (home-page "https://github.com/PySimpleGUI/PySimpleGUI")
+ (synopsis "Python GUI library")
+ (description
+ "This package provides a simple Graphical User Interface library for
+Python.")
+ (license license:lgpl3)))
+
(define-public python-pystache
(package
(name "python-pystache")
--
2.41.0
N
N
Nicolas Graves wrote on 8 Sep 2023 01:32
[PATCH 1/4] gnu: Add python-pymupdf.
(address . 65806@debbugs.gnu.org)(address . ngraves@ngraves.fr)
bc8af8e30e35ffdd7e31970ebb021dea978cdcbe.1694129533.git.ngraves@ngraves.fr
* gnu/packages/pdf.scm (python-pymupdf): New variable.
---
gnu/packages/pdf.scm | 58 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)

Toggle diff (91 lines)
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index e270bdf27f..30cc325d48 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -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")

base-commit: 72745172d155e489936f694d6b9013cb76272370
prerequisite-patch-id: eb618ab7b10483d917c308a38792af98baa517e2
prerequisite-patch-id: 40b6c9f09f27833367a71ec25d77afae4d2a835e
prerequisite-patch-id: c12968d02d99c253f858586a86b16fa32d41f1c1
prerequisite-patch-id: 09d995d48139f8e61183d5634cda13a01cdb50f7
prerequisite-patch-id: 86baa45ec2aad977c8c8135f7613aa391155de6d
prerequisite-patch-id: 3425fbbff6a603d60b4e143ea2141aabf4ddc92c
prerequisite-patch-id: c373c01aab5dcba3503a97d51c62a595147a041c
prerequisite-patch-id: cda857c790b88c681c4e713c5f71e40291970daf
prerequisite-patch-id: 8e234d0f4d93d2aad499eec8842be3d28da98707
prerequisite-patch-id: 5f664cb2fd995a53765c5ffc19a708ac795cc0c4
prerequisite-patch-id: ed447cba9cf9b7e1a1b47aa27acb14f8f2da0a8e
--
2.41.0
N
N
Nicolas Graves wrote on 8 Sep 2023 01:32
[PATCH 3/4] gnu: Add pdf-crop-margins.
(address . 65806@debbugs.gnu.org)(address . ngraves@ngraves.fr)
3535c0c58a946e35378224215147e969deba1659.1694129533.git.ngraves@ngraves.fr
* gnu/packages/pdf.scm (pdf-crop-margins): New variable.
---
gnu/packages/pdf.scm | 57 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)

Toggle diff (70 lines)
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 30cc325d48..2266296621 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -964,6 +964,63 @@ (define-public python-pymupdf
analysis, conversion & manipulation of PDF (and other) documents.")
(license license:agpl3+)))
+(define-public pdf-crop-margins
+ (let ((commit "6d89093e33e98ab02196cfc5e06e96003771e735")
+ (revision "0"))
+ (package
+ (name "pdf-crop-margins")
+ (version "2.0.3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/abarker/pdfCropMargins")
+ ;; Releases are not in git tags.
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0144px9kl927z6gx380i2sd75izqzxnnzl3laih2dwpqp82r9j6f"))))
+ (build-system pyproject-build-system)
+ (arguments
+ (list
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'lift-requirements
+ (lambda _
+ (substitute* "setup.py"
+ (("pillow>=9\\.3\\.0") ; security issues handled by a patch
+ "pillow>=9.2.0")))))))
+ (native-inputs (list python-setuptools
+ python-pillow))
+ (propagated-inputs (list ghostscript
+ python-pymupdf
+ python-pysimplegui))
+ (home-page "https://github.com/abarker/pdfCropMargins")
+ (synopsis "Automatically crop the margins of PDF files")
+ (description "The pdfCropMargins program is a command-line application to
+automatically crop the margins of PDF files. Cropping the margins can make it
+easier to read the pages of a PDF document -- whether the document is printed
+or displayed on a screen -- because the display fonts are larger.
+
+Features
+@itemize
+@item Automatically detects the margins and can crop a given percentage of them.
+@item Can crop all the pages to the same size to give a uniform appearance.
+@item Renders and analyzes page images to find the bounding boxes, which allows
+it to deal with noisy scanned PDFs.
+@item A rudimentary 'undo' capability is implemented by default.
+@item Can crop pages uniformly based on the nth smallest crop values, to help
+with noisy documents where a few pages have unwanted markings in their margins.
+@item Can automatically run a document previewer on the output file.
+@item The format of automatically-generated output-file names is modifiable.
+@item Preserves document catalog information such as outlines if possible.
+@item Crops rotated pages according to their appearance in the document viewer.
+@item Can deal with at least simple cases of password-encrypted files.
+@item Can automatically apply a Ghostscript repair operation to attempt to fix
+corrupt PDF files.
+@end itemize")
+ (license license:gpl3+))))
+
(define-public qpdf
(package
(name "qpdf")
--
2.41.0
N
N
Nicolas Graves wrote on 8 Sep 2023 01:32
[PATCH 4/4] gnu: Add pdf-crop-margins-cli.
(address . 65806@debbugs.gnu.org)(address . ngraves@ngraves.fr)
f27279df0034950b1623ee1f763e36309410b937.1694129533.git.ngraves@ngraves.fr
* gnu/packages/pdf.scm (pdf-crop-margins-cli): New variable.
---
gnu/packages/pdf.scm | 15 +++++++++++++++
1 file changed, 15 insertions(+)

Toggle diff (28 lines)
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 2266296621..7b224746db 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -1021,6 +1021,21 @@ (define-public pdf-crop-margins
@end itemize")
(license license:gpl3+))))
+(define-public pdf-crop-margins-cli
+ (package
+ (inherit pdf-crop-margins)
+ (name "pdf-crop-margins-cli")
+ (arguments
+ (list #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'delete-gui-dependencies
+ (lambda _
+ (substitute* "setup.py"
+ (("\"pillow[><=0-9\\.,]*\",") "")
+ (("\"PySimpleGUI[><=0-9\\.,]*\",") "")))))))
+ (native-inputs (list python-wheel python-setuptools))
+ (propagated-inputs (list ghostscript python-pymupdf))))
+
(define-public qpdf
(package
(name "qpdf")
--
2.41.0
?