Blob Blame History Raw
# Sphinx-generated HTML documentation is not suitable for packaging; see
# for discussion.
# We can generate PDF documentation as a substitute.
%bcond doc_pdf 1

Name:           python-ncclient
Version:        0.6.15
Release:        %autorelease
Summary:        Python library for the NETCONF protocol

# The entire source is Apache-2.0, except:
# Unlicense:
# - The script (a vendored, amalgamated copy of
#   python3dist(versioneer) = 0.28 that is not packaged), and the file
#   ncclient/, which was generated by it
License:        Apache-2.0 AND Unlicense
Source:         %{url}/archive/v%{version}/ncclient-%{version}.tar.gz

BuildArch:      noarch

BuildRequires:  python3-devel

%global common_description %{expand:
ncclient is a Python library that facilitates client-side scripting and
application development around the NETCONF protocol. ncclient was developed by
Shikar It is now maintained by Leonidas Poulopoulos (@leopoul)
and Einar Nilsen-Nygaard (@einarnn).



%description %{common_description}

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

%description -n python3-ncclient %{common_description}

%package doc
Summary:        Documentation and examples for python-ncclient

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk

%description doc
The python-ncclient-doc package contains detailed documentation and examples
for python-ncclient.

%autosetup -n ncclient-%{version}
%py3_shebang_fix examples

sed -r -i '/^(flake8|pytest-cov)\b/d' test-requirements.txt

# Loosen exact-version doc dependencies
sed -r -i 's/==/>=/' docs/requirements.txt
# Drop intersphinx mappings, since we can’t download remote inventories and
# can’t easily produce working hyperlinks from inventories in local
# documentation packages.
echo 'intersphinx_mapping.clear()' >> docs/

%pyproject_buildrequires -t %{?with_doc_pdf:docs/requirements.txt}


%if %{with doc_pdf}
%make_build -C docs latex SPHINXOPTS='-j%{?_smp_build_ncpus}'
# There is an escaping problem we haven’t traced to its root cause. In the list
# of authors, “\and” is emitted, and then “\a” is interpreted as the backslash
# escape for the ASCII BEL (bell) character. This then breaks the LaTeX build.
# Find it and fix it after generating the LaTeX source and before building it.
sed -r -i 's/\x07nd/and/g' docs/build/latex/ncclient.tex
%make_build -C docs/build/latex LATEXMKOPTS='-quiet'

%pyproject_save_files -l ncclient


%files -n python3-ncclient -f %{pyproject_files}

%files doc
%license LICENSE
%doc Changelog
%doc README.rst
%if %{with doc_pdf}
%doc docs/build/latex/ncclient.pdf
%doc examples/