Hello community, here is the log from the commit of package python-pikepdf for openSUSE:Factory checked in at 2020-04-21 13:06:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pikepdf (Old) and /work/SRC/openSUSE:Factory/.python-pikepdf.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pikepdf" Tue Apr 21 13:06:39 2020 rev:4 rq:795619 version:1.11.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pikepdf/python-pikepdf.changes 2020-03-24 22:38:30.037268982 +0100 +++ /work/SRC/openSUSE:Factory/.python-pikepdf.new.2738/python-pikepdf.changes 2020-04-21 13:06:46.540346589 +0200 @@ -1,0 +2,26 @@ +Sun Apr 19 20:10:58 UTC 2020 - Martin Hauke <[email protected]> + +- Update to version 1.11.1 + * We now avoid creating an empty XMP metadata entry when files + are saved. + * Updated documentation to describe how to delete the document + information dictionary. +- Update to version 1.11.0 + * Prevent creation of dictionaries with invalid names (not + beginning with /). + * Allow pikepdf's build to specify a qpdf source tree, allowing + one to compile pikepdf against an unreleased/modified version + of qpdf. + * Improved behavior of pages.p() and pages.remove() when + invalid parameters were given. + * Fixed compatibility with libqpdf version 10.0.1, and build + official wheels against this version. + * Fixed compatibility with pytest 5.x. + * Fixed the documentation build. + * Fixed an issue with running tests in a non-Unicode locale. + * Fixed a test that randomly failed due to a "deadline error". + * Removed a possibly nonfree test file. +- Update to version 1.10.4 + * Rebuild Python wheels with newer version of libqpdf. Fixes + problems with opening certain password-protected files (#87) +------------------------------------------------------------------- Old: ---- pikepdf-1.10.3.tar.gz New: ---- pikepdf-1.11.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pikepdf.spec ++++++ --- /var/tmp/diff_new_pack.2wRG1B/_old 2020-04-21 13:06:49.320352134 +0200 +++ /var/tmp/diff_new_pack.2wRG1B/_new 2020-04-21 13:06:49.320352134 +0200 @@ -20,7 +20,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pikepdf -Version: 1.10.3 +Version: 1.11.1 Release: 0 Summary: Read and write PDFs with Python, powered by qpdf License: MPL-2.0 ++++++ pikepdf-1.10.3.tar.gz -> pikepdf-1.11.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/.gitignore new/pikepdf-1.11.1/.gitignore --- old/pikepdf-1.10.3/.gitignore 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/.gitignore 2020-04-16 11:26:23.000000000 +0200 @@ -19,7 +19,7 @@ var/ .pytest_cache/ .mypy_cache/ -.coverage +.coverage* coverage/ pip-wheel-metadata/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/PKG-INFO new/pikepdf-1.11.1/PKG-INFO --- old/pikepdf-1.10.3/PKG-INFO 2020-03-17 07:56:20.230840000 +0100 +++ new/pikepdf-1.11.1/PKG-INFO 2020-04-16 11:28:15.295339300 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pikepdf -Version: 1.10.3 +Version: 1.11.1 Summary: Read and write PDFs with Python, powered by qpdf Home-page: https://github.com/pikepdf/pikepdf Author: James R. Barlow diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/azure-pipelines.yml new/pikepdf-1.11.1/azure-pipelines.yml --- old/pikepdf-1.10.3/azure-pipelines.yml 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/azure-pipelines.yml 2020-04-16 11:26:23.000000000 +0200 @@ -1,12 +1,12 @@ variables: - qpdf_version: "9.0.2" + qpdf_version: "10.0.1" qpdf_release: ${{ format('https://github.com/qpdf/qpdf/releases/download/release-qpdf-{0}/qpdf-{0}.tar.gz', variables.qpdf_version) }} jpeg_release: "https://www.ijg.org/files/jpegsrc.v9c.tar.gz" zlib_release: "https://www.zlib.net/zlib-1.2.11.tar.gz" - cibw_skip: "cp27-* cp34-*" + cibw_skip: "cp27-* cp34-* pp27-* pp36-*" cibw_test_command: "pytest -nauto {project}/tests" cibw_test_requires: "-r requirements/test.txt" - cibuildwheel_version: "1.0.0" + cibuildwheel_version: "1.3.0" cibw_before_build: "pip install pybind11" trigger: @@ -145,8 +145,8 @@ condition: succeededOrFailed() - publish: wheelhouse artifact: linux32 - - job: macos - pool: { vmImage: "macOS-10.13" } + - job: "macOS_Mojave" + pool: { vmImage: "macOS-10.14" } variables: cibw_before_build: >- pip install pybind11 && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/debian/copyright new/pikepdf-1.11.1/debian/copyright --- old/pikepdf-1.10.3/debian/copyright 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/debian/copyright 2020-04-16 11:26:23.000000000 +0200 @@ -43,6 +43,11 @@ License: CC-BY-SA 2.0 See: https://commons.wikimedia.org/wiki/File:Pike_square_img_3653.jpg +Files: docs/images/save-pike.jpg +Copyright: (C) 2007 Sarah777 +License: Public domain + See: https://upload.wikimedia.org/wikipedia/commons/3/33/SaveDePike.jpg + Files: docs/images/28fish.jpg Copyright: (C) 2009 Fae License: CC-BY-4.0 @@ -66,14 +71,6 @@ Copyright: (C) 2019 Jay Berkenbilt License: Apache 2.0 -Files: test/resources/enron1.pdf -Copyright: EnronData.org -License: CC-BY-3.0 - See: https://enrondata.readthedocs.io/en/latest/data/edo-enron-email-pst-dataset/ -Comment: - enron*_gs.pdf: processed by Ghostscript 9.26. - Original obtained from http://datasets.opentestset.com/datasets/Enron_files/full/williams-b/Alstom%20Power.pdf - Files: tests/resources/graph*.pdf Copyright: Public domain License: public-domain diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/conf.py new/pikepdf-1.11.1/docs/conf.py --- old/pikepdf-1.10.3/docs/conf.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/conf.py 2020-04-16 11:26:23.000000000 +0200 @@ -19,8 +19,6 @@ from pkg_resources import get_distribution -import pikepdf - on_rtd = os.environ.get('READTHEDOCS') == 'True' if on_rtd: # Borrowed from https://github.com/YannickJadoul/Parselmouth/blob/master/docs/conf.py @@ -79,6 +77,7 @@ sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext')) sys.path.insert(0, os.path.join(os.path.abspath('.'), '..')) +import pikepdf # isort:skip pylint: disable=unused-import # -- General configuration ------------------------------------------------ @@ -118,7 +117,7 @@ # General information about the project. project = u'pikepdf' -copyright = u'2020, James R. Barlow' +copyright = u'2020, James R. Barlow' # pylint: disable=redefined-builtin author = u'James R. Barlow' # The version info for the project you're documenting, acts as replacement for Binary files old/pikepdf-1.10.3/docs/images/save-pike.jpg and new/pikepdf-1.11.1/docs/images/save-pike.jpg differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/index.rst new/pikepdf-1.11.1/docs/index.rst --- old/pikepdf-1.10.3/docs/index.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/index.rst 2020-04-16 11:26:23.000000000 +0200 @@ -6,7 +6,7 @@ :alt: A northern pike :figwidth: 30% - A northern pike, or *esox lucius*. [#img1]_ + A northern pike, or *esox lucius*. **pikepdf** is a Python library allowing creation, manipulation and repair of PDFs. It provides a Pythonic wrapper around the C++ PDF content transformation @@ -33,8 +33,9 @@ my_pdf.save('test-rotated.pdf') It is a low level library that requires knowledge of PDF internals and some -familiarity with the PDF specification [#pdfrm]_. It does not provide a user -interface of its own. +familiarity with the `PDF specification +<https://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf>`_. +It does not provide a user interface of its own. pikepdf would help you build apps that do things like: @@ -144,14 +145,3 @@ arch resources - - -.. rubric:: References - -.. [#img1] `Public domain image <https://en.wikipedia.org/wiki/File:Esox_lucius1.jpg>`_. - -.. [#img3] `CC0 iamge <https://pixabay.com/en/pike-fish-predator-shchuchin-2612354/>`_. - -.. [#img2] `CC-BY-SA 2.0 image <https://commons.wikimedia.org/wiki/File:Pike_square_img_3653.jpg>`_. - -.. [#pdfrm] `PDF 32000-1:2008 <https://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf>`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/installation.rst new/pikepdf-1.11.1/docs/installation.rst --- old/pikepdf-1.10.3/docs/installation.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/installation.rst 2020-04-16 11:26:23.000000000 +0200 @@ -27,15 +27,25 @@ Use ``pip install --user pikepdf`` to install the package for the current user only. Use ``pip install pikepdf`` to install to a virtual environment. -This command installs binary wheels. 32- and 64-bit wheels are available for -Windows, Linux and macOS. Binary wheels should work on most systems work on -Linux distributions 2010 and newer, macOS 10.11 and newer (for Homebrew), -Windows 7 and newer. A notable exception is Alpine Linux, which does not support -manylinux2010 wheels – fortunately, a native package is available for Alpine. - -The Linux wheels currently include copies of libqpdf, libjpeg, and zlib -The Windows wheels include libqpdf. This is to ensure that up-to-date, compatible -copies of dependent libraries are included. +This command installs manylinux2010 binary wheels. If you have an older version +of ``pip``, such as the one that ships with Ubuntu 18.04, this command will +attempt to compile the project. If you want to get the binary wheel, upgrade +``pip`` with: + +.. code-block:: bash + + wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py + pip --version # should be 20.0 or newer + pip install pikepdf + +32- and 64-bit wheels are available for Windows, Linux and macOS. Binary wheels +should work on most systems work on Linux distributions 2010 and newer, macOS +10.11 and newer (for Homebrew), Windows 7 and newer, **provided a recent version +of pip is used to install them**. The Linux wheels currently include copies of +libqpdf, libjpeg, and zlib The Windows wheels include libqpdf. This is to ensure +that up-to-date, compatible copies of dependent libraries are included. + +`Alpine Linux`_ does not support Python wheels. Platform support ---------------- @@ -45,13 +55,10 @@ distributed with PyPI, but may be convenient for users that cannot use binary wheels. -.. |pikepdf| image:: https://repology.org/badge/vertical-allrepos/pikepdf.svg - :alt: Package status - .. |python-pikepdf| image:: https://repology.org/badge/vertical-allrepos/python:pikepdf.svg :alt: Package status for python:pikepdf -|pikepdf| |python-pikepdf| +|python-pikepdf| Debian, Ubuntu and other APT-based distributions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,18 +79,17 @@ dnf install python-pikepdf -ArchLinux -^^^^^^^^^ - -.. |aur| image:: https://repology.org/badge/version-for-repo/aur/python:pikepdf.svg +Alpine Linux +^^^^^^^^^^^^ -|aur| +.. |alpine| image:: https://repology.org/badge/version-for-repo/alpine_edge/python:pikepdf.svg + :alt: Alpine Linux Edge -Available in `ArchLinux User Repository <https://aur.archlinux.org/packages/python-pikepdf/>`_. +|alpine| .. code-block:: bash - pacman -S pikepdf + apk add py3-pikepdf Installing on FreeBSD --------------------- @@ -185,11 +191,9 @@ ---------------------------- On Windows, the Visual C++ 2015 redistributable packages are a runtime -requirement for this project. Specifically you must install microsoft -Visual C++ 2015-2019 Redistributable (x64) 14.24.28127 (for 64-bit). - -The package may be found here: -`here <https://www.microsoft.com/en-us/download/details.aspx?id=48145>`__. +requirement for this project. Specifically you must install +`Microsoft Visual C++ 2015-2019 Redistributable (x64) 14.24.28127 +<https://www.microsoft.com/en-us/download/details.aspx?id=48145>`_ (for 64-bit). If not installed, you may see an error saying that "pikepdf's extension library failed to import". diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/release_notes.rst new/pikepdf-1.11.1/docs/release_notes.rst --- old/pikepdf-1.10.3/docs/release_notes.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/release_notes.rst 2020-04-16 11:26:23.000000000 +0200 @@ -18,6 +18,35 @@ ``pikepdf._qpdf`` is a private interface within pikepdf that applications should not access directly, along with any modules with a prefixed underscore. +v1.11.1 +======= + +- We now avoid creating an empty XMP metadata entry when files are saved. +- Updated documentation to describe how to delete the document information + dictionary. + +v1.11.0 +======= + +- Prevent creation of dictionaries with invalid names (not beginning with ``/``). +- Allow pikepdf's build to specify a qpdf source tree, allowing one to compile + pikepdf against an unreleased/modified version of qpdf. +- Improved behavior of ``pages.p()`` and ``pages.remove()`` when invalid parameters + were given. +- Fixed compatibility with libqpdf version 10.0.1, and build official wheels + against this version. +- Fixed compatibility with pytest 5.x. +- Fixed the documentation build. +- Fixed an issue with running tests in a non-Unicode locale. +- Fixed a test that randomly failed due to a "deadline error". +- Removed a possibly nonfree test file. + +v1.10.4 +======= + +- Rebuild Python wheels with newer version of libqpdf. Fixes problems with + opening certain password-protected files (#87). + v1.10.3 ======= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/resources.rst new/pikepdf-1.11.1/docs/resources.rst --- old/pikepdf-1.10.3/docs/resources.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/resources.rst 2020-04-16 11:26:23.000000000 +0200 @@ -16,3 +16,6 @@ .. _Adobe extensions: https://www.adobe.com/devnet/pdf/pdf_reference.html .. _Adobe Supplement to ISO 32000 BaseVersion 1.7 ExtensionLevel 3: https://www.adobe.com/content/dam/acom/en/devnet/pdf/adobe_supplement_iso32000.pdf + +For information about copyrights and licenses, including those associated with the +images in this documentation, see the file ``debian/copyright``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/topics/encoding.rst new/pikepdf-1.11.1/docs/topics/encoding.rst --- old/pikepdf-1.10.3/docs/topics/encoding.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/topics/encoding.rst 2020-04-16 11:26:23.000000000 +0200 @@ -3,10 +3,10 @@ .. epigraph:: - There are three hard problems in computer science: - 1) Converting from PDF, - 2) Converting to PDF, and - 3) O̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳Ҙ҉҉҉ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃O̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳Ҙ҉҉҉ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃ + | There are three hard problems in computer science: + | 1) Converting from PDF, + | 2) Converting to PDF, and + | 3) O̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳Ҙ҉҉҉ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃O̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳̳Ҙ҉҉҉ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃ʹʹ҉ʹ̨̨̨̨̨̨̨̨̃༃༃ -- `Marseille Folog <https://twitter.com/fogus/status/1024657831084085248>`_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/topics/metadata.rst new/pikepdf-1.11.1/docs/topics/metadata.rst --- old/pikepdf-1.10.3/docs/topics/metadata.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/topics/metadata.rst 2020-04-16 11:26:23.000000000 +0200 @@ -13,13 +13,25 @@ see Adobe's `XMP Developer Center <https://www.adobe.com/devnet/xmp.html>`_. The `XMP Specification`_ also provides useful information. -pikepdf can read compound metadata quantities may be read, but only scalar -quantities can be modified. For more complex changes consider using the -``python-xmp-toolkit`` library and its libexempi dependency; but note that it is -not capable of synchronizing changes to the older DocumentInfo metadata. +pikepdf can read compound metadata quantities, but can only modify scalars. For +more complex changes consider using the ``python-xmp-toolkit`` library and its +libexempi dependency; but note that it is not capable of synchronizing changes +to the older DocumentInfo metadata. .. _XMP Specification: https://wwwimages2.adobe.com/content/dam/acom/en/devnet/xmp/pdfs/XMP%20SDK%20Release%20cc-2016-08/XMPSpecificationPart1.pdf +Automatic metadata updates +-------------------------- + +By default pikepdf will create a XMP metadata block and set ``pdf:PDFVersion`` +to a value that matches the PDF version declared elsewhere in the PDF, whenever +a PDF is saved. To suppress this behavior, save with +``pdf.save(..., fix_metadata_version=False)``. + +Also by default, :meth:`Pdf.open_metadata()` will synchronize the XMP metadata +with the older document information dictionary. This behavior can also be +adjusted using keyword arguments. + .. _accessmetadata: Accessing metadata @@ -57,6 +69,12 @@ The list of available metadata fields may be found in the `XMP Specification`_. +Removing metadata items +----------------------- + +Use ``del meta['dc:title']`` to delete a metadata entry. To remove all of the XMP +metadata, use ``del pdf.Root.Metadata``. + Checking PDF/A conformance -------------------------- @@ -77,6 +95,18 @@ Note that this property merely *tests* if the file claims to be conformant to the PDF/A standard. Use a tool such as veraPDF to verify conformance. +Notice for application developers +--------------------------------- + +If you are using pikepdf to create some kind of PDF application, you should +update the fields ``xmp:CreatorTool`` and ``pdf:Producer``. You could, for +example, set ``xmp:CreatorTool`` to your application's name and version, and +``pdf:Producer`` to pikepdf. Refer to Adobe's documentation to decide what +describes the circumstances. + +This will help PDF developers identify the application that generated a +particular PDF and is valuable debugging information. + Low-level XMP metadata access ----------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/docs/tutorial.rst new/pikepdf-1.11.1/docs/tutorial.rst --- old/pikepdf-1.10.3/docs/tutorial.rst 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/docs/tutorial.rst 2020-04-16 11:26:23.000000000 +0200 @@ -180,6 +180,13 @@ Saving changes -------------- +.. figure:: /images/save-pike.jpg + :align: right + :alt: Sign that reads "Help the pike survive" + :figwidth: 40% + + Saving pike. + Naturally, you can save your changes with :meth:`pikepdf.Pdf.save`. ``filename`` can be a :class:`pathlib.Path`, which we accept everywhere. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/requirements/test.txt new/pikepdf-1.11.1/requirements/test.txt --- old/pikepdf-1.10.3/requirements/test.txt 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/requirements/test.txt 2020-04-16 11:26:23.000000000 +0200 @@ -1,8 +1,8 @@ attrs >= 19.1.0 -hypothesis >= 4.24, < 5 +hypothesis >= 4.24, < 6 Pillow >= 5.0.0 -pytest >= 4.4.0, < 5 -pytest-xdist >= 1.28, < 2 +pytest >= 4.4.0, < 6 +pytest-xdist >= 1.28, < 2 pytest-helpers-namespace >= 2019.1.8 pytest-timeout >= 1.3.3 python-xmp-toolkit >= 2.0.1 ; sys_platform != "nt" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/setup.py new/pikepdf-1.11.1/setup.py --- old/pikepdf-1.10.3/setup.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/setup.py 2020-04-16 11:26:23.000000000 +0200 @@ -1,10 +1,11 @@ -from setuptools import setup, Extension -from setuptools.command.build_ext import build_ext import sys -import setuptools -from os.path import join, dirname, exists from glob import glob +from os import environ +from os.path import dirname, exists, join +import setuptools +from setuptools import Extension, setup +from setuptools.command.build_ext import build_ext if sys.version_info >= (3, 6): try: @@ -35,8 +36,14 @@ extra_includes = [] +extra_library_dirs = [] +qpdf_source_tree = environ.get('QPDF_SOURCE_TREE', None) +if qpdf_source_tree: + # Point this to qpdf source tree built with shared libaries + extra_includes.append(join(qpdf_source_tree, 'include')) + extra_library_dirs.append(join(qpdf_source_tree, 'libqpdf/build/.libs')) if 'bsd' in sys.platform: - extra_includes = ['/usr/local/include'] + extra_includes.append('/usr/local/include') ext_modules = [ @@ -50,6 +57,7 @@ get_pybind_include(user=True), *extra_includes, ], + library_dirs=[*extra_library_dirs], libraries=['qpdf'], language='c++', ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/pikepdf/_cpphelpers.py new/pikepdf-1.11.1/src/pikepdf/_cpphelpers.py --- old/pikepdf-1.10.3/src/pikepdf/_cpphelpers.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/pikepdf/_cpphelpers.py 2020-04-16 11:26:23.000000000 +0200 @@ -12,6 +12,8 @@ import os import sys +from pikepdf import Name + # Provide os.fspath equivalent for Python <3.6 if sys.version_info[0:2] <= (3, 5): # pragma: no cover @@ -54,6 +56,9 @@ def update_xmp_pdfversion(pdf, version): + if Name.Metadata not in pdf.Root: + return # Don't create an empty XMP object just to store the version + with pdf.open_metadata(set_pikepdf_as_editor=False, update_docinfo=False) as meta: if 'pdf:PDFVersion' in meta: meta['pdf:PDFVersion'] = version diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/pikepdf/_methods.py new/pikepdf-1.11.1/src/pikepdf/_methods.py --- old/pikepdf-1.10.3/src/pikepdf/_methods.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/pikepdf/_methods.py 2020-04-16 11:26:23.000000000 +0200 @@ -270,8 +270,12 @@ version of pikepdf is the most recent software to modify the metadata. Recommended, except for testing. - update_docinfo (bool): Update the deprecated PDF DocumentInfo block - to be consistent with XMP. + update_docinfo (bool): Update the standard fields of DocumentInfo + (the old PDF metadata dictionary) to match the corresponding + XMP fields. The mapping is described in + :attr:`PdfMetadata.DOCINFO_MAPPING`. Nonstandard DocumentInfo + fields and XMP metadata fields with no DocumentInfo equivalent + are ignored. strict (bool): If ``False`` (the default), we aggressively attempt to recover from any parse errors in XMP, and if that fails we diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/pikepdf/objects.py new/pikepdf-1.11.1/src/pikepdf/objects.py --- old/pikepdf-1.10.3/src/pikepdf/objects.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/pikepdf/objects.py 2020-04-16 11:26:23.000000000 +0200 @@ -173,6 +173,8 @@ return _qpdf._new_dictionary({('/' + k): v for k, v in kwargs.items()}) if not d: d = {} + if d and any(not key.startswith('/') for key in d.keys()): + raise ValueError("Dictionary created from strings must begin with '/'") return _qpdf._new_dictionary(d) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/pikepdf.egg-info/PKG-INFO new/pikepdf-1.11.1/src/pikepdf.egg-info/PKG-INFO --- old/pikepdf-1.10.3/src/pikepdf.egg-info/PKG-INFO 2020-03-17 07:56:14.000000000 +0100 +++ new/pikepdf-1.11.1/src/pikepdf.egg-info/PKG-INFO 2020-04-16 11:28:14.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pikepdf -Version: 1.10.3 +Version: 1.11.1 Summary: Read and write PDFs with Python, powered by qpdf Home-page: https://github.com/pikepdf/pikepdf Author: James R. Barlow diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/pikepdf.egg-info/SOURCES.txt new/pikepdf-1.11.1/src/pikepdf.egg-info/SOURCES.txt --- old/pikepdf-1.10.3/src/pikepdf.egg-info/SOURCES.txt 2020-03-17 07:56:20.000000000 +0100 +++ new/pikepdf-1.11.1/src/pikepdf.egg-info/SOURCES.txt 2020-04-16 11:28:15.000000000 +0200 @@ -37,6 +37,7 @@ docs/images/pike-tree.jpg docs/images/pike.jpg docs/images/pikemen.jpg +docs/images/save-pike.jpg docs/topics/content_streams.rst docs/topics/encoding.rst docs/topics/images.rst @@ -106,7 +107,6 @@ tests/resources/congress-gray.pdf tests/resources/congress.pdf tests/resources/content-stream-errors.pdf -tests/resources/enron1_gs.pdf tests/resources/formxobject.pdf tests/resources/fourpages.pdf tests/resources/graph-encrypted.pdf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/qpdf/object.cpp new/pikepdf-1.11.1/src/qpdf/object.cpp --- old/pikepdf-1.10.3/src/qpdf/object.cpp 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/qpdf/object.cpp 2020-04-16 11:26:23.000000000 +0200 @@ -375,6 +375,10 @@ throw py::attr_error(e.what()); else throw py::attr_error(name); + } catch (const py::value_error &e) { + if (name == std::string("__name__")) + throw py::attr_error(name); + throw; } return value; }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/qpdf/qpdf.cpp new/pikepdf-1.11.1/src/qpdf/qpdf.cpp --- old/pikepdf-1.10.3/src/qpdf/qpdf.cpp 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/qpdf/qpdf.cpp 2020-04-16 11:26:23.000000000 +0200 @@ -575,6 +575,12 @@ ``.open_metadata()`` API instead, which will edit the modern (and unfortunately, more complicated) XMP metadata object and synchronize changes to the document information dictionary. + + This property simplifies access to the actual document information + dictionary and ensures that it is created correctly if it needs + to be created. A new dictionary will be created if this property + is accessed and dictionary does not exist. To delete the dictionary + use ``del pdf.trailer.Info``. )~~~" ) .def_property_readonly("trailer", &QPDF::getTrailer, @@ -709,12 +715,13 @@ potentially creating an invalid file that does not display in old versions. See QPDF manual for details. If a tuple, the second element is an integer, the extension level. - fix_metadata_version (bool): If True (default) and the XMP metadata + fix_metadata_version (bool): If ``True`` (default) and the XMP metadata contains the optional PDF version field, ensure the version in metadata is correct. If the XMP metadata does not contain a PDF version field, none will be added. To ensure that the field is added, edit the metadata and insert a placeholder value in - ``pdf:PDFVersion``. + ``pdf:PDFVersion``. If XMP metadata does not exist, it will + not be created regardless of the value of this argument. object_stream_mode (pikepdf.ObjectStreamMode): ``disable`` prevents the use of object streams. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/src/qpdf/qpdf_pagelist.cpp new/pikepdf-1.11.1/src/qpdf/qpdf_pagelist.cpp --- old/pikepdf-1.10.3/src/qpdf/qpdf_pagelist.cpp 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/src/qpdf/qpdf_pagelist.cpp 2020-04-16 11:26:23.000000000 +0200 @@ -193,8 +193,8 @@ .def("__delitem__", &PageList::delete_pages_from_iterable) .def("__len__", &PageList::count) .def("p", - [](PageList &pl, size_t pnum) { - if (pnum == 0) // Indexing past end is checked in .get_page + [](PageList &pl, ssize_t pnum) { + if (pnum <= 0) // Indexing past end is checked in .get_page throw py::index_error("page access out of range in 1-based indexing"); return pl.get_page(pnum - 1); }, @@ -275,8 +275,8 @@ ) .def("remove", [](PageList &pl, py::kwargs kwargs) { - auto pnum = kwargs["p"].cast<size_t>(); - if (pnum == 0) // Indexing past end is checked in .get_page + auto pnum = kwargs["p"].cast<ssize_t>(); + if (pnum <= 0) // Indexing past end is checked in .get_page throw py::index_error("page access out of range in 1-based indexing"); pl.delete_page(pnum - 1); }, Binary files old/pikepdf-1.10.3/tests/resources/enron1_gs.pdf and new/pikepdf-1.11.1/tests/resources/enron1_gs.pdf differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/tests/test_metadata.py new/pikepdf-1.11.1/tests/test_metadata.py --- old/pikepdf-1.10.3/tests/test_metadata.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/tests/test_metadata.py 2020-04-16 11:26:23.000000000 +0200 @@ -7,7 +7,7 @@ from pathlib import Path import pytest -from hypothesis import assume, example, given +from hypothesis import assume, example, given, settings from hypothesis import strategies as st from hypothesis.strategies import integers from lxml.etree import XMLSyntaxError @@ -63,12 +63,6 @@ @pytest.fixture -def enron1(resources): - # Has nuls in docinfo, old PDF - return Pdf.open(resources / 'enron1_gs.pdf') - - [email protected] def invalid_creationdate(resources): # Has nuls in docinfo, old PDF return Pdf.open(resources / 'invalid_creationdate.pdf') @@ -342,8 +336,25 @@ assert not re.search(r'rdf:Description xmlns:[^\s]+ rdf:about=""/', str(xmp)) -def test_docinfo_problems(enron1, invalid_creationdate): - meta = enron1.open_metadata() +def test_docinfo_problems(sandwich, invalid_creationdate): + sandwich.Root.Metadata = Stream( + sandwich, + b""" + <?xpacket begin='\xc3\xaf\xc2\xbb\xc2\xbf' id='W5M0MpCehiHzreSzNTczkc9d'?> + <?adobe-xap-filters esc="CRLF"?> + <x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'> + <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'> + <rdf:Description rdf:about='uuid:873a76ba-4819-11f4-0000-5c5716666531' xmlns:pdf='http://ns.adobe.com/pdf/1.3/' pdf:Producer='GPL Ghostscript 9.26'/> + <rdf:Description rdf:about='uuid:873a76ba-4819-11f4-0000-5c5716666531' xmlns:xmp='http://ns.adobe.com/xap/1.0/'><xmp:ModifyDate>2019-01-04T00:44:42-08:00</xmp:ModifyDate> + <xmp:CreateDate>2019-01-04T00:44:42-08:00</xmp:CreateDate> + <xmp:CreatorTool>Acrobat 4.0 Scan Plug-in for Windows�</xmp:CreatorTool></rdf:Description> + <rdf:Description rdf:about='uuid:873a76ba-4819-11f4-0000-5c5716666531' xmlns:xapMM='http://ns.adobe.com/xap/1.0/mm/' xapMM:DocumentID='uuid:873a76ba-4819-11f4-0000-5c5716666531'/> + <rdf:Description rdf:about='uuid:873a76ba-4819-11f4-0000-5c5716666531' xmlns:dc='http://purl.org/dc/elements/1.1/' dc:format='application/pdf'><dc:title><rdf:Alt><rdf:li xml:lang='x-default'>Untitled</rdf:li></rdf:Alt></dc:title></rdf:Description> + </rdf:RDF> + </x:xmpmeta> + """, + ) + meta = sandwich.open_metadata() meta._load() # File has invalid XML sequence � with meta: with pytest.warns(UserWarning) as warned: @@ -358,14 +369,14 @@ assert 'could not be updated' in warned[0].message.args[0] -def test_wrong_xml(enron1): - enron1.Root.Metadata = Stream( - enron1, +def test_wrong_xml(sandwich): + sandwich.Root.Metadata = Stream( + sandwich, b""" <test><xml>This is valid xml but not valid XMP</xml></test> """.strip(), ) - meta = enron1.open_metadata(strict=True) + meta = sandwich.open_metadata(strict=True) with pytest.raises(ValueError, match='not XMP'): with meta: pass @@ -428,6 +439,7 @@ xmp['pdfaid:part'] = '5' +@settings(deadline=None) @given(st.integers(min_value=1, max_value=1350)) @example(548) @example(1154) @@ -528,3 +540,29 @@ assert 'could not be copied to XMP' in str(e) or '/Dummy' in str(e) else: ET.fromstring(str(m)) # ensure we can parse it + + +def test_set_empty_string(graph): + with graph.open_metadata() as m: + m['dc:title'] = 'a' + + generated_xmp = graph.Root.Metadata.read_bytes() + print(generated_xmp) + assert generated_xmp.count(b'<dc:title>') == 1 + + [email protected]('fix_metadata', [True, False]) +def test_dont_create_empty_xmp(trivial, outpdf, fix_metadata): + trivial.save(outpdf, fix_metadata_version=fix_metadata) + + with pikepdf.open(outpdf) as p: + assert Name.Metadata not in p.Root + + [email protected]('fix_metadata', [True, False]) +def test_dont_create_empty_docinfo(trivial, outpdf, fix_metadata): + del trivial.trailer.Info + trivial.save(outpdf, fix_metadata_version=fix_metadata) + + with pikepdf.open(outpdf) as p: + assert Name.Info not in p.trailer diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/tests/test_object.py new/pikepdf-1.11.1/tests/test_object.py --- old/pikepdf-1.10.3/tests/test_object.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/tests/test_object.py 2020-04-16 11:26:23.000000000 +0200 @@ -368,6 +368,10 @@ with pytest.raises(TypeError): d.page_contents_add(b'', True) + def test_bad_name(self): + with pytest.raises(ValueError, match=r"must begin with '/'"): + d = pikepdf.Dictionary({'/Slash': 'dot', 'unslash': 'error'}) + def test_not_convertible(): class PurePythonObj: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/tests/test_pages.py new/pikepdf-1.11.1/tests/test_pages.py --- old/pikepdf-1.10.3/tests/test_pages.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/tests/test_pages.py 2020-04-16 11:26:23.000000000 +0200 @@ -5,7 +5,7 @@ import pytest -from pikepdf import Dictionary, Name, Pdf, PdfMatrix, Stream +from pikepdf import Array, Dictionary, Name, Pdf, PdfMatrix, Stream # pylint: disable=redefined-outer-name,pointless-statement @@ -204,6 +204,8 @@ pdf.pages.p(5) with pytest.raises(IndexError): pdf.pages.p(0) + with pytest.raises(IndexError): + pdf.pages.p(-1) def test_page_contents_add(graph, outdir): @@ -326,3 +328,24 @@ reopened = Pdf.open(outpdf) assert reopened.pages[0].Rotate == 180 assert reopened.pages[1].get(Name.Rotate, 0) == 0 + + +def test_remove_onebased(fourpages): + second_page = fourpages.pages.p(2) + assert second_page == fourpages.pages[1] + fourpages.pages.remove(p=2) + assert second_page not in fourpages.pages + assert len(fourpages.pages) == 3 + with pytest.raises(IndexError): + fourpages.pages.remove(p=0) + with pytest.raises(IndexError): + fourpages.pages.remove(p=4) + with pytest.raises(IndexError): + fourpages.pages.remove(p=-1) + + +def test_pages_wrong_type(fourpages): + with pytest.raises(TypeError): + fourpages.pages.insert(3, {}) + with pytest.raises(TypeError): + fourpages.pages.insert(3, Array([42])) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/tests/test_pdf.py new/pikepdf-1.11.1/tests/test_pdf.py --- old/pikepdf-1.10.3/tests/test_pdf.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/tests/test_pdf.py 2020-04-16 11:26:23.000000000 +0200 @@ -2,10 +2,11 @@ Testing focused on pikepdf.Pdf """ +import locale import os import shutil import sys -from io import StringIO, BytesIO +from io import BytesIO, StringIO from pathlib import Path from unittest.mock import Mock, patch @@ -15,7 +16,6 @@ from pikepdf import PasswordError, Pdf, PdfError, Stream from pikepdf._cpphelpers import fspath # For py35 - # pylint: disable=redefined-outer-name @@ -180,6 +180,7 @@ mock.assert_called() [email protected](locale.getpreferredencoding() != 'UTF-8', reason="Unicode check") def test_unicode_filename(resources, outdir): target1 = outdir / '测试.pdf' target2 = outdir / '通过考试.pdf' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-1.10.3/tests/test_sanity.py new/pikepdf-1.11.1/tests/test_sanity.py --- old/pikepdf-1.10.3/tests/test_sanity.py 2020-03-17 07:53:39.000000000 +0100 +++ new/pikepdf-1.11.1/tests/test_sanity.py 2020-04-16 11:26:23.000000000 +0200 @@ -2,17 +2,9 @@ A bunch of quick tests that confirm nothing is horribly wrong """ -import ctypes -import errno import gc -import os -import signal -import sys -import threading -import time -from concurrent.futures import ThreadPoolExecutor, TimeoutError, as_completed from contextlib import suppress -from io import BytesIO +from distutils.version import LooseVersion from shutil import copy import pytest @@ -24,7 +16,7 @@ def test_minimum_qpdf_version(): from pikepdf import _qpdf - assert _qpdf.qpdf_version() >= '7.0.0' + assert LooseVersion(_qpdf.qpdf_version()) >= LooseVersion('7.0.0') def test_open_pdf(resources):
