Commit 6ebf5ec4 authored by Sören Tempel's avatar Sören Tempel Committed by Sören Tempel
Browse files

testing/pdfarranger: backport patch for pikepdf6

parent 7a914070
Pipeline #137659 canceled with stage
in 37 seconds
......@@ -12,7 +12,8 @@ depends="desktop-file-utils ghostscript gsettings-desktop-schemas
makedepends="py3-setuptools py3-distutils-extra intltool"
options="!check" # tests require dogtail package
subpackages="$pkgname-lang $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/pdfarranger/pdfarranger/archive/$pkgver.tar.gz"
source="$pkgname-$pkgver.tar.gz::https://github.com/pdfarranger/pdfarranger/archive/$pkgver.tar.gz
support-pikepdf6.patch"
build() {
python3 setup.py build
......@@ -23,5 +24,6 @@ package() {
}
sha512sums="
e0b1ed59158681766e6b707a207363a8ccd38bdc76311600d338ef443e0ee79405af6afb65b878a68d7e52d2ea35f6a7aa700d9aaf46b31bcf64fd863c8784f2 pdfarranger-1.8.2.tar.gz
7d18f2c19b725532a29d80a19573db29c21049a0c6abac12b58855880ba031414b877bdb3bf333f2205eda1dbc08d62b258d783c7721564d18d29a5b62f8dfc5 pdfarranger-1.9.0.tar.gz
f6214a81c9327eb1935e8ea8fa35fe4bd367161606f74234c2128181901aa5ea09292996085ecaa9d810383d47277218fafcb51f8927cad3881ba4fb461264c6 support-pikepdf6.patch
"
Fix for https://github.com/pdfarranger/pdfarranger/issues/716
Taken from https://github.com/pdfarranger/pdfarranger/commit/6a53d54c7f3e19ca066ea7382f843ad093c80f15https://github.com/pdfarranger/pdfarranger/issues/716
From 6a53d54c7f3e19ca066ea7382f843ad093c80f15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Robert?= <jeromerobert@gmx.com>
Date: Sat, 17 Sep 2022 19:42:02 +0200
Subject: [PATCH] Fix NotImplementedError with PikePDF 6
Fix #716
---
pdfarranger/exporter.py | 17 ++++++++++++-----
setup.py | 2 +-
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/pdfarranger/exporter.py b/pdfarranger/exporter.py
index ff97ac19..6e275b79 100644
--- a/pdfarranger/exporter.py
+++ b/pdfarranger/exporter.py
@@ -215,9 +215,12 @@ def _copy_n_transform(pdf_input, pdf_output, pages, quit_flag=None):
# if the page already exists in the output PDF, duplicate it
new_page = copied_pages.get((row.nfile, row.npage))
if new_page is None:
- # for backward compatibility with old pikepdf. With pikepdf > 3
- # new_page = current_page should be enough
- new_page = pdf_output.copy_foreign(current_page)
+ try:
+ # for backward compatibility with pikepdf <= 3
+ new_page = pdf_output.copy_foreign(current_page)
+ except NotImplementedError:
+ # This is pikepdf >= 6
+ new_page = current_page
# let pdf_output adopt new_page
pdf_output.pages.append(new_page)
new_page = pdf_output.pages[-1]
@@ -253,8 +256,12 @@ def export_doc(pdf_input, pages, mdata, exportmode, file_out, quit_flag):
return
outpdf = pikepdf.Pdf.new()
_set_meta(mdata, pdf_input, outpdf)
- # needed to add this, probably related to pikepdf < 2.7.0 workaround
- page = outpdf.copy_foreign(page)
+ try:
+ # needed to add this, probably related to pikepdf < 2.7.0 workaround
+ page = outpdf.copy_foreign(page)
+ except NotImplementedError:
+ # This is pikepdf >= 6
+ pass
# works without make_indirect as already applied to this page
outpdf.pages.append(page)
outname = file_out
diff --git a/setup.py b/setup.py
index 56e461ed..82c5c42f 100755
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@
entry_points={
'console_scripts': ['pdfarranger=pdfarranger.pdfarranger:main']
},
- install_requires=['pikepdf>=1.17.0,<6','python-dateutil>=2.4.0'],
+ install_requires=['pikepdf>=1.17.0','python-dateutil>=2.4.0'],
extras_require={
'image': ['img2pdf>=0.3.4'],
},
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment