File python-dulwich.spec of Package python-dulwich

#
# spec file for package python-dulwich
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-dulwich
Version:        0.18.5
Release:        0
Url:            https://www.dulwich.io
Summary:        Pure-Python Git Library
License:        GPL-2.0+ or Apache-2.0
Group:          Development/Languages/Python
Source0:        https://pypi.io/packages/source/d/dulwich/dulwich-%{version}.tar.gz
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  python3-Sphinx
Requires(post): update-alternatives
Requires(preun): update-alternatives

%python_subpackages

%description
Simple Pure-Python implementation of the Git file formats and protocols. Dulwich
is the place where Mr. and Mrs. Git live in one of the Monty Python sketches.

%package -n python-dulwich-doc
Summary:        Documentation for %{name}
Group:          Documentation/Other
Provides:       %{python_module dulwich-doc = %{version}}

%description -n python-dulwich-doc
Simple Pure-Python implementation of the Git file formats and protocols. Dulwich
is the place where Mr. and Mrs. Git live in one of the Monty Python sketches.

This package contains the documentation.

%prep
%setup -q -n dulwich-%{version}

%build
export CFLAGS="%{optflags}"
%python_build
sphinx-build -b html docs/ docs/build/html

%install
%python_install
%python_expand %fdupes -s %{buildroot}%{$python_sitelib}
%python_clone -a %{buildroot}%{_bindir}/dulwich
%python_clone -a %{buildroot}%{_bindir}/dul-receive-pack
%python_clone -a %{buildroot}%{_bindir}/dul-upload-pack
rm docs/build/html/.doctrees/environment.pickle

%post
%python_install_alternative dulwich
%python_install_alternative dul-receive-pack
%python_install_alternative dul-upload-pack

%postun
%python_uninstall_alternative dulwich
%python_uninstall_alternative dul-receive-pack
%python_uninstall_alternative dul-upload-pack

%files %{python_files}
%defattr(-,root,root,-)
%doc COPYING NEWS README.md
%python_alternative dulwich
%python_alternative dul-receive-pack
%python_alternative dul-upload-pack
%{python_sitearch}/*

%files -n python-dulwich-doc
%doc COPYING docs/build/html

%changelog