source: sasview/check_packages.py @ 377ca62f

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 377ca62f was f433e6a, checked in by andyfaff, 8 years ago

MAINT: check_packages.py - check for Py3

  • Property mode set to 100644
File size: 4.8 KB
RevLine 
[7665698]1"""
2Checking and reinstalling the external packages
3"""
[725de411]4from __future__ import print_function
5
[7665698]6import sys
[b441081]7
[b52f47f]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/
[96e151f]10try:
11    import PIL.Image
12except ImportError:
13    pass
14else:
15    sys.modules['Image'] = PIL.Image
16
[f433e6a]17if sys.version_info[0] > 2:
18    print("To use the sasview GUI you must use Python 2\n")
[b52f47f]19
[9939b16]20common_required_package_list = {
[725de411]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'},
[9939b16]39}
40win_required_package_list = {
[725de411]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__'},
[da8c5dc]44}
[9939b16]45mac_required_package_list = {
[725de411]46    'py2app': {'version': None, 'import_name': 'py2app', 'test': '__version__'},
[da8c5dc]47}
48
[9939b16]49deprecated_package_list = {
[725de411]50    'pyPdf': {'version': '1.13', 'import_name': 'pyPdf', 'test': '__version__'},
[9939b16]51}
[da8c5dc]52
[f433e6a]53print("Checking Required Package Versions....\n")
[725de411]54print("Common Packages")
55
56for package_name, test_vals in common_required_package_list.items():
[7665698]57    try:
[725de411]58        i = __import__(test_vals['import_name'], fromlist=[''])
[da8c5dc]59        if test_vals['test'] == None:
[725de411]60            print("%s Installed (Unknown version)" % package_name)
[da8c5dc]61        elif package_name == 'lxml':
[725de411]62            verstring = str(getattr(i, 'LXML_VERSION'))
63            print("%s Version Installed: %s"% (package_name, verstring.replace(', ', '.').lstrip('(').rstrip(')')))
[da8c5dc]64        else:
[725de411]65            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test'])))
66    except ImportError:
67        print('%s NOT INSTALLED'% package_name)
[da8c5dc]68
69if sys.platform == 'win32':
[725de411]70    print("")
71    print("Windows Specific Packages:")
72    for package_name, test_vals in win_required_package_list.items():
[da8c5dc]73        try:
[443a487]74            if package_name == "pywin":
75                import win32api
[725de411]76                fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\')
77                print("%s Version Installed: %s"% (package_name, fixed_file_info['FileVersionLS'] >> 16))
[443a487]78            else:
[725de411]79                i = __import__(test_vals['import_name'], fromlist=[''])
80                print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test'])))
81        except ImportError:
82            print('%s NOT INSTALLED'% package_name)
[da8c5dc]83
84if sys.platform == 'darwin':
[725de411]85    print("")
86    print("MacOS Specific Packages:")
87    for package_name, test_vals in mac_required_package_list.items():
[da8c5dc]88        try:
[725de411]89            i = __import__(test_vals['import_name'], fromlist=[''])
90            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test'])))
91        except ImportError:
92            print('%s NOT INSTALLED'% package_name)
[da8c5dc]93
94
[725de411]95print("")
96print("Deprecated Packages")
97print("You can remove these unless you need them for other reasons!")
98for package_name, test_vals in deprecated_package_list.items():
[131576f]99    try:
[725de411]100        i = __import__(test_vals['import_name'], fromlist=[''])
[da8c5dc]101        if package_name == 'pyPdf':
[725de411]102            # pyPdf doesn't have the version number internally
103            print('pyPDF Installed (Version unknown)')
[da8c5dc]104        else:
[725de411]105            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test'])))
106    except ImportError:
107        print('%s NOT INSTALLED'% package_name)
Note: See TracBrowser for help on using the repository browser.