Backport patch so the console doesn't require matplotlib

This commit is contained in:
Thomas Spura 2013-02-21 09:17:19 +01:00
parent 0ba34b7a71
commit ef9e54c818
2 changed files with 54 additions and 6 deletions

View File

@ -0,0 +1,42 @@
commit b5d39276af0e3ed80a8565d567a00b02fdafedfb
Author: Thomas Spura <thomas.spura@gmail.com>
Date: Fri Dec 14 13:46:18 2012 +0100
Don't enable pylab mode, when matplotlib is not importable
On a headless server, matplotlib is a unnecessary dependency and the ipython
console will crash badly, when tring to enable %pylab there.
In that case, just don't enable %pylab and ask the user to install matplotlib.
Original bug report: https://bugzilla.redhat.com/show_bug.cgi?id=872176
diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py
index d87fcb7..f39ba6a 100644
--- a/IPython/core/interactiveshell.py
+++ b/IPython/core/interactiveshell.py
@@ -2864,6 +2864,10 @@ def enable_pylab(self, gui=None, import_all=True, welcome_message=False):
except KeyError:
error("Backend %r not supported" % gui)
return
+ except ImportError:
+ error("pylab mode doesn't work as matplotlib could not be found." + \
+ "\nIs it installed on the system?")
+ return
self.user_ns.update(ns)
self.user_ns_hidden.update(ns)
# Now we must activate the gui pylab wants to use, and fix %run to take
diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py
index d451d7c..4539c06 100644
--- a/IPython/core/shellapp.py
+++ b/IPython/core/shellapp.py
@@ -203,6 +203,10 @@ def init_gui_pylab(self):
self.log.info("Enabling GUI event loop integration, "
"toolkit=%s" % self.gui)
shell.enable_gui(self.gui)
+ except ImportError:
+ self.log.warn("pylab mode doesn't work as matplotlib could not be found." + \
+ "\nIs it installed on the system?")
+ self.shell.showtraceback()
except Exception:
self.log.warn("GUI event loop or pylab initialization failed")
self.shell.showtraceback()

View File

@ -16,7 +16,7 @@
Name: ipython
Version: 0.13.1
Release: 2%{?dist}
Release: 3%{?dist}
Summary: An enhanced interactive Python shell
Group: Development/Libraries
@ -26,6 +26,9 @@ Group: Development/Libraries
License: (BSD and MIT and Python) and GPLv2+
URL: http://ipython.org/
Source0: http://archive.ipython.org/release/%{version}/%{name}-%{version}.tar.gz
# will be in ipython-0.14
# https://github.com/ipython/ipython/pull/2681
Patch0: ipython-0.13.1-dont-require-matplotlib.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -111,8 +114,6 @@ Obsoletes: ipython < 0.13-1
Summary: An enhanced interactive Python shell
Requires: python-zmq
#IPython/lib/latextools.py and others in /lib/
Requires: python-matplotlib
#bundled libs
Requires: pexpect
@ -127,6 +128,7 @@ Requires: python-simplegeneric
Summary: An enhanced interactive Python shell
Requires: python-ipython-console = %{version}-%{release}
Requires: python-tornado
Requires: python-matplotlib
Provides: ipython-notebook = %{version}-%{release}
%description -n python-ipython-notebook
@ -161,6 +163,7 @@ Summary: Gui applications from %{name}
Group: Applications/Editors
Requires: python-ipython-console = %{version}-%{release}
Requires: PyQt4
Requires: python-matplotlib
Requires: python-pygments
Provides: ipython-gui = %{version}-%{release}
Obsoletes: ipython-gui < 0.13-1
@ -209,6 +212,8 @@ This package contains the gui of %{name}, which requires PyQt.
%prep
%setup -q
%patch0 -p 1
# delete bundling libs
pushd IPython/external
# python's own modules
@ -441,12 +446,13 @@ PYTHONPATH=%{buildroot}%{python_sitelib} \
%endif # with_python3
%changelog
* Thu Feb 21 2013 Thomas Spura <tomspur@fedoraproject.org> - 0.13.1-3
- obsolete old ipython packages (José Matos, #882724)
- notebook and gui subpackage require matplotlib not the console anymore (#872176)
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.13.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Wed Dec 12 2012 Thomas Spura <tomspur@fedoraproject.org> - 0.13.1-2
- obsolete old ipython packages (José Matos, #882724)
* Wed Oct 24 2012 Thomas Spura <tomspur@fedoraproject.org> - 0.13.1-1
- update to 0.13.1 (#838031)
- run tests with en_US.UTF-8