File python-docutils.spec of Package python-docutils.32673

#
# spec file for package python-docutils
#
# 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-docutils
Version:        0.14
Release:        0
Summary:        Python Documentation Utilities
License:        Python-2.0 and BSD-2-Clause and GPL-2.0+ and GPL-3.0+ and SUSE-Public-Domain
Group:          Development/Languages/Python
Url:            https://pypi.python.org/pypi/docutils/
Source:         https://files.pythonhosted.org/packages/source/d/docutils/docutils-%{version}.tar.gz
Source99:       python-docutils-rpmlintrc
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module nose}
BuildRequires:  %{python_module xml}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       python-xml
Requires(pre):  update-alternatives
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch:      noarch
%ifpython3
Provides:       docutils = %{version}
Obsoletes:      docutils < %{version}
%endif
%python_subpackages

%description
Docutils is a modular system for processing documentation into useful formats,
such as HTML, XML, and LaTeX. For input Docutils supports reStructuredText, an
easy-to-read, what-you-see-is-what-you-get plaintext markup syntax.

%prep
%setup -q -n docutils-%{version}
# Remove useless ".py" ending from executables:
for i in tools/rst*; do mv "$i" "${i/.py}"; done
sed -i "s|'tools/\(rst.*\)\.py'|'tools/\1'|" setup.py
# Remove shebang from non-executable files
for i in {'code_analyzer','error_reporting','punctuation_chars','smartquotes','math/latex2mathml','math/math2html','math/tex2mathml_extern'}; do
sed -i -e "1d" "docutils/utils/$i.py"
done
sed -i -e "1d" "docutils/writers/xetex/__init__.py" "docutils/writers/_html_base.py"

%build
%python_build

%install
%python_install

# Copy rst2html as docutils, modern versions provides the docutils
# binary and it's the default script to use in update-alternatives
cp %{buildroot}%{_bindir}/rst2html %{buildroot}%{_bindir}/docutils

for binary in docutils rst2html rst2latex rst2man rst2odt rst2odt_prepstyles rst2pseudoxml rst2s5 rst2xetex rst2xml rstpep2html rst2html4 rst2html5; do
    %python_clone -a %{buildroot}%{_bindir}/$binary
done

%python_expand %fdupes -s %{buildroot}%{$python_sitelib}

%post
# remove old package alternatives before providing new
update-alternatives --display rst2html4 > /dev/null 2> /dev/null && update-alternatives --remove rst2html4 %{_bindir}/rst2html4-docutils
update-alternatives --display rst2html5 > /dev/null 2> /dev/null && update-alternatives --remove rst2html5 %{_bindir}/rst2html5-docutils

%{python_install_alternative docutils rst2html rst2latex rst2man rst2odt rst2odt_prepstyles rst2pseudoxml rst2s5 rst2xetex rst2xml rstpep2html rst2html4 rst2html5}

%postun
%{python_uninstall_alternative docutils rst2html rst2latex rst2man rst2odt rst2odt_prepstyles rst2pseudoxml rst2s5 rst2xetex rst2xml rstpep2html rst2html4 rst2html5}

%check
%python_exec -c 'import subprocess; import sys; sys.exit(subprocess.call([sys.executable, "test/alltests.py" if sys.version_info[0] == 2 else "test3/alltests.py"]))'

%files %{python_files}
%defattr(-,root,root,-)
%doc COPYING.txt FAQ.txt HISTORY.txt README.txt THANKS.txt BUGS.txt docs/* licenses

%python_alternative %{_bindir}/docutils
%python_alternative %{_bindir}/rst2html
%python_alternative %{_bindir}/rst2latex
%python_alternative %{_bindir}/rst2man
%python_alternative %{_bindir}/rst2odt
%python_alternative %{_bindir}/rst2odt_prepstyles
%python_alternative %{_bindir}/rst2pseudoxml
%python_alternative %{_bindir}/rst2s5
%python_alternative %{_bindir}/rst2xetex
%python_alternative %{_bindir}/rst2xml
%python_alternative %{_bindir}/rstpep2html
%python_alternative %{_bindir}/rst2html4
%python_alternative %{_bindir}/rst2html5

%{python_sitelib}/docutils/
%{python_sitelib}/docutils-%{version}-py%{python_version}.egg-info

%changelog
openSUSE Build Service is sponsored by