Show More
@@ -0,0 +1,35 b'' | |||||
|
1 | # encoding: utf-8 | |||
|
2 | """ | |||
|
3 | Utilities for version comparison | |||
|
4 | ||||
|
5 | It is a bit ridiculous that we need these. | |||
|
6 | """ | |||
|
7 | ||||
|
8 | #----------------------------------------------------------------------------- | |||
|
9 | # Copyright (C) 2013 The IPython Development Team | |||
|
10 | # | |||
|
11 | # Distributed under the terms of the BSD License. The full license is in | |||
|
12 | # the file COPYING, distributed as part of this software. | |||
|
13 | #----------------------------------------------------------------------------- | |||
|
14 | ||||
|
15 | #----------------------------------------------------------------------------- | |||
|
16 | # Imports | |||
|
17 | #----------------------------------------------------------------------------- | |||
|
18 | ||||
|
19 | from distutils.version import LooseVersion | |||
|
20 | ||||
|
21 | #----------------------------------------------------------------------------- | |||
|
22 | # Code | |||
|
23 | #----------------------------------------------------------------------------- | |||
|
24 | ||||
|
25 | def check_version(v, check): | |||
|
26 | """check version string v >= check | |||
|
27 | ||||
|
28 | If dev/prerelease tags result in TypeError for string-number comparison, | |||
|
29 | it is assumed that the dependency is satisfied. | |||
|
30 | Users on dev branches are responsible for keeping their own packages up to date. | |||
|
31 | """ | |||
|
32 | try: | |||
|
33 | return LooseVersion(v) >= LooseVersion(check) | |||
|
34 | except TypeError: | |||
|
35 | return True |
@@ -7,7 +7,7 b' Do not use this if you need PyQt with the old QString/QVariant API.' | |||||
7 | """ |
|
7 | """ | |
8 |
|
8 | |||
9 | import os |
|
9 | import os | |
10 |
|
10 | from IPython.utils.version import check_version | ||
11 | # Available APIs. |
|
11 | # Available APIs. | |
12 | QT_API_PYQT = 'pyqt' |
|
12 | QT_API_PYQT = 'pyqt' | |
13 | QT_API_PYSIDE = 'pyside' |
|
13 | QT_API_PYSIDE = 'pyside' | |
@@ -26,7 +26,7 b' if QT_API is None:' | |||||
26 | pyside_found = False |
|
26 | pyside_found = False | |
27 | try: |
|
27 | try: | |
28 | import PySide |
|
28 | import PySide | |
29 |
if PySide.__version__ |
|
29 | if not check_version(PySide.__version__, '1.0.3'): | |
30 | # old PySide, fallback on PyQt |
|
30 | # old PySide, fallback on PyQt | |
31 | raise ImportError |
|
31 | raise ImportError | |
32 | # we can't import an incomplete pyside and pyqt4 |
|
32 | # we can't import an incomplete pyside and pyqt4 | |
@@ -49,7 +49,7 b' if QT_API is None:' | |||||
49 | "present.\nThis will likely crash, please install " \ |
|
49 | "present.\nThis will likely crash, please install " \ | |
50 | "PySide completely, remove PySide or PyQt4 or set " \ |
|
50 | "PySide completely, remove PySide or PyQt4 or set " \ | |
51 | "the QT_API environment variable to pyqt or pyside" |
|
51 | "the QT_API environment variable to pyqt or pyside" | |
52 |
if QtCore.PYQT_VERSION_STR |
|
52 | if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): | |
53 | # PyQt 4.6 has issues with null strings returning as None |
|
53 | # PyQt 4.6 has issues with null strings returning as None | |
54 | raise ImportError |
|
54 | raise ImportError | |
55 | QT_API = QT_API_PYQT |
|
55 | QT_API = QT_API_PYQT | |
@@ -63,7 +63,7 b' elif QT_API == QT_API_PYQT:' | |||||
63 | # Now peform the imports. |
|
63 | # Now peform the imports. | |
64 | if QT_API == QT_API_PYQT: |
|
64 | if QT_API == QT_API_PYQT: | |
65 | from PyQt4 import QtCore, QtGui, QtSvg |
|
65 | from PyQt4 import QtCore, QtGui, QtSvg | |
66 |
if QtCore.PYQT_VERSION_STR |
|
66 | if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): | |
67 | raise ImportError("IPython requires PyQt4 >= 4.7, found %s"%QtCore.PYQT_VERSION_STR) |
|
67 | raise ImportError("IPython requires PyQt4 >= 4.7, found %s"%QtCore.PYQT_VERSION_STR) | |
68 |
|
68 | |||
69 | # Alias PyQt-specific functions for PySide compatibility. |
|
69 | # Alias PyQt-specific functions for PySide compatibility. | |
@@ -72,7 +72,7 b' if QT_API == QT_API_PYQT:' | |||||
72 |
|
72 | |||
73 | elif QT_API == QT_API_PYSIDE: |
|
73 | elif QT_API == QT_API_PYSIDE: | |
74 | import PySide |
|
74 | import PySide | |
75 |
if PySide.__version__ |
|
75 | if not check_version(PySide.__version__, '1.0.3'): | |
76 | raise ImportError("IPython requires PySide >= 1.0.3, found %s"%PySide.__version__) |
|
76 | raise ImportError("IPython requires PySide >= 1.0.3, found %s"%PySide.__version__) | |
77 | from PySide import QtCore, QtGui, QtSvg |
|
77 | from PySide import QtCore, QtGui, QtSvg | |
78 |
|
78 |
@@ -32,9 +32,10 b' import os' | |||||
32 | import sys |
|
32 | import sys | |
33 |
|
33 | |||
34 | from IPython.utils.warn import warn |
|
34 | from IPython.utils.warn import warn | |
|
35 | from IPython.utils.version import check_version | |||
35 |
|
36 | |||
36 | matplotlib = sys.modules.get('matplotlib') |
|
37 | matplotlib = sys.modules.get('matplotlib') | |
37 |
if matplotlib and matplotlib.__version__ |
|
38 | if matplotlib and not check_version(matplotlib.__version__, '1.0.2'): | |
38 | # 1.0.1 doesn't support pyside or v2, so stick with PyQt @v1, |
|
39 | # 1.0.1 doesn't support pyside or v2, so stick with PyQt @v1, | |
39 | # and ignore everything else |
|
40 | # and ignore everything else | |
40 | from PyQt4 import QtCore, QtGui |
|
41 | from PyQt4 import QtCore, QtGui |
General Comments 0
You need to be logged in to leave comments.
Login now