File IPython.spec of Package IPython

#
# spec file for package IPython
#
# Copyright (c) 2014 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:        1.1.0
Release:        0
Source0:        https://pypi.python.org/packages/source/i/ipython/ipython-%{version}.tar.gz
# CVE-2014-3429 - RCE via unchecked cross-origin websocket connections
Patch1:         CVE-2014-3429-cross-domain.patch
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:  gnome-icon-theme
BuildRequires:  python
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
BuildRequires:  python-setuptools
BuildRequires:  python-wxWidgets
%if 0%{?suse_version}
%py_requires
BuildRequires:  fdupes
BuildRequires:  update-desktop-files
%endif
Requires:       gnome-icon-theme
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
Requires:       python-Pygments
Requires:       python-matplotlib
Requires:       python-qt4
# html notebook
BuildRequires:  python-tornado >= 2.0
Requires:       python-tornado >= 2.0
#documentation
BuildRequires:  graphviz
BuildRequires:  graphviz-gnome
BuildRequires:  python-Sphinx >= 0.3

%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}
%patch1 -p1

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

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

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

# move automatically installed documentation to the right directory
install -d -m 755 %{buildroot}%{_docdir}/
mv -f %{buildroot}/usr/share/doc/ipython/ %{buildroot}%{_docdir}/%{name}

# make docs
pushd docs
PYTHONPATH=$PYTHONPATH:%{buildroot}%{python_sitelib} make html
rm build/html/.buildinfo
mv build/html %{buildroot}%{_docdir}/%{name}/
popd

# set executable
chmod a+x %{buildroot}%{python_sitelib}/%{name}/html/static/components/less.js/bin/lessc
chmod a+x %{buildroot}%{python_sitelib}/%{name}/external/mathjax.py
chmod a+x %{buildroot}%{python_sitelib}/%{name}/html/static/components/marked/bin/marked

# 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
mv examples/core/*.desktop ./
sed -i 's/gnome-netstatus-idle/ipython/g' *.desktop
%suse_update_desktop_file -r -i ipython System TerminalEmulator
%suse_update_desktop_file -r -i ipython-qtconsole System TerminalEmulator

# install icons
for i in %{_datadir}/icons/gnome/*/status/gnome-netstatus-idle.*
do
    NUM="$(basename $(dirname $(dirname $i)))"
    mkdir -p "%{buildroot}%{_datadir}/icons/hicolor/$NUM/apps/"
    pushd "%{buildroot}%{_datadir}/icons/hicolor/$NUM/apps/"
    ln -s "$i" ./ipython.png
    popd
done

%files
%defattr(-,root,root)
%doc COPYING.txt README.rst
%{_bindir}/ipcluster
%{_bindir}/ipcontroller
%{_bindir}/ipengine
%{_bindir}/iplogger
%{_bindir}/iptest
%{_bindir}/ipython
%{_bindir}/irunner
%{_bindir}/pycolor
%{_mandir}/man1/ipcluster.1.gz
%{_mandir}/man1/ipcontroller.1.gz
%{_mandir}/man1/ipengine.1.gz
%{_mandir}/man1/iplogger.1.gz
%{_mandir}/man1/ipython.1.gz
%{_mandir}/man1/irunner.1.gz
%{_mandir}/man1/pycolor.1.gz
%{_datadir}/applications/ipython-qtconsole.desktop
%{_datadir}/applications/ipython.desktop
%{_datadir}/icons/hicolor/
%{python_sitelib}/%{name}
%{python_sitelib}/ipython-%{version}-py*.egg-info
%exclude %{_docdir}/%{name}/html/
%if 0%{?suse_version} > 1220
%exclude %{_docdir}/%{name}/examples/
%endif

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

%changelog
openSUSE Build Service is sponsored by