diff options
Diffstat (limited to 'debian/patches')
9 files changed, 70 insertions, 199 deletions
diff --git a/debian/patches/Fix-issue-25-year-missing-leading-zero-on-some-platforms.patch b/debian/patches/Fix-issue-25-year-missing-leading-zero-on-some-platforms.patch deleted file mode 100644 index 8c51aad..0000000 --- a/debian/patches/Fix-issue-25-year-missing-leading-zero-on-some-platforms.patch +++ /dev/null @@ -1,51 +0,0 @@ -From: "James R. Barlow" <jim@purplerock.ca> -Date: Tue, 12 Feb 2019 20:42:11 -0800 -Subject: Fix issue #25 - year missing leading zero on some platforms - -Closes #25 - -(cherry picked from commit 4d22fe47912c518e8b3348aedccdac3f11ed81d7) ---- - src/pikepdf/models/metadata.py | 7 +++++-- - tests/test_metadata.py | 3 ++- - 2 files changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/pikepdf/models/metadata.py b/src/pikepdf/models/metadata.py -index 1a0eeb2..65934cd 100644 ---- a/src/pikepdf/models/metadata.py -+++ b/src/pikepdf/models/metadata.py -@@ -121,8 +121,11 @@ def encode_pdf_date(d: datetime) -> str: - the local time. - """ - -- pdfmark_date_fmt = r'%Y%m%d%H%M%S' -- s = d.strftime(pdfmark_date_fmt) -+ # The formatting of %Y is not consistent as described in -+ # https://bugs.python.org/issue13305 and underspecification in libc. -+ # So explicitly format the year with leading zeros -+ s = "{:04d}".format(d.year) -+ s += d.strftime(r'%m%d%H%M%S') - tz = d.strftime('%z') - if tz: - sign, tz_hours, tz_mins = tz[0], tz[1:3], tz[3:5] -diff --git a/tests/test_metadata.py b/tests/test_metadata.py -index 1d41878..41a879c 100644 ---- a/tests/test_metadata.py -+++ b/tests/test_metadata.py -@@ -3,7 +3,7 @@ from datetime import datetime, timezone, timedelta - import re - - import pytest --from hypothesis import given -+from hypothesis import given, example - from hypothesis.strategies import integers - import pikepdf - from pikepdf import Pdf, Dictionary, Name, PasswordError, Stream -@@ -252,6 +252,7 @@ def test_date_docinfo_from_xmp(): - integers(0, 99), - integers(0, 99), - ) -+@example(1, 1, 1, 0, 0, 0) - def test_random_dates(year, month, day, hour, mins, sec): - date_args = year, month, day, hour, mins, sec - xmp = '{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}'.format(*date_args) diff --git a/debian/patches/disable-test_docinfo_problems.patch b/debian/patches/disable-test_docinfo_problems.patch index a69ca9a..fdcd1fa 100644 --- a/debian/patches/disable-test_docinfo_problems.patch +++ b/debian/patches/disable-test_docinfo_problems.patch @@ -9,7 +9,7 @@ Needs a test resource whose DFSG status is in doubt. --- a/tests/test_metadata.py +++ b/tests/test_metadata.py -@@ -50,12 +50,6 @@ def trivial(resources): +@@ -58,12 +58,6 @@ def trivial(resources): @pytest.fixture @@ -22,12 +22,10 @@ Needs a test resource whose DFSG status is in doubt. def invalid_creationdate(resources): # Has nuls in docinfo, old PDF return Pdf.open(resources / 'invalid_creationdate.pdf') -@@ -320,34 +314,6 @@ def test_remove_attribute_metadata(sandw - - # Ensure the whole node was deleted +@@ -337,37 +331,6 @@ def test_remove_attribute_metadata(sandw assert not re.search(r'rdf:Description xmlns:[^\s]+ rdf:about=""/', str(xmp)) -- -- + + -def test_docinfo_problems(enron1, invalid_creationdate): - meta = enron1.open_metadata() - meta._load() # File has invalid XML sequence � @@ -45,15 +43,20 @@ Needs a test resource whose DFSG status is in doubt. - - -def test_wrong_xml(enron1): -- enron1.Root.Metadata = Stream(enron1, b""" +- enron1.Root.Metadata = Stream( +- enron1, +- b""" - <test><xml>This is valid xml but not valid XMP</xml></test> -- """.strip()) +- """.strip(), +- ) - meta = enron1.open_metadata() -- with pytest.raises(ValueError, message='not XMP'): +- with pytest.raises(ValueError, match='not XMP'): - with meta: - pass -- with pytest.raises(ValueError, message='not XMP'): +- with pytest.raises(ValueError, match='not XMP'): - meta['pdfaid:part'] - - +- +- def test_no_x_xmpmeta(trivial): + trivial.Root.Metadata = Stream( + trivial, diff --git a/debian/patches/disable-test_icc_extract.patch b/debian/patches/disable-test_icc_extract.patch new file mode 100644 index 0000000..3f6973f --- /dev/null +++ b/debian/patches/disable-test_icc_extract.patch @@ -0,0 +1,27 @@ +From: Sean Whitton <spwhitton@spwhitton.name> +Date: Thu, 15 Aug 2019 18:42:49 +0100 +Subject: disable test_icc_extract + +Requires a test resource in Files-Excluded. +--- + tests/test_image_access.py | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/tests/test_image_access.py b/tests/test_image_access.py +index d4625d5..113a5ef 100644 +--- a/tests/test_image_access.py ++++ b/tests/test_image_access.py +@@ -317,13 +317,6 @@ def test_icc_use(resources): + assert pim.icc.profile.xcolor_space == 'GRAY' + + +-def test_icc_extract(resources): +- xobj, _pdf = first_image_in(resources / 'tree-icc.pdf') +- +- pim = PdfImage(xobj) +- assert pim.as_pil_image().info['icc_profile'] == pim.icc.tobytes() +- +- + def test_stacked_compression(resources): + xobj, _pdf = first_image_in(resources / 'pike-flate-jp2.pdf') + diff --git a/debian/patches/docs-build-use-DEB_VERSION_UPSTREAM.patch b/debian/patches/docs-build-use-DEB_VERSION_UPSTREAM.patch index e440dca..f880317 100644 --- a/debian/patches/docs-build-use-DEB_VERSION_UPSTREAM.patch +++ b/debian/patches/docs-build-use-DEB_VERSION_UPSTREAM.patch @@ -8,8 +8,8 @@ Subject: docs build use DEB_VERSION_UPSTREAM --- a/docs/conf.py +++ b/docs/conf.py -@@ -52,8 +52,6 @@ else: - # documentation root, use os.path.abspath to make it absolute, like shown here. +@@ -76,8 +76,6 @@ else: + sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext')) sys.path.insert(0, os.path.join(os.path.abspath('.'), '..')) -import pikepdf @@ -17,7 +17,7 @@ Subject: docs build use DEB_VERSION_UPSTREAM # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -@@ -101,7 +99,7 @@ author = u'James R. Barlow' +@@ -123,7 +121,7 @@ author = u'James R. Barlow' # |version| and |release|, also used in various other places throughout the # built documents. diff --git a/debian/patches/drop-installation-from-docs-contents.patch b/debian/patches/drop-installation-from-docs-contents.patch index 65ca879..bfd6dae 100644 --- a/debian/patches/drop-installation-from-docs-contents.patch +++ b/debian/patches/drop-installation-from-docs-contents.patch @@ -13,6 +13,6 @@ Subject: drop installation from docs contents :name: intro_toc - installation - changelog + release_notes tutorial objects diff --git a/debian/patches/drop-pybind11-from-setup.py.patch b/debian/patches/drop-pybind11-from-setup.py.patch new file mode 100644 index 0000000..90dc374 --- /dev/null +++ b/debian/patches/drop-pybind11-from-setup.py.patch @@ -0,0 +1,22 @@ +From: Sean Whitton <spwhitton@spwhitton.name> +Date: Thu, 15 Aug 2019 18:12:41 +0100 +Subject: drop pybind11 from setup.py + +We are successfully providing pybind11 as a build-dep but ocrmypdf's +setup.py fails to detect it for some reason. +--- + setup.py | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/setup.py b/setup.py +index 59e9b3b..c1f62b2 100644 +--- a/setup.py ++++ b/setup.py +@@ -138,7 +138,6 @@ setup( + setup_requires=[ + 'setuptools_scm', + 'setuptools_scm_git_archive', +- 'pybind11 >= 2.3.0, < 3', + ], + use_scm_version=True, + tests_require=tests_require, diff --git a/debian/patches/drop-setuptools_scm_git_archive-from-setup.py.patch b/debian/patches/drop-setuptools_scm_git_archive-from-setup.py.patch deleted file mode 100644 index 9349e43..0000000 --- a/debian/patches/drop-setuptools_scm_git_archive-from-setup.py.patch +++ /dev/null @@ -1,19 +0,0 @@ -From: Sean Whitton <spwhitton@spwhitton.name> -Date: Wed, 10 Oct 2018 08:17:05 -0700 -Subject: drop setuptools_scm_git_archive from setup.py - -Pending resolution of #910742. ---- - setup.py | 1 - - 1 file changed, 1 deletion(-) - ---- a/setup.py -+++ b/setup.py -@@ -134,7 +134,6 @@ setup( - setup_requires=[ - 'pytest-runner', - 'setuptools_scm', -- 'setuptools_scm_git_archive', - 'pybind11 >= 2.2.4, < 3' - ], - use_scm_version=True, diff --git a/debian/patches/fix_xmp_metadata_without_xmpmeta_wrapper.patch b/debian/patches/fix_xmp_metadata_without_xmpmeta_wrapper.patch deleted file mode 100644 index 0254bee..0000000 --- a/debian/patches/fix_xmp_metadata_without_xmpmeta_wrapper.patch +++ /dev/null @@ -1,110 +0,0 @@ -From d31ea8fed2004345b3c274172ff0c28b7c6aca16 Mon Sep 17 00:00:00 2001 -From: "James R. Barlow" <jim@purplerock.ca> -Date: Wed, 6 Feb 2019 00:36:59 -0800 -Subject: [PATCH] Fix handling of XMP metadata with no <x:xmpmeta> wrapper - ---- - src/pikepdf/models/metadata.py | 12 ++++++++-- - tests/test_metadata.py | 41 ++++++++++++++++++++++++++++++++-- - 2 files changed, 49 insertions(+), 4 deletions(-) - -diff --git a/src/pikepdf/models/metadata.py b/src/pikepdf/models/metadata.py -index 58c5a9d..23d246b 100644 ---- a/src/pikepdf/models/metadata.py -+++ b/src/pikepdf/models/metadata.py -@@ -428,6 +428,14 @@ def _get_subelements(self, node): - return result - return '' - -+ def _get_rdf_root(self): -+ rdf = self._xmp.find('.//rdf:RDF', self.NS) -+ if rdf is None: -+ rdf = self._xmp.getroot() -+ if not rdf.tag == '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF': -+ raise ValueError("Metadata seems to be XML but not XMP") -+ return rdf -+ - def _get_elements(self, name=''): - """Get elements from XMP - -@@ -452,7 +460,7 @@ def _get_elements(self, name=''): - - """ - qname = self._qname(name) -- rdf = self._xmp.find('.//rdf:RDF', self.NS) -+ rdf = self._get_rdf_root() - for rdfdesc in rdf.findall('rdf:Description[@rdf:about=""]', self.NS): - if qname and qname in rdfdesc.keys(): - yield (rdfdesc, qname, rdfdesc.get(qname), rdf) -@@ -540,7 +548,7 @@ def add_array(node, items): - raise TypeError(val) - except StopIteration: - # Insert a new node -- rdf = self._xmp.find('.//rdf:RDF', self.NS) -+ rdf = self._get_rdf_root() - if str(self._qname(key)) in LANG_ALTS: - val = AltList([clean(val)]) - if isinstance(val, (list, set)): -diff --git a/tests/test_metadata.py b/tests/test_metadata.py -index abe05ff..be654c8 100644 ---- a/tests/test_metadata.py -+++ b/tests/test_metadata.py -@@ -6,7 +6,7 @@ - from hypothesis import given - from hypothesis.strategies import integers - import pikepdf --from pikepdf import Pdf, Dictionary, Name, PasswordError -+from pikepdf import Pdf, Dictionary, Name, PasswordError, Stream - from pikepdf.models.metadata import ( - decode_pdf_date, encode_pdf_date, - XMP_NS_DC, XMP_NS_PDF, XMP_NS_XMP, -@@ -285,7 +285,7 @@ def test_bad_char_rejection(trivial): - ET.fromstring(str(xmp)) - - --def test_xpacket(sandwich): -+def test_xpacket_generation(sandwich): - xmpstr1 = sandwich.Root.Metadata.read_bytes() - xpacket_begin = b'<?xpacket begin=' - xpacket_end = b'<?xpacket end=' -@@ -336,3 +336,40 @@ def test_docinfo_problems(enron1, invalid_creationdate): - with meta as xmp: - xmp['xmp:CreateDate'] = 'invalid date' - assert 'could not be updated' in warned[0].message.args[0] -+ -+ -+def test_wrong_xml(enron1): -+ enron1.Root.Metadata = Stream(enron1, b""" -+ <test><xml>This is valid xml but not valid XMP</xml></test> -+ """.strip()) -+ meta = enron1.open_metadata() -+ with pytest.raises(ValueError, message='not XMP'): -+ with meta: -+ pass -+ with pytest.raises(ValueError, message='not XMP'): -+ meta['pdfaid:part'] -+ -+ -+def test_no_x_xmpmeta(trivial): -+ trivial.Root.Metadata = Stream(trivial, b""" -+ <?xpacket begin="\xef\xbb\xbf" id="W5M0MpCehiHzreSzNTczkc9d"?> -+ <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -+ xmlns:xmp="http://ns.adobe.com/xap/1.0/"> -+ <rdf:Description rdf:about="" -+ xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/" -+ xmlns:xmp="http://ns.adobe.com/xap/1.0/"> -+ <pdfaid:part>1</pdfaid:part> -+ <pdfaid:conformance>A</pdfaid:conformance> -+ <xmp:CreatorTool>Simple Scan 3.30.2</xmp:CreatorTool> -+ <xmp:CreateDate>2019-02-05T07:08:46+01:00</xmp:CreateDate> -+ <xmp:ModifyDate>2019-02-05T07:08:46+01:00</xmp:ModifyDate> -+ <xmp:MetadataDate>2019-02-05T07:08:46+01:00</xmp:MetadataDate> -+ </rdf:Description> -+ </rdf:RDF> -+ <?xpacket end="w"?> -+ """.strip()) -+ -+ with trivial.open_metadata() as xmp: -+ assert xmp._get_rdf_root() is not None -+ xmp['pdfaid:part'] = '2' -+ assert xmp['pdfaid:part'] == '2' diff --git a/debian/patches/series b/debian/patches/series index 152c5b8..57f09d3 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,6 +1,5 @@ docs-build-use-DEB_VERSION_UPSTREAM.patch drop-installation-from-docs-contents.patch -drop-setuptools_scm_git_archive-from-setup.py.patch -fix_xmp_metadata_without_xmpmeta_wrapper.patch disable-test_docinfo_problems.patch -Fix-issue-25-year-missing-leading-zero-on-some-platforms.patch +drop-pybind11-from-setup.py.patch +disable-test_icc_extract.patch |