From 404157ecdc62f867b5e76bfa77d74622dc313235 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Sat, 25 Jun 2022 10:31:42 -0400 Subject: [PATCH] Package Sphinx-generated PDF in a -doc subpackage --- python-chardet.spec | 46 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/python-chardet.spec b/python-chardet.spec index b584975..4954a5b 100644 --- a/python-chardet.spec +++ b/python-chardet.spec @@ -1,3 +1,12 @@ +# Circular dependency on pytest +%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 + Name: python-chardet Version: 4.0.0 Release: %autorelease @@ -22,12 +31,20 @@ BuildArch: noarch BuildRequires: python3-devel -# Circular dependency on pytest -%bcond_without tests %if %{with tests} BuildRequires: python3-pytest %endif +%if %{with doc_pdf} +BuildRequires: make +BuildRequires: python3dist(sphinx) +BuildRequires: python3dist(sphinx-rtd-theme) +BuildRequires: python3-sphinx-latex +BuildRequires: latexmk +BuildRequires: tex-xetex-bin +BuildRequires: /usr/bin/xindy +%endif + %global common_description %{expand: Chardet: The Universal Character Encoding Detector @@ -59,6 +76,13 @@ Summary: %{summary} %{common_description} +%package doc +Summary: Documentation for python-chardet + +%description doc +%{common_description} + + %prep %autosetup -p1 -n chardet-%{version} @@ -66,6 +90,9 @@ Summary: %{summary} # https://github.com/chardet/chardet/commit/1e94b33329 grep -lr "^#\!/usr/bin/env python" chardet/ | xargs sed -i "1d" +# Since pdflatex cannot handle Unicode inputs in general: +echo "latex_engine = 'xelatex'" >> docs/conf.py + %generate_buildrequires %pyproject_buildrequires @@ -74,6 +101,11 @@ grep -lr "^#\!/usr/bin/env python" chardet/ | xargs sed -i "1d" %build %pyproject_wheel +%if %{with doc_pdf} +PYTHONPATH="${PWD}" %make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}' +%make_build -C docs/_build/latex LATEXMKOPTS='-quiet' +%endif + %install %pyproject_install @@ -88,11 +120,17 @@ install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 '%{SOURCE1}' %files -n python3-chardet -f %{pyproject_files} -%license LICENSE -%doc README.rst %{_bindir}/chardetect %{_mandir}/man1/chardetect.1* +%files doc +%license LICENSE +%doc README.rst +%if %{with doc_pdf} +%doc docs/_build/latex/chardet.pdf +%endif + + %changelog %autochangelog