##// END OF EJS Templates
add check_version utility...
MinRK -
Show More
@@ -7,7 +7,7 b' Do not use this if you need PyQt with the old QString/QVariant API.'
7 7 """
8 8
9 9 import os
10 from IPython.utils.version import NumericalVersion as V
10 from IPython.utils.version import check_version
11 11 # Available APIs.
12 12 QT_API_PYQT = 'pyqt'
13 13 QT_API_PYSIDE = 'pyside'
@@ -26,7 +26,7 b' if QT_API is None:'
26 26 pyside_found = False
27 27 try:
28 28 import PySide
29 if V(PySide.__version__) < V('1.0.3'):
29 if not check_version(PySide.__version__, '1.0.3'):
30 30 # old PySide, fallback on PyQt
31 31 raise ImportError
32 32 # we can't import an incomplete pyside and pyqt4
@@ -49,7 +49,7 b' if QT_API is None:'
49 49 "present.\nThis will likely crash, please install " \
50 50 "PySide completely, remove PySide or PyQt4 or set " \
51 51 "the QT_API environment variable to pyqt or pyside"
52 if V(QtCore.PYQT_VERSION_STR) < V('4.7'):
52 if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
53 53 # PyQt 4.6 has issues with null strings returning as None
54 54 raise ImportError
55 55 QT_API = QT_API_PYQT
@@ -63,7 +63,7 b' elif QT_API == QT_API_PYQT:'
63 63 # Now peform the imports.
64 64 if QT_API == QT_API_PYQT:
65 65 from PyQt4 import QtCore, QtGui, QtSvg
66 if V(QtCore.PYQT_VERSION_STR) < V('4.7'):
66 if not check_version(QtCore.PYQT_VERSION_STR, '4.7'):
67 67 raise ImportError("IPython requires PyQt4 >= 4.7, found %s"%QtCore.PYQT_VERSION_STR)
68 68
69 69 # Alias PyQt-specific functions for PySide compatibility.
@@ -72,7 +72,7 b' if QT_API == QT_API_PYQT:'
72 72
73 73 elif QT_API == QT_API_PYSIDE:
74 74 import PySide
75 if V(PySide.__version__) < V('1.0.3'):
75 if not check_version(PySide.__version__, '1.0.3'):
76 76 raise ImportError("IPython requires PySide >= 1.0.3, found %s"%PySide.__version__)
77 77 from PySide import QtCore, QtGui, QtSvg
78 78
@@ -32,10 +32,10 b' import os'
32 32 import sys
33 33
34 34 from IPython.utils.warn import warn
35 from IPython.utils.version import NumericalVersion as V
35 from IPython.utils.version import check_version
36 36
37 37 matplotlib = sys.modules.get('matplotlib')
38 if matplotlib and V(matplotlib.__version__) <= V('1.0.1'):
38 if matplotlib and not check_version(matplotlib.__version__, '1.0.2'):
39 39 # 1.0.1 doesn't support pyside or v2, so stick with PyQt @v1,
40 40 # and ignore everything else
41 41 from PyQt4 import QtCore, QtGui
@@ -54,3 +54,16 b' def version_tuple(vs):'
54 54 """
55 55 return tuple(NumericalVersion(vs).version)
56 56
57 #
58 def check_version(v, check):
59 """check version string v >= check
60
61 If dev/prerelease tags result in TypeError for string-number comparison,
62 it is assumed that the dependency is satisfied.
63 Users on dev branches are responsible for keeping their own packages up to date.
64 """
65 try:
66 return LooseVersion(v) >= LooseVersion(check)
67 except TypeError:
68 return True
69 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now