diff mbox series

[bug#67970] gnu: python-pdfminer-six: Update to 20221105.

Message ID 00adf56591326b3694c391c78f6a9613f9e78ba2.1703267366.git.felgru@posteo.net
State New
Headers show
Series [bug#67970] gnu: python-pdfminer-six: Update to 20221105. | expand

Commit Message

Felix Gruber Dec. 22, 2023, 5:49 p.m. UTC
* gnu/packages/python-xyz.scm (python-pdfminer-six): Update to 20221105.
  [build-system]: Use pyproject-build-system.
  [arguments]: Convert to gexp, remove custom 'check phase and add new
  phase to fix version.
  [propagated-inputs]: Remove python-chardet and python-sortedcontainers;
  add python-charset-normalizer.
  [native-inputs]: Remove python-nose and python-tox; add python-pytest.
* gnu/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch:
  New file.
* gnu/local.mk (dist_patch_DATA): Add it.

Change-Id: I9913385a681b32afde930e32e7379db91357177b
---
 gnu/local.mk                                  |  1 +
 ...on-pdfminer-six-fix-imports-in-tests.patch | 41 +++++++++++++++++++
 gnu/packages/python-xyz.scm                   | 33 ++++++++-------
 3 files changed, 60 insertions(+), 15 deletions(-)
 create mode 100644 gnu/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch


base-commit: ca813173894360edef35a5d98878a3135e99e62a
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index caf2bb16fa..6e56c5ed38 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1773,6 +1773,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/python-feedparser-missing-import.patch	\
   %D%/packages/patches/python-louvain-fix-test.patch		\
   %D%/packages/patches/python-random2-getrandbits-test.patch		\
+  %D%/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch	\
   %D%/packages/patches/python-poppler-qt5-fix-build.patch	\
   %D%/packages/patches/python-pypdf-annotate-tests-appropriately.patch	\
   %D%/packages/patches/python-sip-include-dirs.patch	\
diff --git a/gnu/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch b/gnu/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch
new file mode 100644
index 0000000000..13c793811a
--- /dev/null
+++ b/gnu/packages/patches/python-pdfminer-six-fix-imports-in-tests.patch
@@ -0,0 +1,41 @@ 
+Fix import errors during tests.
+
+See https://github.com/pdfminer/pdfminer.six/issues/896
+
+This patch has been taken from
+https://build.opensuse.org/package/view_file/openSUSE:Factory/python-pdfminer.six/import-from-non-pythonpath-files.patch
+
+diff '--color=auto' -rub pdfminer.six-20221105.orig/tests/test_tools_dumppdf.py pdfminer.six-20221105/tests/test_tools_dumppdf.py
+--- pdfminer.six-20221105.orig/tests/test_tools_dumppdf.py	2022-11-05 12:22:08.000000000 -0400
++++ pdfminer.six-20221105/tests/test_tools_dumppdf.py	2023-12-11 12:12:06.044210731 -0500
+@@ -4,7 +4,11 @@
+ 
+ from helpers import absolute_sample_path
+ from tempfilepath import TemporaryFilePath
+-from tools import dumppdf
++ 
++import importlib.util
++spec = importlib.util.spec_from_file_location("dumppdf", "tools/dumppdf.py")
++dumppdf = importlib.util.module_from_spec(spec)
++spec.loader.exec_module(dumppdf)
+ 
+ 
+ def run(filename, options=None):
+diff '--color=auto' -rub pdfminer.six-20221105.orig/tests/test_tools_pdf2txt.py pdfminer.six-20221105/tests/test_tools_pdf2txt.py
+--- pdfminer.six-20221105.orig/tests/test_tools_pdf2txt.py	2022-11-05 12:22:08.000000000 -0400
++++ pdfminer.six-20221105/tests/test_tools_pdf2txt.py	2023-12-11 12:12:40.848031179 -0500
+@@ -3,10 +3,13 @@
+ from tempfile import mkdtemp
+ import filecmp
+ 
+-import tools.pdf2txt as pdf2txt
+ from helpers import absolute_sample_path
+ from tempfilepath import TemporaryFilePath
+ 
++import importlib.util
++spec = importlib.util.spec_from_file_location("pdf2txt", "tools/pdf2txt.py")
++pdf2txt = importlib.util.module_from_spec(spec)
++spec.loader.exec_module(pdf2txt)
+ 
+ def run(sample_path, options=None):
+     absolute_path = absolute_sample_path(sample_path)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 404177e9cd..18019cc859 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -18188,7 +18188,7 @@  (define-public python-jellyfish
 (define-public python-pdfminer-six
   (package
     (name "python-pdfminer-six")
-    (version "20201018")
+    (version "20221105")
     ;; There are no tests in the PyPI tarball.
     (source
      (origin
@@ -18198,23 +18198,26 @@  (define-public python-pdfminer-six
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1a2fxxnnjqbx344znpvx7cnv1881dk6585ibw01inhfq3w6yj2lr"))))
-    (build-system python-build-system)
+        (base32 "06gqlpv7vakd3nr20mf2x161z9a9bbvxnvf424i3wzlq3d01w89v"))
+       (patches
+         (search-patches "python-pdfminer-six-fix-imports-in-tests.patch"))))
+    (build-system pyproject-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         ;; Tests write to the source tree.
-         (add-after 'unpack 'make-git-checkout-writable
-           (lambda _
-             (for-each make-file-writable (find-files "."))
-             #t))
-         (replace 'check
-           (lambda _
-             (invoke "make" "test"))))))
+     (list #:phases
+           #~(modify-phases %standard-phases
+               ;; Tests write to the source tree.
+               (add-after 'unpack 'make-git-checkout-writable
+                 (lambda _
+                   (for-each make-file-writable (find-files "."))))
+               (add-after 'make-git-checkout-writable 'patch
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* "pdfminer/__init__.py"
+                     ;; Replace version placeholder with actual version.
+                     (("__VERSION__") #$(package-version this-package))))))))
     (propagated-inputs
-     (list python-chardet python-cryptography python-sortedcontainers))
+     (list python-charset-normalizer python-cryptography))
     (native-inputs
-     (list python-nose python-tox))
+     (list python-pytest))
     (home-page "https://github.com/pdfminer/pdfminer.six")
     (synopsis "PDF parser and analyzer")
     (description "@code{pdfminer.six} is a community maintained fork of