Changes in / [ba22344:063dd44] in sasview


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • check_packages.py

    r131d94b rf433e6a  
    22Checking and reinstalling the external packages 
    33""" 
    4 import os 
     4from __future__ import print_function 
     5 
    56import sys 
    67 
     
    1415    sys.modules['Image'] = PIL.Image 
    1516 
     17if sys.version_info[0] > 2: 
     18    print("To use the sasview GUI you must use Python 2\n") 
    1619 
    1720common_required_package_list = { 
    18     'setuptools':{'version':'0.6c11','import_name':'setuptools','test':'__version__'}, 
    19     'pyparsing':{'version':'1.5.5','import_name':'pyparsing','test':'__version__'}, 
    20     'html5lib':{'version':'0.95','import_name':'html5lib','test':'__version__'}, 
    21     'reportlab':{'version':'2.5','import_name':'reportlab','test':'Version'}, 
    22     'h5py':{'version':'2.5','import_name':'h5py','test':'__version__'}, 
    23     'lxml':{'version':'2.3','import_name':'lxml.etree','test':'LXML_VERSION'}, 
    24     'PIL':{'version':'1.1.7','import_name':'Image','test':'VERSION'}, 
    25     'pylint':{'version':None,'import_name':'pylint','test':None}, 
    26     'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, 
    27     'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, 
    28     'numpy':{'version':'1.7.1','import_name':'numpy','test':'__version__'}, 
    29     'scipy':{'version':'0.18.0','import_name':'scipy','test':'__version__'}, 
    30     'wx':{'version':'2.8.12.1','import_name':'wx','test':'__version__'}, 
    31     'matplotlib':{'version':'1.1.0','import_name':'matplotlib','test':'__version__'}, 
    32     'xhtml2pdf':{'version':'3.0.33','import_name':'xhtml2pdf','test':'__version__'}, 
    33     'sphinx':{'version':'1.2.1','import_name':'sphinx','test':'__version__'}, 
    34     'unittest-xml-reporting':{'version':'1.10.0','import_name':'xmlrunner','test':'__version__'}, 
    35     'pyopencl':{'version':'2015.1','import_name':'pyopencl','test':'VERSION_TEXT'}, 
     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'}, 
    3639} 
    3740win_required_package_list = { 
    38     'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, 
    39     'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, 
    40     'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'}, 
     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__'}, 
    4144} 
    4245mac_required_package_list = { 
    43     'py2app':{'version':None,'import_name':'py2app','test':'__version__'}, 
     46    'py2app': {'version': None, 'import_name': 'py2app', 'test': '__version__'}, 
    4447} 
    4548 
    4649deprecated_package_list = { 
    47     'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}, 
     50    'pyPdf': {'version': '1.13', 'import_name': 'pyPdf', 'test': '__version__'}, 
    4851} 
    4952 
    50 print "Checking Required Package Versions...." 
    51 print 
    52 print "Common Packages" 
    53 for package_name,test_vals in common_required_package_list.iteritems(): 
     53print("Checking Required Package Versions....\n") 
     54print("Common Packages") 
     55 
     56for package_name, test_vals in common_required_package_list.items(): 
    5457    try: 
    55         i = __import__(test_vals['import_name'],fromlist=['']) 
     58        i = __import__(test_vals['import_name'], fromlist=['']) 
    5659        if test_vals['test'] == None: 
    57             print "%s Installed (Unknown version)" % package_name 
     60            print("%s Installed (Unknown version)" % package_name) 
    5861        elif package_name == 'lxml': 
    59             verstring = str(getattr(i,'LXML_VERSION')) 
    60             print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) 
     62            verstring = str(getattr(i, 'LXML_VERSION')) 
     63            print("%s Version Installed: %s"% (package_name, verstring.replace(', ', '.').lstrip('(').rstrip(')'))) 
    6164        else: 
    62             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    63     except: 
    64         print '%s NOT INSTALLED'% package_name 
     65            print("%s Version Installed: %s"% (package_name, getattr(i, test_vals['test']))) 
     66    except ImportError: 
     67        print('%s NOT INSTALLED'% package_name) 
    6568 
    6669if sys.platform == 'win32': 
    67     print 
    68     print "Windows Specific Packages:" 
    69     for package_name,test_vals in win_required_package_list.iteritems(): 
     70    print("") 
     71    print("Windows Specific Packages:") 
     72    for package_name, test_vals in win_required_package_list.items(): 
    7073        try: 
    7174            if package_name == "pywin": 
    7275                import win32api 
    73                 fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') 
    74                 print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) 
     76                fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__, '\\') 
     77                print("%s Version Installed: %s"% (package_name, fixed_file_info['FileVersionLS'] >> 16)) 
    7578            else: 
    76                 i = __import__(test_vals['import_name'],fromlist=['']) 
    77                 print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    78         except: 
    79             print '%s NOT INSTALLED'% package_name 
     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) 
    8083 
    8184if sys.platform == 'darwin': 
    82     print 
    83     print "MacOS Specific Packages:" 
    84     for package_name,test_vals in mac_required_package_list.iteritems(): 
     85    print("") 
     86    print("MacOS Specific Packages:") 
     87    for package_name, test_vals in mac_required_package_list.items(): 
    8588        try: 
    86             i = __import__(test_vals['import_name'],fromlist=['']) 
    87             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    88         except: 
    89             print '%s NOT INSTALLED'% package_name 
     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) 
    9093 
    9194 
    92 print 
    93 print "Deprecated Packages" 
    94 print "You can remove these unless you need them for other reasons!" 
    95 for package_name,test_vals in deprecated_package_list.iteritems(): 
     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(): 
    9699    try: 
    97         i = __import__(test_vals['import_name'],fromlist=['']) 
     100        i = __import__(test_vals['import_name'], fromlist=['']) 
    98101        if package_name == 'pyPdf': 
    99             #pyPdf doesn't have the version number internally 
    100             print 'pyPDF Installed (Version unknown)' 
     102            # pyPdf doesn't have the version number internally 
     103            print('pyPDF Installed (Version unknown)') 
    101104        else: 
    102             print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) 
    103     except: 
    104         print '%s NOT INSTALLED'% package_name 
     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 TracChangeset for help on using the changeset viewer.