diff --git a/spyderlib/__init__.py b/spyderlib/__init__.py index 4a1ed6961d7..0f0cc792f74 100644 --- a/spyderlib/__init__.py +++ b/spyderlib/__init__.py @@ -61,11 +61,6 @@ def get_versions(reporev=True): """Get version information for components used by Spyder""" import sys import platform - # Hack to let IPython set QT_API, in case it's installed - try: - from IPython.external import qt - except ImportError: - pass import spyderlib.qt import spyderlib.qt.QtCore diff --git a/spyderlib/ipythonconfig.py b/spyderlib/ipythonconfig.py index ef177145520..75875f93f72 100644 --- a/spyderlib/ipythonconfig.py +++ b/spyderlib/ipythonconfig.py @@ -9,10 +9,19 @@ """ from spyderlib.utils import programs +from spyderlib import dependencies +from spyderlib.baseconfig import _ +IPYTHON_REQVER = '>=0.13' +ZMQ_REQVER = '>=2.1.11' + +dependencies.add("IPython", _("IPython Console integration"), + required_version=IPYTHON_REQVER) +dependencies.add("zmq", _("IPython Console integration"), + required_version=ZMQ_REQVER) def is_qtconsole_installed(): - pyzmq_installed = programs.is_module_installed('zmq') + pyzmq_installed = programs.is_module_installed('zmq', version=ZMQ_REQVER) if programs.is_module_installed('IPython.qt') and pyzmq_installed: return True elif programs.is_module_installed('IPython.frontend.qt') and \ @@ -21,5 +30,4 @@ def is_qtconsole_installed(): else: return False -SUPPORTED_IPYTHON = '>=0.13' IPYTHON_QT_INSTALLED = is_qtconsole_installed() diff --git a/spyderlib/qt/__init__.py b/spyderlib/qt/__init__.py index 8c8a6bed8ce..6c71c1f4931 100644 --- a/spyderlib/qt/__init__.py +++ b/spyderlib/qt/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright © 2011 Pierre Raybaut +# Copyright © 2011-2012 Pierre Raybaut +# © 2012-2014 anatoly techtonik # Licensed under the terms of the MIT License # (see spyderlib/__init__.py for details) @@ -15,16 +16,18 @@ API_NAME = {'pyqt': 'PyQt4', 'pyside': 'PySide'}[API] if API == 'pyqt': - # We do not force QString, QVariant, ... API to #1 or #2 anymore - # as spyderlib is now compatible with both APIs -# import sip -# try: -# sip.setapi('QString', 2) -# sip.setapi('QVariant', 2) -# except AttributeError: -# # PyQt < v4.6: in future version, we should warn the user -# # that PyQt is outdated and won't be supported by Spyder >v2.1 -# pass + # Spyder 2.3 is compatible with both #1 and #2 PyQt API, + # but to avoid issues with IPython and other Qt plugins + # we choose to support only API #2 for 2.4+ + import sip + try: + sip.setapi('QString', 2) + sip.setapi('QVariant', 2) + except AttributeError: + # PyQt < v4.6. The actual check is done by requirements.check_qt() + # call from spyder.py + pass + try: from PyQt4.QtCore import PYQT_VERSION_STR as __version__ except ImportError: @@ -32,7 +35,6 @@ API = os.environ['QT_API'] = 'pyside' API_NAME = 'PySide' else: - __version_info__ = tuple(__version__.split('.')+['final', 1]) is_old_pyqt = __version__.startswith(('4.4', '4.5', '4.6', '4.7')) is_pyqt46 = __version__.startswith('4.6') import sip diff --git a/spyderlib/spyder.py b/spyderlib/spyder.py index 9ee58958b66..ff7da04323d 100644 --- a/spyderlib/spyder.py +++ b/spyderlib/spyder.py @@ -38,35 +38,6 @@ ORIGINAL_SYS_EXIT = sys.exit -#============================================================================== -# Test if IPython v0.13+ is installed to eventually switch to PyQt API #2 -#============================================================================== -from spyderlib.baseconfig import _ -from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED, SUPPORTED_IPYTHON -from spyderlib import dependencies - -dependencies.add("IPython", _("IPython Console integration"), - required_version=SUPPORTED_IPYTHON) -dependencies.add("zmq", _("IPython Console integration"), - required_version='>=2.1.11') - -if IPYTHON_QT_INSTALLED: - # Importing IPython will eventually set the QT_API environment variable - import IPython # analysis:ignore - if os.environ.get('QT_API', 'pyqt') == 'pyqt': - # If PyQt is the selected GUI toolkit (at this stage, only the - # bootstrap script has eventually set this option), switch to - # PyQt API #2 by simply importing the IPython qt module - os.environ['QT_API'] = 'pyqt' - try: - from IPython.external import qt #analysis:ignore - except ImportError: - # Avoid raising any error here: the spyderlib.requirements module - # will take care of it, in a user-friendly way (Tkinter message box - # if no GUI toolkit is installed) - pass - - #============================================================================== # Check requirements #============================================================================== @@ -76,7 +47,7 @@ #============================================================================== -# Windows platforms only: support for hiding the attached console window +# Windows only: support for hiding console window when started with python.exe #============================================================================== set_attached_console_visible = None is_attached_console_visible = None @@ -116,9 +87,7 @@ #============================================================================== -# Initial splash screen to reduce perceived startup time. -# It blends with the one of MainWindow (i.e. self.splash) and it's hidden -# just before that one. +# Splash screen #============================================================================== from spyderlib.baseconfig import _, get_image_path SPLASH_APP = QApplication(['']) @@ -142,6 +111,8 @@ running_in_mac_app) from spyderlib.config import CONF, EDIT_EXT, IMPORT_EXT, OPEN_FILES_PORT from spyderlib.cli_options import get_options +from spyderlib import dependencies +from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED from spyderlib.userconfig import NoDefault from spyderlib.utils import encoding, programs from spyderlib.utils.iofuncs import load_session, save_session, reset_session