File python-jupyter_ipyparallel.spec of Package python-jupyter_ipyparallel

#
# spec file for package python-jupyter_ipyparallel
#
# 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 http://bugs.opensuse.org/
#


# Easily disable nbextension installation
%bcond_without nbextension

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name:           python-jupyter_ipyparallel
Version:        6.1.1
Release:        0
Summary:        Interactive Parallel Computing with IPython
License:        BSD-3-Clause
Group:          Development/Languages/Python
Url:            https://github.com/ipython/ipyparallel
Source:         https://files.pythonhosted.org/packages/source/i/ipyparallel/ipyparallel-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
%if %{with nbextension}
BuildRequires:  python3-jupyter_notebook
%endif
Requires:       python-python-dateutil >= 2.1
Requires:       python-decorator
Requires:       python-ipython_genutils
Requires:       python-jupyter_client
Requires:       python-jupyter_ipykernel
Requires:       python-jupyter_ipython >= 4
Requires:       python-pyzmq >= 13
Requires:       python-tornado >= 4
%ifpython2      
Requires:       python-futures
%endif
Recommends:     %{name}-nbextension = %{version}
Recommends:     python-mpi4py
Recommends:     python-pymongo
%ifpython2
Requires:       python3-jupyter_ipyparallel
%endif
%ifpython3
Provides:         python-jupyter_ipyparallel-nbextension = %{version}
# Change <= to < in next version of 6.0.2
Obsoletes:        python-jupyter_ipyparallel-nbextension <= %{version}
Requires(post):   python3-jupyter_notebook
Requires(preun):  python3-jupyter_notebook
%endif
Requires(post):   update-alternatives
Requires(postun):  update-alternatives
BuildArch:      noarch

%python_subpackages

%description
Use multiple instances of IPython in parallel, interactively.

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

%build
%python_build

%install
%python_install


# Prepare for update-alternatives
%python_clone -a %{buildroot}%{_bindir}/ipcluster
%python_clone -a %{buildroot}%{_bindir}/ipcontroller
%python_clone -a %{buildroot}%{_bindir}/ipengine

# These files are meant to be runnable stand-alone, so they should be executable
%{python_expand pushd %{buildroot}%{$python_sitelib}
chmod a+x ipyparallel/apps/*app.py
chmod a-x ipyparallel/apps/baseapp.py
chmod a+x ipyparallel/controller/heartmonitor.py
# Fix wrong-script-interpreter
sed -i "s|#!/usr/bin/env python|#!%__$python|" ipyparallel/apps/*app.py
sed -i "s|#!/usr/bin/env python|#!%__$python|" ipyparallel/controller/heartmonitor.py
# Deduplicating files can generate a RPMLINT warning for pyc mtime
$python -m compileall -d %{$python_sitearch} ipyparallel/apps/
$python -O -m compileall -d %{$python_sitearch} ipyparallel/apps/
$python -m compileall -d %{$python_sitearch} ipyparallel/controller/heartmonitor.py
$python -O -m compileall -d %{$python_sitearch} ipyparallel/controller/heartmonitor.py
%fdupes .
popd
}
%python_expand rm -f %{buildroot}%{$python_sitelib}/_current_flavor

PYTHONPATH=%{buildroot}%{python3_sitelib} jupyter nbextension install --prefix=%{buildroot}%{_prefix} --py ipyparallel

%post
%{python_install_alternative ipcluster ipcontroller ipengine}
%ifpython3
ipcluster nbextension enable
%endif
exit 0

%postun
%python_uninstall_alternative ipcluster

%preun -n python3-jupyter_ipyparallel
if [ $1 == 0 ] && [ -d %{python3_sitelib}/ipyparallel/ ] ; then
    ipcluster nbextension disable
fi
exit 0

%files %{python_files}
%defattr(-,root,root,-)
%doc COPYING.md README.md
%python_alternative %{_bindir}/ipcluster
%python_alternative %{_bindir}/ipcontroller
%python_alternative %{_bindir}/ipengine
%{python_sitelib}/ipyparallel-%{version}-py*.egg-info
%{python_sitelib}/ipyparallel/
%python3_only %{_datadir}/jupyter/nbextensions/ipyparallel/

%changelog
openSUSE Build Service is sponsored by