diff mbox

[v2,1/3] gnu: Add python-pypdf2.

Message ID 1478731153-27023-1-git-send-email-h.goebel@crazy-compilers.com
State New
Headers show

Commit Message

Hartmut Goebel Nov. 9, 2016, 10:39 p.m. UTC
* gnu/packages/pdf.scm(python-pypdf2, python2-pypdf2): New variables.
---
 gnu/packages/pdf.scm | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Ludovic Courtès Nov. 10, 2016, 10:46 a.m. UTC | #1
Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> * gnu/packages/pdf.scm(python-pypdf2, python2-pypdf2): New variables.
                        ^
Space please.

> +    (arguments
> +     `(#:tests? #f)) ; tests fail in Python 3 (due to str vs bytes)

So probably we should only build the Python 2 variant?  WDYT?

> +@item and more!

I’d remove this line.

> +By being pure Python, it should run on any Python platform without any
> +dependencies on external libraries.  It can also work entirely on StringIO

@code{StringIO}

Thanks,
Ludo’.
Hartmut Goebel Nov. 10, 2016, 10:58 a.m. UTC | #2
Am 10.11.2016 um 11:46 schrieb Ludovic Courtès:
>> > +    (arguments
>> > +     `(#:tests? #f)) ; tests fail in Python 3 (due to str vs bytes)
> So probably we should only build the Python 2 variant?  WDYT?
>

The main feature of PyPDF2 is that is supports Python 3, what the old
pyPdf does not. So we need Python 3.

The test suite does not fail in the sense that it shows bugs, but in a
way that shows the test suite was not adopted to work with Python 3. The
test-suite is negligible anyway.  I'll update the comment.
Ludovic Courtès Nov. 10, 2016, 12:35 p.m. UTC | #3
Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> Am 10.11.2016 um 11:46 schrieb Ludovic Courtès:
>>> > +    (arguments
>>> > +     `(#:tests? #f)) ; tests fail in Python 3 (due to str vs bytes)
>> So probably we should only build the Python 2 variant?  WDYT?
>>
>
> The main feature of PyPDF2 is that is supports Python 3, what the old
> pyPdf does not. So we need Python 3.
>
> The test suite does not fail in the sense that it shows bugs, but in a
> way that shows the test suite was not adopted to work with Python 3. The
> test-suite is negligible anyway.  I'll update the comment.

Hmm, OK.  That doesn’t make it sounds like it’s really safe to use with
Python 3.

At the very least, the test suite should be disabled only for the
Python 3 variant IMO, and with a slightly more detailed explanation in
the comment.

Thanks!

Ludo’.
Hartmut Goebel Nov. 10, 2016, 1:10 p.m. UTC | #4
Am 10.11.2016 um 13:35 schrieb Ludovic Courtès:
> Hmm, OK.  That doesn’t make it sounds like it’s really safe to use with
> Python 3.

You challenged me :-)   I fixed the test-suite using a simple change
which opens a file in binary mode.
diff mbox

Patch

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index ee33e3c..e243006 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -784,3 +784,48 @@  the framebuffer.")
     (description "@command{pdf2svg} is a simple command-line PDF to SVG
 converter using the Poppler and Cairo libraries.")
     (license license:gpl2+)))
+
+(define-public python-pypdf2
+  (package
+    (name "python-pypdf2")
+    (version "1.26.0")
+    (source (origin
+              (method url-fetch)
+              (uri (pypi-uri "PyPDF2" version))
+              (sha256
+               (base32
+                "11a3aqljg4sawjijkvzhs3irpw0y67zivqpbjpm065ha5wpr13z2"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f)) ; tests fail in Python 3 (due to str vs bytes)
+    (home-page "http://mstamy2.github.com/PyPDF2")
+    (synopsis "Pure Python PDF toolkit")
+    (description "A pure Python library built as a PDF toolkit.  It is capable
+of:
+
+@enumerate
+@item extracting document information (title, author, …)
+@item splitting documents page by page
+@item merging documents page by page
+@item cropping pages
+@item merging multiple pages into a single page
+@item encrypting and decrypting PDF files
+@item and more!
+@end enumerate
+
+By being pure Python, it should run on any Python platform without any
+dependencies on external libraries.  It can also work entirely on StringIO
+objects rather than file streams, allowing for PDF manipulation in memory.  It
+is therefore a useful tool for websites that manage or manipulate PDFs.")
+    (license license:bsd-3)))
+
+(define-public python2-pypdf2
+  (package
+    (inherit (package-with-python2 python-pypdf2))
+    (arguments
+     `(#:python ,python-2
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'check
+           (lambda _
+             (zero? (system* "python" "-m" "unittest" "Tests.tests")))))))))