/
requirements.py
73 lines (62 loc) · 2.62 KB
/
requirements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
# (see spyder/__init__.py for details)
"""Module checking Spyder installation requirements"""
# Standard library imports
import sys
import os.path as osp
# Third-party imports
from pkg_resources import parse_version
def show_warning(message):
"""Show warning using Tkinter if available"""
try:
# If Tkinter is installed (highly probable), showing an error pop-up
import Tkinter, tkMessageBox
root = Tkinter.Tk()
root.withdraw()
tkMessageBox.showerror("Spyder", message)
except ImportError:
pass
raise RuntimeError(message)
def check_path():
"""Check sys.path: is Spyder properly installed?"""
dirname = osp.abspath(osp.join(osp.dirname(__file__), osp.pardir))
if dirname not in sys.path:
show_warning("Spyder must be installed properly "
"(e.g. from source: 'python setup.py install'),\n"
"or directory '%s' must be in PYTHONPATH "
"environment variable." % dirname)
def check_qt():
"""Check Qt binding requirements"""
qt_infos = dict(pyqt5=("PyQt5", "5.6"))
try:
import qtpy
package_name, required_ver = qt_infos[qtpy.API]
actual_ver = qtpy.PYQT_VERSION
if parse_version(actual_ver) < parse_version(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"%s %s+ is required (found v%s)."
% (package_name, required_ver, actual_ver))
except ImportError:
show_warning("Failed to import qtpy.\n"
"Please check Spyder installation requirements:\n\n"
"qtpy 1.2.0+ and\n"
"%s %s+\n\n"
"are required to run Spyder."
% (qt_infos['pyqt5']))
def check_spyder_kernels():
"""Check spyder-kernel requirement."""
try:
import spyder_kernels
required_ver = '2.0.0'
actual_ver = spyder_kernels.__version__
if parse_version(actual_ver) < parse_version(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"spyder-kernels >= 2.0 is required (found %s)."
% actual_ver)
except ImportError:
show_warning("Failed to import spyder-kernels.\n"
"Please check Spyder installation requirements:\n\n"
"spyder-kernels >= 2.0 is required")