1 | """ |
---|
2 | Checking and reinstalling the external packages |
---|
3 | """ |
---|
4 | from __future__ import print_function |
---|
5 | |
---|
6 | import sys |
---|
7 | |
---|
8 | # Fix for error: hash-collision-3-both-1-and-1/ |
---|
9 | # See http://jaredforsyth.com/blog/2010/apr/28/accessinit-hash-collision-3-both-1-and-1/ |
---|
10 | try: |
---|
11 | import PIL.Image |
---|
12 | except ImportError: |
---|
13 | pass |
---|
14 | else: |
---|
15 | sys.modules['Image'] = PIL.Image |
---|
16 | |
---|
17 | if sys.version_info[0] > 2: |
---|
18 | print("To use the sasview GUI you must use Python 2\n") |
---|
19 | |
---|
20 | common_required_package_list = { |
---|
21 | 'setuptools': {'version': '0.6c11', 'import_name': 'setuptools', 'test': '__version__'}, |
---|
22 | 'pyparsing': {'version': '1.5.5', 'import_name': 'pyparsing', 'test': '__version__'}, |
---|
23 | 'html5lib': {'version': '0.95', 'import_name': 'html5lib', 'test': '__version__'}, |
---|
24 | 'reportlab': {'version': '2.5', 'import_name': 'reportlab', 'test': 'Version'}, |
---|
25 | 'h5py': {'version': '2.5', 'import_name': 'h5py', 'test': '__version__'}, |
---|
26 | 'lxml': {'version': '2.3', 'import_name': 'lxml.etree', 'test': 'LXML_VERSION'}, |
---|
27 | 'PIL': {'version': '1.1.7', 'import_name': 'Image', 'test': 'VERSION'}, |
---|
28 | 'pylint': {'version': None, 'import_name': 'pylint', 'test': None}, |
---|
29 | 'periodictable': {'version': '1.3.0', 'import_name': 'periodictable', 'test': '__version__'}, |
---|
30 | 'bumps': {'version': '0.7.5.9', 'import_name': 'bumps', 'test': '__version__'}, |
---|
31 | 'numpy': {'version': '1.7.1', 'import_name': 'numpy', 'test': '__version__'}, |
---|
32 | 'scipy': {'version': '0.18.0', 'import_name': 'scipy', 'test': '__version__'}, |
---|
33 | 'wx': {'version': '2.8.12.1', 'import_name': 'wx', 'test': '__version__'}, |
---|
34 | 'matplotlib': {'version': '1.1.0', 'import_name': 'matplotlib', 'test': '__version__'}, |
---|
35 | 'xhtml2pdf': {'version': '3.0.33', 'import_name': 'xhtml2pdf', 'test': '__version__'}, |
---|
36 | 'sphinx': {'version': '1.2.1', 'import_name': 'sphinx', 'test': '__version__'}, |
---|
37 | 'unittest-xml-reporting': {'version': '1.10.0', 'import_name': 'xmlrunner', 'test': '__version__'}, |
---|
38 | 'pyopencl': {'version': '2015.1', 'import_name': 'pyopencl', 'test': 'VERSION_TEXT'}, |
---|
39 | } |
---|
40 | win_required_package_list = { |
---|
41 | 'comtypes': {'version': '0.6.2', 'import_name': 'comtypes', 'test': '__version__'}, |
---|
42 | 'pywin': {'version': '217', 'import_name': 'pywin', 'test': '__version__'}, |
---|
43 | 'py2exe': {'version': '0.6.9', 'import_name': 'py2exe', 'test': '__version__'}, |
---|
44 | } |
---|
45 | mac_required_package_list = { |
---|
46 | 'py2app': {'version': None, 'import_name': 'py2app', 'test': '__version__'}, |
---|
47 | } |
---|
48 | |
---|
49 | deprecated_package_list = { |
---|
50 | 'pyPdf': {'version': '1.13', 'import_name': 'pyPdf', 'test': '__version__'}, |
---|
51 | } |
---|
52 | |
---|
53 | print("Checking Required Package Versions....\n") |
---|
54 | print("Common Packages") |
---|
55 | |
---|
56 | for package_name, test_vals in common_required_package_list.items(): |
---|
57 | try: |
---|
58 | i = __import__(test_vals['import_name'], fromlist=['']) |
---|
59 | if test_vals['test'] is None: |
---|
60 | print("%s Installed (Unknown version)" % package_name) |
---|
61 | elif package_name == 'lxml': |
---|
62 | verstring = str(getattr(i, 'LXML_VERSION')) |
---|
63 | print("%s Version Installed: %s"% (package_name, verstring.replace(', ', '.').lstrip('(').rstrip(')'))) |
---|
64 | else: |
---|
65 | print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) |
---|
66 | except ImportError: |
---|
67 | print('%s NOT INSTALLED'% package_name) |
---|
68 | |
---|
69 | if sys.platform == 'win32': |
---|
70 | print("") |
---|
71 | print("Windows Specific Packages:") |
---|
72 | for package_name, test_vals in win_required_package_list.items(): |
---|
73 | try: |
---|
74 | i = __import__(test_vals['import_name'], fromlist=['']) |
---|
75 | print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test'], "unknown"))) |
---|
76 | except ImportError: |
---|
77 | print('%s NOT INSTALLED'% package_name) |
---|
78 | |
---|
79 | if sys.platform == 'darwin': |
---|
80 | print("") |
---|
81 | print("MacOS Specific Packages:") |
---|
82 | for package_name, test_vals in mac_required_package_list.items(): |
---|
83 | try: |
---|
84 | i = __import__(test_vals['import_name'], fromlist=['']) |
---|
85 | print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) |
---|
86 | except ImportError: |
---|
87 | print('%s NOT INSTALLED'% package_name) |
---|
88 | |
---|
89 | |
---|
90 | print("") |
---|
91 | print("Deprecated Packages") |
---|
92 | print("You can remove these unless you need them for other reasons!") |
---|
93 | for package_name, test_vals in deprecated_package_list.items(): |
---|
94 | try: |
---|
95 | i = __import__(test_vals['import_name'], fromlist=['']) |
---|
96 | if package_name == 'pyPdf': |
---|
97 | # pyPdf doesn't have the version number internally |
---|
98 | print('pyPDF Installed (Version unknown)') |
---|
99 | else: |
---|
100 | print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) |
---|
101 | except ImportError: |
---|
102 | print('%s NOT INSTALLED'% package_name) |
---|