Build Sphinx docs as PDF in a new -doc subpackage

This commit is contained in:
Benjamin A. Beasley 2022-05-16 10:37:49 -04:00
parent 2926cf32cf
commit 8962508e31

View File

@ -1,4 +1,11 @@
%bcond_without tests
# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond_without doc_pdf
# The python-diskcache package, used in some of the tests, has been retired.
%bcond_with diskcache
@ -21,6 +28,13 @@ BuildArch: noarch
BuildRequires: python3-devel
%if %{with doc_pdf}
BuildRequires: make
BuildRequires: python3dist(sphinx)
BuildRequires: python3-sphinx-latex
BuildRequires: latexmk
%endif
%global common_description %{expand: \
Cross platform locks for threads and processes}
@ -35,6 +49,13 @@ Summary: A python package that provides useful locks
%{common_description}
%package doc
Summary: Documentation for fasteners
%description doc
%{common_description}
%prep
%autosetup -p1 -n fasteners-%{version}
%if %{without diskcache}
@ -49,6 +70,11 @@ sed -r -i '/\b(diskcache)\b/d' requirements-test.txt
%build
%pyproject_wheel
%if %{with doc_pdf}
PYTHONPATH="${PWD}" sphinx-build -b latex doc/source %{_vpath_builddir}/_latex
%make_build -C %{_vpath_builddir}/_latex LATEXMKOPTS='-quiet'
%endif
%install
%pyproject_install
@ -65,8 +91,15 @@ sed -r -i '/\b(diskcache)\b/d' requirements-test.txt
%files -n python3-fasteners -f %{pyproject_files}
# pyproject_files handles LICENSE; verify with “rpm -qL -p …”
%files doc
%license LICENSE
%doc CHANGELOG
%doc README.md
%if %{with doc_pdf}
%doc %{_vpath_builddir}/_latex/Fasteners.pdf
%endif
%changelog