Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to use Jupyter imports and remove support for IPython 3 #2913

Merged
merged 7 commits into from
Jan 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ a Python version greater than 2.7 (Python 3.2 is not supported anymore).

* **Python** 2.7 or 3.3+
* **PyQt5** 5.2+ or **PyQt4** 4.6+: PyQt5 is recommended.
* **IPython** 3.0 or **qtconsole**: Enhanced Python interpreter.
* **qtconsole**: Enhanced Python interpreter.
* **Rope** and/or **Jedi** 0.8.1: Editor code completion, calltips
and go-to-definition.
* **Pyflakes**: Real-time code analysis.
Expand Down
11 changes: 2 additions & 9 deletions doc/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,9 @@ Recommended modules

We recommend you to install these modules to get the most out of Spyder:

* `IPython <http://ipython.org/install.html#downloads>`_ 3.0 or less, or
`qtconsole <http://jupyter.org/qtconsole/stable/>`_ 4.0 or higher -- for an
* `qtconsole <http://jupyter.org/qtconsole/stable/>`_ 4.0 or higher -- for an
enhanced Python interpreter.

.. note::

- On *Ubuntu* you need to install ``ipython-qtconsole``.
- On *Fedora*, ``ipython-gui``
- And on *Gentoo* ``ipython`` with the ``qt4`` USE flag


* `sphinx <http://sphinx.pocoo.org>`_ >= v0.6 -- for the Help pane rich
text mode and to get our documentation.

Expand Down
35 changes: 11 additions & 24 deletions spyderlib/config/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,30 @@


# Constants
IPYTHON_REQVER = '>=3.0'
ZMQ_REQVER = '>=13.0.0'
QTCONSOLE_REQVER = '>=4.0'
ZMQ_REQVER = ">=13.0.0"
NBCONVERT_REQVER = ">=4.0"


# Dependencies
dependencies.add("IPython", _("IPython Console integration"),
required_version=IPYTHON_REQVER)
dependencies.add("zmq", _("IPython Console integration"),
required_version=ZMQ_REQVER)


# Jupyter 4.0 requirements
ipy4_installed = programs.is_module_installed('IPython', '>=4.0')
if ipy4_installed:
dependencies.add("qtconsole", _("IPython Console integration"),
required_version=QTCONSOLE_REQVER)
dependencies.add("qtconsole", _("Jupyter Qtconsole integration"),
required_version=QTCONSOLE_REQVER)
dependencies.add("nbconvert", _("Manipulate Jupyter notebooks on the Editor"),
required_version=NBCONVERT_REQVER)


# Auxiliary functions
def is_qtconsole_installed():
ipyqt_installed = programs.is_module_installed('IPython.qt',
version=IPYTHON_REQVER)
pyzmq_installed = programs.is_module_installed('zmq', version=ZMQ_REQVER)
pygments_installed = programs.is_module_installed('pygments')
qtconsole_installed = programs.is_module_installed('qtconsole',
version=QTCONSOLE_REQVER)

if ipyqt_installed and pyzmq_installed and pygments_installed:
if ipy4_installed:
if programs.is_module_installed('qtconsole'):
return True
else:
return False
else:
return True
if pyzmq_installed and pygments_installed and qtconsole_installed:
return True
else:
return False


# Main check for IPython presence
IPYTHON_QT_INSTALLED = is_qtconsole_installed()
QTCONSOLE_INSTALLED = is_qtconsole_installed()
6 changes: 3 additions & 3 deletions spyderlib/plugins/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Local imports
from spyderlib import dependencies
from spyderlib.config.base import get_conf_path, get_module_source_path, _
from spyderlib.config.ipython import IPYTHON_QT_INSTALLED
from spyderlib.config.ipython import QTCONSOLE_INSTALLED
from spyderlib.config.main import CONF
from spyderlib.config.gui import get_color_scheme, get_font, set_font
from spyderlib.utils import programs
Expand All @@ -39,7 +39,7 @@

#XXX: Hardcoded dependency on optional IPython plugin component
# that requires the hack to make this work without IPython
if IPYTHON_QT_INSTALLED:
if QTCONSOLE_INSTALLED:
from spyderlib.widgets.ipython import IPythonControlWidget
else:
IPythonControlWidget = None # analysis:ignore
Expand Down Expand Up @@ -145,7 +145,7 @@ def setup_page(self):
'connect/python_console')
ipython_box = self.create_checkbox(_("IPython Console"),
'connect/ipython_console')
ipython_box.setEnabled(IPYTHON_QT_INSTALLED)
ipython_box.setEnabled(QTCONSOLE_INSTALLED)

connections_layout = QVBoxLayout()
connections_layout.addWidget(connections_label)
Expand Down
6 changes: 3 additions & 3 deletions spyderlib/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
from spyderlib.qt.QtCore import Signal, Slot, Qt
import spyderlib.utils.icon_manager as ima

# IPython imports
# IPython/Jupyter imports
from IPython.core.application import get_ipython_dir
from IPython.kernel.connect import find_connection_file
from IPython.qt.manager import QtKernelManager
from jupyter_client.connect import find_connection_file
from qtconsole.manager import QtKernelManager

# Ssh imports
from zmq.ssh import tunnel as zmqtunnel
Expand Down
16 changes: 2 additions & 14 deletions spyderlib/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,6 @@
pass


#==============================================================================
# Don't show IPython ShimWarning's to our users
# TODO: Move to Jupyter imports in 3.1
#==============================================================================
try:
import warnings
from IPython.utils.shimmodule import ShimWarning
warnings.simplefilter('ignore', ShimWarning)
except:
pass


#==============================================================================
# Qt imports
#==============================================================================
Expand Down Expand Up @@ -138,7 +126,7 @@
is_gtk_desktop)
from spyderlib.cli_options import get_options
from spyderlib import dependencies
from spyderlib.config.ipython import IPYTHON_QT_INSTALLED
from spyderlib.config.ipython import QTCONSOLE_INSTALLED
from spyderlib.config.user import NoDefault
from spyderlib.utils import encoding, programs
from spyderlib.utils.iofuncs import load_session, save_session, reset_session
Expand Down Expand Up @@ -920,7 +908,7 @@ def create_edit_action(text, tr_text, icon):
self.variableexplorer.register_plugin()

# IPython console
if IPYTHON_QT_INSTALLED:
if QTCONSOLE_INSTALLED:
self.set_splash(_("Loading IPython console..."))
from spyderlib.plugins.ipythonconsole import IPythonConsole
self.ipyconsole = IPythonConsole(self)
Expand Down
4 changes: 2 additions & 2 deletions spyderlib/widgets/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
str_lower)

try:
from IPython.nbconvert import PythonExporter as nbexporter
from nbconvert import PythonExporter as nbexporter
except:
nbexporter = None # analysis:ignore
nbexporter = None # analysis:ignore


def fixpath(path):
Expand Down
14 changes: 3 additions & 11 deletions spyderlib/widgets/externalshell/start_ipython_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
import sys
import os.path as osp

# TODO: Move to Jupyter imports in 3.1
try:
import warnings
from IPython.utils.shimmodule import ShimWarning
warnings.simplefilter('ignore', ShimWarning)
except:
pass


def sympy_config(mpl_backend):
"""Sympy configuration"""
Expand All @@ -40,11 +32,11 @@ def kernel_config():
"""Create a config object with IPython kernel options"""
import os

from IPython.config.loader import Config, load_pyconfig_files
from IPython.core.application import get_ipython_dir
from spyderlib.config.main import CONF
from spyderlib.utils.programs import is_module_installed

from traitlets.config.loader import Config, load_pyconfig_files

# ---- IPython config ----
try:
profile_path = osp.join(get_ipython_dir(), 'profile_default')
Expand Down Expand Up @@ -192,7 +184,7 @@ def varexp(line):
sys.path.insert(0, '')

# Fire up the kernel instance.
from IPython.kernel.zmq.kernelapp import IPKernelApp
from ipykernel.kernelapp import IPKernelApp
ipk_temp = IPKernelApp.instance()
ipk_temp.config = kernel_config()
ipk_temp.initialize()
Expand Down
13 changes: 5 additions & 8 deletions spyderlib/widgets/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@
from spyderlib.qt.QtCore import Signal, Slot, Qt
import spyderlib.utils.icon_manager as ima

# IPython imports
try:
from qtconsole.rich_jupyter_widget import RichJupyterWidget as RichIPythonWidget
except ImportError:
from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
from IPython.qt.console.ansi_code_processor import ANSI_OR_SPECIAL_PATTERN
# IPython/Jupyter imports
from IPython.core.application import get_ipython_dir
from IPython.core.oinspect import call_tip
from IPython.config.loader import Config, load_pyconfig_files
from qtconsole.rich_jupyter_widget import RichJupyterWidget
from qtconsole.ansi_code_processor import ANSI_OR_SPECIAL_PATTERN
from traitlets.config.loader import Config, load_pyconfig_files

# Local imports
from spyderlib.config.base import (get_conf_path, get_image_path,
Expand Down Expand Up @@ -167,7 +164,7 @@ def focusOutEvent(self, event):
#-----------------------------------------------------------------------------
# Shell widget
#-----------------------------------------------------------------------------
class IPythonShellWidget(RichIPythonWidget):
class IPythonShellWidget(RichJupyterWidget):
"""
Spyder's IPython shell widget

Expand Down
12 changes: 4 additions & 8 deletions spyderlib/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@
from spyderlib.py3compat import to_text_string

try:
try: # Ipython 4
import nbformat as nbformat
from nbconvert import PythonExporter as nbexporter
except ImportError: # Ipython 3
import IPython.nbformat as nbformat
from IPython.nbconvert import PythonExporter as nbexporter
except ImportError:
nbformat = None # analysis:ignore
import nbformat as nbformat
from nbconvert import PythonExporter as nbexporter
except:
nbformat = None # analysis:ignore

# %% This line is for cell execution testing
# For debugging purpose:
Expand Down