File python-jupyter_nbconvert.spec of Package python-jupyter_nbconvert

#
# spec file for package python-jupyter_nbconvert
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/
#


%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-jupyter_nbconvert
Version:        5.4.1
Release:        0
# May not be necessary in next version
%define doc_ver 5.4
Summary:        Conversion of Jupyter Notebooks
License:        BSD-3-Clause
Group:          Development/Languages/Python
URL:            https://github.com/jupyter/nbconvert
Source0:        https://files.pythonhosted.org/packages/source/n/nbconvert/nbconvert-%{version}.tar.gz
Source1:        https://media.readthedocs.org/pdf/nbconvert/%{doc_ver}/nbconvert.pdf
Source2:        https://media.readthedocs.org/htmlzip/nbconvert/%{doc_ver}/nbconvert.zip
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  unzip
# Test requirements
BuildRequires:  %{python_module Jinja2}
BuildRequires:  %{python_module Pygments}
BuildRequires:  %{python_module bleach}
BuildRequires:  %{python_module defusedxml}
BuildRequires:  %{python_module entrypoints >= 0.2.2}
BuildRequires:  %{python_module jupyter_client >= 4.2}
BuildRequires:  %{python_module jupyter_core}
BuildRequires:  %{python_module jupyter_ipykernel}
BuildRequires:  %{python_module jupyter_nbformat >= 4.4}
BuildRequires:  %{python_module mistune >= 0.7.4}
BuildRequires:  %{python_module nose}
BuildRequires:  %{python_module pandocfilters >= 1.4.1}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module testpath}
BuildRequires:  %{python_module tornado >= 4.0}
BuildRequires:  %{python_module traitlets >= 4.2}
# Python 2 test requirements
Requires:       python-Jinja2
Requires:       python-Pygments
Requires:       python-bleach
Requires:       python-defusedxml
Requires:       python-entrypoints >= 0.2.2
Requires:       python-jupyter_core
Requires:       python-jupyter_nbformat >= 4.4
Requires:       python-mistune >= 0.7.4
Requires:       python-pandocfilters >= 1.4.1
Requires:       python-testpath
Requires:       python-traitlets >= 4.2
Recommends:     pandoc
Recommends:     python-jupyter_client >= 4.2
Recommends:     python-tornado >= 4.0
Suggests:       %{name}-latex
BuildArch:      noarch
%python_subpackages

%description
The jupyter nbconvert package converts notebooks to various other formats
via Jinja templates.

%package        latex
Summary:        LaTeX support for nbconvert
Group:          Development/Languages/Python
Requires:       texlive-bibtex
Requires:       texlive-makeindex
Requires:       tex(adjustbox.sty)
Requires:       tex(eurosym.sty)
Requires:       tex(ulem.sty)

%description    latex
The jupyter nbconvert package converts notebooks to various other formats
via Jinja templates.

This package pulls in the LaTeX dependencies for nbconvert.

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

%description -n python-jupyter_nbconvert-doc
Documentation and help files for python-jupyter_nbconvert.

%prep
%setup -q -n nbconvert-%{version}
cp %{SOURCE1} .
unzip %{SOURCE2} -d docs
mv docs/nbconvert-* docs/html
rm docs/html/.buildinfo

%build
%python_build

%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}

%{python_expand chmod a+x %{buildroot}%{$python_sitelib}/nbconvert/nbconvertapp.py
chmod a+x %{buildroot}%{$python_sitelib}/nbconvert/filters/filter_links.py
sed -i "s|^#!%{_bindir}/env python$|#!%{__$python}|" %{buildroot}%{$python_sitelib}/nbconvert/nbconvertapp.py
sed -i "s|^#!%{_bindir}/env python3$|#!%{__$python}|" %{buildroot}%{$python_sitelib}/nbconvert/filters/filter_links.py
$python -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/nbconvert/
$python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/nbconvert/
$python -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/nbconvert/filters/
$python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/nbconvert/filters/
%fdupes %{buildroot}%{$python_sitelib}
}

%check
pushd docs
export LANG=en_US.UTF-8
# test_run_notebooks disabled until IPython 7 incompatibility in tests fixed.
# See https://github.com/jupyter/nbconvert/issues/898
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitelib}
$python -m ipykernel.kernelspec --user
%pytest --pyargs -k 'not (test_svg_handling or test_run_notebooks)' nbconvert
}
popd

%files %{python_files}
%license LICENSE
%doc README.md
%python3_only %{_bindir}/jupyter-nbconvert
%{python_sitelib}/*

%files %{python_files latex}
%license LICENSE

%files -n python-jupyter_nbconvert-doc
%license LICENSE
%doc nbconvert.pdf
%doc docs/html

%changelog
openSUSE Build Service is sponsored by