File IPython.spec of Package IPython

#
# spec file for package IPython
#
# Copyright (c) 2015 SUSE LINUX Products 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/
#


Name:           IPython
BuildRequires:  python-devel
Version:        3.2.2
Release:        0
Source0:        https://pypi.python.org/packages/source/i/ipython/ipython-%{version}.tar.gz
Source1:        ipython-icons.tar.xz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Url:            http://ipython.scipy.org/
Summary:        An Enhanced Interactive Python Shell
License:        BSD-3-Clause
Group:          Development/Languages/Python
BuildArch:      noarch
BuildRequires:  python
BuildRequires:  python-setuptools
BuildRequires:  python-Cython
BuildRequires:  python-curses
BuildRequires:  python-nose >= 0.10.1
BuildRequires:  python-opengl
BuildRequires:  python-pexpect
BuildRequires:  python-pymongo
BuildRequires:  python-pyzmq-devel >= 2.1.11
%if 0%{?suse_version} != 1315 
BuildRequires:  python-wxWidgets
%endif
%if 0%{?suse_version}
%py_requires
BuildRequires:  fdupes
BuildRequires:  update-desktop-files
%endif
Requires:       python-Jinja2
Requires:       python-pexpect
Requires:       python-pyzmq >= 2.1.11
Recommends:     python-curses
Recommends:     python-pymongo
Recommends:     python-wxWidgets
# qtconsole
BuildRequires:  python-Pygments
BuildRequires:  python-matplotlib
BuildRequires:  python-qt4-devel
Recommends:     python-Pygments
Recommends:     python-matplotlib
Recommends:     python-qt4
# html notebook
BuildRequires:  python-tornado >= 4.0
Recommends:     python-tornado >= 4.0
BuildRequires:  python-mistune >= 0.5
Recommends:     python-mistune >= 0.5
#ipython nbformat
BuildRequires:  python-jsonschema
Requires:       python-jsonschema
#documentation
BuildRequires:  graphviz
BuildRequires:  graphviz-gnome
BuildRequires:  python-Sphinx >= 0.3
BuildRequires:  python-numpydoc
Requires(post): update-alternatives
Requires(postun): update-alternatives

%description
IPython provides a replacement for the interactive python (Python)
interpreter with extra functionality.

Main features:
* Comprehensive object introspection.
* Input history that is persistent across sessions.
* Caching of output results during a session with automatically
   generated references.
* Readline-based name completion.
* Extensible system of 'magic' commands for controlling the
   environment and performing many tasks related either to IPython
   or the operating system.
* Configuration system with easy switching between different setups
   (simpler than changing $PYTHONSTARTUP environment variables every
   time).
* Session logging and reloading.
* Extensible syntax processing for special purpose situations.
* Access to the system shell with user-extensible alias system.
* Easily embeddable in other Python programs.
* Integrated access to the pdb debugger and the Python profiler.


%package doc
Summary:        An Enhanced Interactive Python Shell documentation
Group:          Documentation/Other
Recommends:     %{name} = %{version}

%description doc
IPython provides a replacement for the interactive python (Python)
interpreter with extra functionality.

This package contains comprehensive documentation for IPython in
html format, as well as examples of usage.


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

# Get rid of library shebangs
find . -type f -name "*.py" -exec sed -i '/#!\/usr\/bin\/env/d' {} \;

# Get the .desktop files ready
mv examples/IPython\ Kernel/*.desktop ./
sed -i 's/gnome-netstatus-idle/ipython/g' *.desktop
sed -i 's/Exec=ipython/Exec=ipython-%{py_ver}/g' *.desktop
mv ipython.desktop ipython-%{py_ver}.desktop
mv ipython-qtconsole.desktop ipython-qtconsole-%{py_ver}.desktop

%build
export CFLAGS="%{optflags}"
python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

install -d -m 755 %{buildroot}%{_docdir}/

# docs now require jsdoc, a javascript package
# make docs
# pushd docs
# PYTHONPATH=$PYTHONPATH:%{buildroot}%{python_sitelib} make html
# rm build/html/.buildinfo
# mv build/html %{buildroot}%{_docdir}/%{name}/
# popd
# add examples
cp -vr examples %{buildroot}%{_docdir}/%{name}/

# set executable
chmod a+x %{buildroot}%{python_sitelib}/%{name}/external/mathjax.py

# remove all executables that end in *2
rm %{buildroot}/%{_bindir}/ipcluster2
rm %{buildroot}/%{_bindir}/ipcontroller2
rm %{buildroot}/%{_bindir}/ipengine2
rm %{buildroot}/%{_bindir}/iptest2
rm %{buildroot}/%{_bindir}/ipython2

# remove hidden files
rm -f %{buildroot}%{python_sitelib}/%{name}/.git_commit_info.ini
rm -f %{buildroot}%{python_sitelib}/%{name}/html/static/components/.gitignore
rm -f %{buildroot}%{_docdir}/%{name}/manual/.buildinfo

%fdupes %{buildroot}%{_docdir}/%{name}/

# install .desktop files
%suse_update_desktop_file -r -i ipython-%{py_ver} System TerminalEmulator
%suse_update_desktop_file -r -i ipython-qtconsole-%{py_ver} System TerminalEmulator

# install icons
tar xf %{S:1} -C %{buildroot}%{_datadir}

# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for p in ipython iptest ipengine ipcontroller ipcluster ; do
    mv %{buildroot}%{_bindir}/$p %{buildroot}%{_bindir}/$p-%{py_ver}
    ln -s -f %{_sysconfdir}/alternatives/$p %{buildroot}%{_bindir}/$p
    # create a dummy target for /etc/alternatives/$p
    touch %{buildroot}%{_sysconfdir}/alternatives/$p
done

# Prepare for update-alternatives usage
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for p in ipython ipengine ipcontroller ipcluster ; do
    mv %{buildroot}%{_mandir}/man1/$p.1 %{buildroot}%{_mandir}/man1/$p-%{py_ver}.1
    ln -s -f %{_sysconfdir}/alternatives/$p.1.gz %{buildroot}%{_mandir}/man1/$p.1.gz
    # create a dummy target for /etc/alternatives/$p
    touch %{buildroot}%{_sysconfdir}/alternatives/$p.1.gz
done

%post
%_sbindir/update-alternatives \
   --install %{_bindir}/ipython ipython %{_bindir}/ipython-%{py_ver} 30 \
   --slave %{_bindir}/iptest iptest %{_bindir}/iptest-%{py_ver} \
   --slave %{_bindir}/ipengine ipengine %{_bindir}/ipengine-%{py_ver} \
   --slave %{_bindir}/ipcontroller ipcontroller %{_bindir}/ipcontroller-%{py_ver} \
   --slave %{_bindir}/ipcluster ipcluster %{_bindir}/ipcluster-%{py_ver} \
   --slave %{_mandir}/man1/ipython.1.gz ipython.1.gz %{_mandir}/man1/ipython-%{py_ver}.1.gz \
   --slave %{_mandir}/man1/ipengine.1.gz ipengine.1.gz %{_mandir}/man1/ipengine-%{py_ver}.1.gz \
   --slave %{_mandir}/man1/ipcontroller.1.gz ipcontroller.1.gz %{_mandir}/man1/ipcontroller-%{py_ver}.1.gz \
   --slave %{_mandir}/man1/ipcluster.1.gz ipcluster.1.gz %{_mandir}/man1/ipcluster-%{py_ver}.1.gz

%postun
if [ $1 -eq 0 ] ; then
    %_sbindir/update-alternatives --remove ipython %{_bindir}/ipython-%{py_ver}
fi

%files
%defattr(-,root,root)
%doc COPYING.rst README.rst
%{_bindir}/ipcluster
%{_bindir}/ipcontroller
%{_bindir}/ipengine
%{_bindir}/iptest
%{_bindir}/ipython
%{_bindir}/ipcluster-%{py_ver}
%{_bindir}/ipcontroller-%{py_ver}
%{_bindir}/ipengine-%{py_ver}
%{_bindir}/iptest-%{py_ver}
%{_bindir}/ipython-%{py_ver}
%{_mandir}/man1/ipcluster.1.gz
%{_mandir}/man1/ipcontroller.1.gz
%{_mandir}/man1/ipengine.1.gz
%{_mandir}/man1/ipython.1.gz
%{_mandir}/man1/ipcluster-%{py_ver}.1.gz
%{_mandir}/man1/ipcontroller-%{py_ver}.1.gz
%{_mandir}/man1/ipengine-%{py_ver}.1.gz
%{_mandir}/man1/ipython-%{py_ver}.1.gz
%ghost %{_sysconfdir}/alternatives/ipcluster
%ghost %{_sysconfdir}/alternatives/ipcontroller
%ghost %{_sysconfdir}/alternatives/ipengine
%ghost %{_sysconfdir}/alternatives/iptest
%ghost %{_sysconfdir}/alternatives/ipython
%ghost %{_sysconfdir}/alternatives/ipcluster.1.gz
%ghost %{_sysconfdir}/alternatives/ipcontroller.1.gz
%ghost %{_sysconfdir}/alternatives/ipengine.1.gz
%ghost %{_sysconfdir}/alternatives/ipython.1.gz
%{_datadir}/applications/ipython-qtconsole-%{py_ver}.desktop
%{_datadir}/applications/ipython-%{py_ver}.desktop
%{_datadir}/icons/hicolor/
%{python_sitelib}/%{name}
%{python_sitelib}/ipython-%{version}-py*.egg-info
%exclude %{_docdir}/%{name}/

%files doc
%defattr(-,root,root)
%{_docdir}/%{name}/
%exclude %{_docdir}/%{name}/COPYING.rst
%exclude %{_docdir}/%{name}/README.rst

%changelog
openSUSE Build Service is sponsored by