Blob Blame History Raw
# 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 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 versioneer.py (a vendored, amalgamated copy of
#   python3dist(versioneer) = 0.28 that is not packaged), and the file
#   ncclient/_version.py, which was generated by it
License:        Apache-2.0 AND Unlicense
URL:            https://github.com/ncclient/ncclient
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 Bhushan.net). It is now maintained by Leonidas Poulopoulos (@leopoul)
and Einar Nilsen-Nygaard (@einarnn).

Docs: http://ncclient.readthedocs.org

PyPI: https://pypi.python.org/pypi/ncclient}

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

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


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

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
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/conf.py


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


%build
%pyproject_wheel

%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'
%endif


%install
%pyproject_install
%pyproject_save_files -l ncclient


%check
%tox

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


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


%changelog
%autochangelog