~ubuntu-branches/ubuntu/trusty/spyder/trusty-proposed

« back to all changes in this revision

Viewing changes to spyderlib/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Aubry
  • Date: 2010-06-28 23:43:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100628234302-3xnz0gcu0w83282r
Tags: 1.1.1-1
* New upstream release
* New maintainer address (Closes: #586833)
* Build with python 2.6 (Closes: #586824)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
OTHER DEALINGS IN THE SOFTWARE.
28
28
"""
29
29
 
30
 
__version__ = '1.0.3'
 
30
__version__ = '1.1.1'
31
31
__license__ = __doc__
32
 
 
33
 
def check_requirement(package, module_name, version_attr, required_str):
34
 
    wng = "\n%s v%s or higher is required" % (package, required_str)
35
 
    try:
36
 
        module = __import__(module_name)
37
 
    except ImportError:
38
 
        return wng+" (not found!)"
39
 
    else:
40
 
        if module_name.find('.'):
41
 
            module = getattr(module, module_name.split('.')[1])
42
 
        actual_str = getattr(module, version_attr)
43
 
        actual = actual_str.split('.')
44
 
        required = required_str.split('.')
45
 
        if actual[0] < required[0] or \
46
 
           (actual[0] == required[0] and actual[1] < required[1]):
47
 
            return wng+" (found v%s)" % actual_str
48
 
        else:
49
 
            return ''
50
 
 
51
 
def check_pyqt_qscintilla():
52
 
    wng = check_requirement("PyQt", "PyQt4.QtCore", "PYQT_VERSION_STR", "4.4")
53
 
    wng += check_requirement("QScintilla", "PyQt4.Qsci",
54
 
                             "QSCINTILLA_VERSION_STR", "2.2")
55
 
    if wng:
56
 
        import os
57
 
        message = "Please check Spyder installation requirements:"+wng
58
 
        if os.name == 'nt':
59
 
            message += """
60
 
    
61
 
Windows XP/Vista/7 users:
62
 
QScintilla2 is distributed together with PyQt4
63
 
(Python(x,y) plugin or official PyQt4 Windows installer)"""
64
 
        try:
65
 
            # If Tkinter is installed (highly probable), showing an error pop-up
66
 
            import Tkinter, tkMessageBox
67
 
            root = Tkinter.Tk()
68
 
            root.withdraw()
69
 
            tkMessageBox.showerror("Spyder", message)
70
 
        except ImportError:
71
 
            pass
72
 
        raise ImportError, wng
73
 
 
74
 
check_pyqt_qscintilla()