Blob Blame History Raw
%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
Summary:        Read and write PDFs with Python, powered by qpdf

License:        MPLv2.0
URL:            https://github.com/pikepdf/pikepdf
Source0:        %pypi_source
# 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
# Tests:
BuildRequires:  poppler-utils

%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.}


%description %{_description}


%package -n     python3-%{srcname}
Summary:        %{summary}


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


%if %{with docs}
%package -n python-%{srcname}-doc
Summary:        pikepdf documentation

# 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

%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
%pyproject_wheel

%if %{with docs}
# generate html docs
export PYTHONPATH="%{pyproject_build_lib}"
pushd docs
sphinx-build-3 . ../html
popd
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
%endif


%install
%pyproject_install
%pyproject_save_files %{srcname}


%check
%pytest


%files -n python3-%{srcname} -f %{pyproject_files}
%license LICENSE.txt
%doc README.md


%if %{with docs}
%files -n python-%{srcname}-doc
%doc html
%license LICENSE.txt
%endif


%changelog
%autochangelog