Blob Blame History Raw
%global srcname ocrmypdf

Name:           %{srcname}
Version:        14.2.1
Release:        %autorelease
Summary:        Add an OCR text layer to scanned PDF files

# See all SPDX-License-Identifier tags in files.
# No docs or tests are included in RPM.
License:        MPL-2.0 and Zlib
Source0:        %pypi_source %{srcname}
# Fedora specific.
Patch0001:      0001-Remove-unnecessary-dependencies.patch

BuildArch:      noarch

ExcludeArch: %{ix86}

BuildRequires:  ghostscript >= 9.50
BuildRequires:  pngquant >= 2.0.0
BuildRequires:  tesseract >= 4.1.1
BuildRequires:  tesseract-osd
BuildRequires:  tesseract-langpack-deu
BuildRequires:  unpaper >= 6.1
BuildRequires:  python3-devel

Requires:       ghostscript >= 9.15
Recommends:     pngquant >= 2.0.0
Requires:       tesseract >= 4.1.1
Recommends:     unpaper >= 6.1

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be
searched or copy-pasted.

%package -n %{srcname}-doc
Summary:        ocrmypdf documentation
License:        CC-BY-SA-4.0

%description -n %{srcname}-doc
Documentation for ocrmypdf

%pyproject_extras_subpkg -n %{srcname} watcher

%pyproject_extras_subpkg -n %{srcname} webservice

%pyproject_buildrequires -x docs -x test

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

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

# Cleanup shebang and executable bits.
for f in src/%{srcname}/*.py src/%{srcname}/*/*.py; do
    sed -e '1{\@^#!/usr/bin/env python@d}' $f > $ &&
    touch -r $f $ &&
    mv $ $f
    chmod -x $f


# generate html docs
PYTHONPATH="$PWD/build/lib" OCRMYPDF_VERSION="%{version}" sphinx-build-3 docs html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%pyproject_save_files %{srcname}

# Install completion files.
install -Dpm 0644 misc/completion/ocrmypdf.bash %{buildroot}%{_datadir}/bash-completion/completions/ocrmypdf
install -Dpm 0644 misc/completion/ %{buildroot}%{_datadir}/fish/vendor_completions.d/

# Install optional programs.
install -Dpm 0755 misc/ %{buildroot}%{_bindir}/%{srcname}-watcher
install -Dpm 0755 misc/ %{buildroot}%{_bindir}/%{srcname}-webservice

%{pytest} -ra -n auto --runslow -k 'not test_tesseract_config_invalid'
# For some reason these break and 'work' when run in parallel.
%{pytest} -ra --runslow -k 'test_tesseract_config_invalid'

%files -n %{srcname} -f %{pyproject_files}
%license LICENSE
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d

%files -n %{srcname}-doc
%doc html
%license LICENSE