#6 Initial EPEL 9 package
Merged a year ago by carlwgeorge. Opened a year ago by carlwgeorge.
rpms/ carlwgeorge/python-pikepdf epel9-init  into  epel9

@@ -0,0 +1,31 @@ 

+ From 34e8b30626fe710f4353baf4b713ce52f1823b65 Mon Sep 17 00:00:00 2001

+ From: Carl George <carl@george.computer>

+ Date: Fri, 14 Apr 2023 20:36:16 -0500

+ Subject: [PATCH 1/3] Adjust test requirements

+ 

+ - Remove pytest-cov

+ - Remove upper limit on pillow

+ ---

+  setup.cfg | 3 +--

+  1 file changed, 1 insertion(+), 2 deletions(-)

+ 

+ diff --git a/setup.cfg b/setup.cfg

+ index 9c2e7c6..9ca27d8 100644

+ --- a/setup.cfg

+ +++ b/setup.cfg

+ @@ -64,11 +64,10 @@ docs =

+  test = 

+  	attrs >= 20.2.0

+  	hypothesis >= 5, < 7

+ -	Pillow >= 7, < 9

+ +	Pillow >= 7

+  	psutil >= 5, < 6

+  	pybind11

+  	pytest >= 6, < 7

+ -	pytest-cov >= 2.10.1, < 3

+  	pytest-forked

+  	pytest-xdist >= 1.28, < 3

+  	pytest-timeout >= 1.4.2

+ -- 

+ 2.39.2

+ 

@@ -1,51 +0,0 @@ 

- From 3173e74284fc8182c8ca75c281ed2d65844a4e84 Mon Sep 17 00:00:00 2001

- From: Elliott Sales de Andrade <quantum.analyst@gmail.com>

- Date: Wed, 23 Dec 2020 05:26:27 -0500

- Subject: [PATCH] Relax some requirements.

- 

- Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>

- ---

-  pyproject.toml        | 1 -

-  requirements/test.txt | 1 -

-  setup.cfg             | 1 -

-  3 files changed, 3 deletions(-)

- 

- diff --git a/pyproject.toml b/pyproject.toml

- index e0680bf..59a3e2d 100644

- --- a/pyproject.toml

- +++ b/pyproject.toml

- @@ -4,7 +4,6 @@ requires-python = ">=3.6"

-  [build-system]

-  requires = [

-    "setuptools >= 50",

- -  "wheel >= 0.35",

-    "setuptools_scm[toml] >= 4.1",

-    "setuptools_scm_git_archive",

-    "pybind11 >= 2.6.0, <= 2.8.0"

- diff --git a/requirements/test.txt b/requirements/test.txt

- index 085bcaf..be85560 100644

- --- a/requirements/test.txt

- +++ b/requirements/test.txt

- @@ -5,7 +5,6 @@ Pillow >= 7, < 9

-  psutil >= 5, < 6

-  pybind11 >= 2.6.0

-  pytest >= 6, < 7

- -pytest-cov >= 2.10.1, < 3

-  pytest-forked

-  pytest-xdist >= 1.28, < 3

-  pytest-timeout >= 1.4.2

- diff --git a/setup.cfg b/setup.cfg

- index afb14c5..66574a0 100644

- --- a/setup.cfg

- +++ b/setup.cfg

- @@ -68,7 +68,6 @@ test =

-  	psutil >= 5, < 6

-  	pybind11

-  	pytest >= 6, < 7

- -	pytest-cov >= 2.10.1, < 3

-  	pytest-forked

-  	pytest-xdist >= 1.28, < 3

-  	pytest-timeout >= 1.4.2

- -- 

- 2.31.1

- 

@@ -0,0 +1,71 @@ 

+ From 8b1ce1fe07e83192d75220e69e5e62dabff9fa86 Mon Sep 17 00:00:00 2001

+ From: "James R. Barlow" <james@purplerock.ca>

+ Date: Wed, 25 May 2022 13:28:43 -0700

+ Subject: [PATCH 2/3] Replace pkg_resources with importlib.metadata

+ 

+ (cherry picked from commit caaf1119784b32f8b68d26b2c05a8fc2bea5ad89)

+ ---

+  docs/conf.py            |  4 +---

+  setup.cfg               |  1 +

+  src/pikepdf/_version.py | 10 +++++-----

+  3 files changed, 7 insertions(+), 8 deletions(-)

+ 

+ diff --git a/docs/conf.py b/docs/conf.py

+ index b5095a3..453ef92 100644

+ --- a/docs/conf.py

+ +++ b/docs/conf.py

+ @@ -17,8 +17,6 @@ import subprocess

+  import sys

+  from pathlib import Path

+  

+ -from pkg_resources import get_distribution

+ -

+  on_rtd = os.environ.get('READTHEDOCS') == 'True'

+  if on_rtd:

+  

+ @@ -110,7 +108,7 @@ author = u'James R. Barlow'

+  # |version| and |release|, also used in various other places throughout the

+  # built documents.

+  

+ -release = get_distribution('pikepdf').version

+ +release = pikepdf.__version__

+  version = '.'.join(release.split('.')[:2])

+  

+  # The language for content autogenerated by Sphinx. Refer to documentation

+ diff --git a/setup.cfg b/setup.cfg

+ index 9ca27d8..9cd0f92 100644

+ --- a/setup.cfg

+ +++ b/setup.cfg

+ @@ -39,6 +39,7 @@ python_requires = >= 3.6

+  install_requires = 

+  	lxml >= 4.0

+  	Pillow >= 6.0  # only needed for images; technically removable

+ +	importlib-metadata>=4;python_version<'3.8'  # until Python 3.8

+  packages = find:

+  package_dir = 

+  	=src

+ diff --git a/src/pikepdf/_version.py b/src/pikepdf/_version.py

+ index 681f1bc..a2a391f 100644

+ --- a/src/pikepdf/_version.py

+ +++ b/src/pikepdf/_version.py

+ @@ -4,12 +4,12 @@

+  #

+  # Copyright (C) 2017, James R. Barlow (https://github.com/jbarlow83/)

+  

+ -from pkg_resources import DistributionNotFound

+ -from pkg_resources import get_distribution as _get_distribution

+  

+  try:

+ -    __version__ = _get_distribution(__package__).version

+ -except DistributionNotFound:  # pragma: no cover

+ -    __version__ = "Not installed"

+ +    from importlib_metadata import version as _package_version

+ +except ImportError:

+ +    from importlib.metadata import version as _package_version

+ +

+ +__version__ = _package_version('pikepdf')

+  

+  __all__ = ['__version__']

+ -- 

+ 2.39.2

+ 

@@ -0,0 +1,49 @@ 

+ From 2276111bb56aa08f815b8790763dfaae3fb6578f Mon Sep 17 00:00:00 2001

+ From: "James R. Barlow" <james@purplerock.ca>

+ Date: Fri, 15 Apr 2022 00:58:07 -0700

+ Subject: [PATCH 3/3] Fix palette handling for Pillow 9.1.0

+ 

+ (cherry picked from commit 4f6923fe33c2d7e78d1482a5eb2beb6e9155977b)

+ ---

+  src/pikepdf/models/image.py | 8 ++++----

+  tests/test_image_access.py  | 3 ++-

+  2 files changed, 6 insertions(+), 5 deletions(-)

+ 

+ diff --git a/src/pikepdf/models/image.py b/src/pikepdf/models/image.py

+ index 632036e..e3d6aff 100644

+ --- a/src/pikepdf/models/image.py

+ +++ b/src/pikepdf/models/image.py

+ @@ -484,12 +484,12 @@ class PdfImage(PdfImageBase):

+          if self.mode == 'P' and self.bits_per_component == 1:

+              # Fix paletted 1-bit images

+              base_mode, palette = self.palette

+ -            if base_mode == 'RGB' and palette != b'\x00\x00\x00\xff\xff\xff':

+ +            if base_mode == 'RGB':

+                  im = im.convert('P')

+ +                if len(palette) == 6:

+ +                    # rgbrgb -> rgb000000...rgb

+ +                    palette = palette[0:3] + (b'\x00\x00\x00' * (256 - 2)) + palette[3:6]

+                  im.putpalette(palette, rawmode=base_mode)

+ -                gp = im.getpalette()

+ -                gp[765:768] = gp[3:6]  # work around Pillow bug

+ -                im.putpalette(gp)

+              elif base_mode == 'L' and palette != b'\x00\xff':

+                  im = im.convert('P')

+                  im.putpalette(palette, rawmode=base_mode)

+ diff --git a/tests/test_image_access.py b/tests/test_image_access.py

+ index 55624e4..dd33b2c 100644

+ --- a/tests/test_image_access.py

+ +++ b/tests/test_image_access.py

+ @@ -297,7 +297,8 @@ def test_image_palette(resources, filename, bpc, rgb):

+      outstream = BytesIO()

+      pim.extract_to(stream=outstream)

+  

+ -    im = pim.as_pil_image().convert('RGB')

+ +    im_pal = pim.as_pil_image()

+ +    im = im_pal.convert('RGB')

+      assert im.getpixel((1, 1)) == rgb

+  

+  

+ -- 

+ 2.39.2

+ 

file modified
+42 -39
@@ -1,5 +1,12 @@ 

  %global srcname pikepdf

  

+ # disable docs on EPEL 9 to avoid circular dependency on matplotlib

+ %if %{defined el9}

+ %bcond_with docs

+ %else

+ %bcond_without docs

+ %endif

+ 

  Name:           python-%{srcname}

  Version:        2.16.1

  Release:        %autorelease
@@ -8,97 +15,93 @@ 

  License:        MPLv2.0

  URL:            https://github.com/pikepdf/pikepdf

  Source0:        %pypi_source

- Patch0001:      0001-Relax-some-requirements.patch

+ # downstream only

+ Patch1:         0001-Adjust-test-requirements.patch

+ # https://github.com/pikepdf/pikepdf/commit/caaf1119784b32f8b68d26b2c05a8fc2bea5ad89

+ Patch2:         0002-Replace-pkg_resources-with-importlib.metadata.patch

+ # https://github.com/pikepdf/pikepdf/commit/4f6923fe33c2d7e78d1482a5eb2beb6e9155977b

+ Patch3:         0003-Fix-palette-handling-for-Pillow-9.1.0.patch

  

  BuildRequires:  gcc-c++

  BuildRequires:  qpdf-devel >= 10.0.3

  BuildRequires:  python3-devel

- BuildRequires:  python3dist(lxml) >= 4

- BuildRequires:  (python3dist(pillow) >= 7 with python3dist(pillow) < 9)

- BuildRequires:  (python3dist(pybind11) >= 2.6 with python3dist(pybind11) < 3)

- BuildRequires:  python3dist(setuptools)

- BuildRequires:  python3dist(setuptools-scm)

- BuildRequires:  python3dist(setuptools-scm[toml]) >= 4.1

- BuildRequires:  python3dist(setuptools-scm-git-archive)

  # Tests:

  BuildRequires:  poppler-utils

- BuildRequires:  python3dist(attrs) >= 20.2

- BuildRequires:  (python3dist(hypothesis) >= 5 with python3dist(hypothesis) < 7)

- BuildRequires:  python3dist(psutil) >= 5

- BuildRequires:  (python3dist(pytest) >= 6 with python3dist(pytest) < 7)

- BuildRequires:  python3dist(pytest-forked)

- BuildRequires:  python3dist(pytest-timeout) >= 1.4.2

- BuildRequires:  (python3dist(pytest-xdist) >= 1.28 with python3dist(pytest-xdist) < 3)

- BuildRequires:  python3dist(python-dateutil) >= 2.8

- BuildRequires:  python3dist(python-xmp-toolkit) >= 2.0.1

- 

- %description

+ 

+ %global _description %{expand:

  pikepdf is a Python library for reading and writing PDF files. pikepdf is

- based on QPDF, a powerful PDF manipulation and repair library.

+ based on QPDF, a powerful PDF manipulation and repair library.}

+ 

+ 

+ %description %{_description}

  

  

  %package -n     python3-%{srcname}

  Summary:        %{summary}

  

- # Force a minimum version (same soname as 8.1.x):

- Requires:       qpdf-libs >= 8.4.2

  

- %description -n python3-%{srcname}

- pikepdf is a Python library for reading and writing PDF files. pikepdf is

- based on QPDF, a powerful PDF manipulation and repair library.

+ %description -n python3-%{srcname} %{_description}

  

  

+ %if %{with docs}

  %package -n python-%{srcname}-doc

  Summary:        pikepdf documentation

  

- BuildRequires:  python3dist(sphinx) >= 3

- BuildRequires:  python3dist(sphinx-issues)

- BuildRequires:  python3dist(sphinx-rtd-theme)

- BuildRequires:  python3dist(matplotlib)

+ # Not autorequired because it's a Fedora-specific subpackage.

  BuildRequires:  python3-ipython-sphinx

  

+ 

  %description -n python-%{srcname}-doc

  Documentation for pikepdf

+ %endif

  

  

  %prep

  %autosetup -n %{srcname}-%{version} -p1

  

- # Remove bundled egg-info

- rm -rf src/%{srcname}.egg-info

- 

+ %if %{with docs}

  # We don't build docs against the installed version, so force the version.

  sed -i -e "s/release = .\+/release = '%{version}'/g" docs/conf.py

+ %endif

+ 

+ 

+ %generate_buildrequires

+ %pyproject_buildrequires -x test %{?with_docs:-x docs}

  

  

  %build

- %py3_build

+ %pyproject_wheel

  

+ %if %{with docs}

  # generate html docs

+ export PYTHONPATH="%{pyproject_build_lib}"

  pushd docs

- PYTHONPATH=$(ls -d ${PWD}/../build/lib*) sphinx-build-3 . ../html

+ sphinx-build-3 . ../html

  popd

  # remove the sphinx-build leftovers

  rm -rf html/.{doctrees,buildinfo}

+ %endif

  

  

  %install

- %py3_install

+ %pyproject_install

+ %pyproject_save_files %{srcname}

  

  

  %check

- %{pytest} -ra

+ %pytest

  

  

- %files -n python3-%{srcname}

+ %files -n python3-%{srcname} -f %{pyproject_files}

  %license LICENSE.txt

  %doc README.md

- %{python3_sitearch}/%{srcname}/

- %{python3_sitearch}/%{srcname}-%{version}-py%{python3_version}.egg-info/

  

+ 

+ %if %{with docs}

  %files -n python-%{srcname}-doc

  %doc html

  %license LICENSE.txt

+ %endif

  

  

  %changelog

After a good bit of research, to get an EPEL 9 package of python-pikepdf I determined that we'll need to start with version 2.16.1 from the f34 branch. Before opening this PR I fast-forward merged f34 to epel9 to avoid this PR having 90+ commits. A few additional changes were needed to get this to build, and for buildrequirement sanity I went ahead and converted it to pyproject macros. Once merged and built this will resolve rhbz#2093516. This actually won't be able to be built until RHEL 9.2 is released, because that's when qpdf-devel is supposed to be added to CRB.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci
https://fedora.softwarefactory-project.io/zuul/buildset/41834fb541a64dec99c529bac394e32d

Pull-Request has been merged by carlwgeorge

a year ago