File python-jupyter_cms.spec of Package python-jupyter_cms

#
# spec file for package python-jupyter_cms
#
# Copyright (c) 2018 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-%{**}}
# Test resources not included
%bcond_with     test
Name:           python-jupyter_cms
Version:        0.7.0
Release:        0
Summary:        Content management extension for Jupyter Notebook
License:        BSD-3-Clause
Group:          Development/Languages/Python
URL:            https://github.com/jupyter-incubator/contentmanagement
Source:         https://files.pythonhosted.org/packages/source/j/jupyter_cms/jupyter_cms-%{version}.tar.gz
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  python2-scandir
BuildRequires:  python3-Whoosh >= 2.7.0
BuildRequires:  python3-jupyter_notebook >= 4.2.0
Requires:       python-Whoosh >= 2.7.0
Requires:       python-jupyter_core
Requires:       python-jupyter_ipython >= 4.1.0
Requires:       python-jupyter_nbconvert >= 5.0.0
Requires:       python-jupyter_notebook >= 4.2.0
BuildArch:      noarch
%if %{with test}
BuildRequires:  %{python_module Whoosh >= 2.7.0}
BuildRequires:  %{python_module entrypoints >= 0.2.2}
BuildRequires:  %{python_module jupyter_core}
BuildRequires:  %{python_module jupyter_ipython >= 4.1.0}
BuildRequires:  %{python_module jupyter_nbconvert >= 5.0.0}
BuildRequires:  %{python_module jupyter_notebook >= 4.2.0}
%endif
%ifpython2
Requires:       python2-scandir
%endif
%ifpython3
Requires(post): python-Whoosh >= 2.7.0
Requires(post): python-jupyter_notebook
Requires(preun): python-Whoosh >= 2.7.0
Requires(preun): python-jupyter_notebook
%endif
%ifpython2
Requires:       python3-jupyter_cms = %{version}
%endif
%python_subpackages

%description
This package adds the following features to Jupyter Notebook:

* Search dialog on file tree, editor, and notebook screens to search over filenames and .ipynb content in the notebook directory
* IPython kernel extension to make notebooks importable, and notebook cells injectable via # <api> and # <help> annotations
* Full-page drag-and-drop upload target
* Pop-over table of contents navigation for notebooks

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

%build
%python_build

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

PYTHONPATH=%{buildroot}%{python3_sitelib} jupyter nbextension install --nbextensions=%{buildroot}%{_datadir}/jupyter/nbextensions/ --py jupyter_cms
%python_expand %fdupes %{buildroot}%{_datadir}/jupyter/nbextensions/

%post -n python3-jupyter_cms
jupyter serverextension enable --system --py jupyter_cms || true
jupyter nbextension enable --system --py jupyter_cms || true

%preun -n python3-jupyter_cms
if [ $1 == 0 ]   && [ -d %{python3_sitelib}/jupyter_cms/ ] ; then
    jupyter serverextension disable --system --py jupyter_cms || true
    jupyter nbextension disable --system --py jupyter_cms || true
fi

%if %{with test}
%check
%python_exec -m unittest discover -s test
%endif

%files %{python_files}
%defattr(-,root,root,-)
%license LICENSE.md
%python3_only %{_bindir}/jupyter-cms
%python3_only %{_datadir}/jupyter/nbextensions/jupyter_cms/
%{python_sitelib}/jupyter_cms-%{version}-py*.egg-info
%{python_sitelib}/jupyter_cms/

%changelog
openSUSE Build Service is sponsored by