[7665698] | 1 | """ |
---|
| 2 | Checking and reinstalling the external packages |
---|
| 3 | """ |
---|
| 4 | import os |
---|
| 5 | import sys |
---|
[b441081] | 6 | |
---|
[da8c5dc] | 7 | common_required_package_list = {'setuptools':{'version':'0.6c11','import_name':'setuptools','test':'__version__'}, |
---|
| 8 | 'pyparsing':{'version':'1.5.5','import_name':'pyparsing','test':'__version__'}, |
---|
| 9 | 'html5lib':{'version':'0.95','import_name':'html5lib','test':'__version__'}, |
---|
| 10 | 'reportlab':{'version':'2.5','import_name':'reportlab','test':'Version'}, |
---|
| 11 | 'lxml':{'version':'2.3','import_name':'lxml.etree','test':'LXML_VERSION'}, |
---|
| 12 | 'PIL':{'version':'1.1.7','import_name':'Image','test':'VERSION'}, |
---|
| 13 | 'pylint':{'version':None,'import_name':'pylint','test':None}, |
---|
| 14 | 'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, |
---|
| 15 | 'numpy':{'version':'1.6.1','import_name':'numpy','test':'__version__'}, |
---|
| 16 | 'scipy':{'version':'0.10.1','import_name':'scipy','test':'__version__'}, |
---|
| 17 | 'wx':{'version':'2.8.12.1','import_name':'wx','test':'__version__'}, |
---|
| 18 | 'matplotlib':{'version':'1.1.0','import_name':'matplotlib','test':'__version__'}, |
---|
| 19 | 'pisa':{'version':'3.0.28','import_name':'ho.pisa','test':'__version__'} |
---|
| 20 | |
---|
| 21 | } |
---|
| 22 | win_required_package_list = {'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, |
---|
| 23 | 'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, |
---|
| 24 | 'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'} |
---|
| 25 | } |
---|
| 26 | mac_required_package_list = {'py2app':{'version':None,'import_name':'py2app','test':'__version__'}} |
---|
| 27 | |
---|
| 28 | deprecated_package_list = {'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}} |
---|
| 29 | |
---|
| 30 | print "Checking Required Package Versions...." |
---|
| 31 | print |
---|
| 32 | print "Common Packages" |
---|
| 33 | for package_name,test_vals in common_required_package_list.iteritems(): |
---|
[7665698] | 34 | try: |
---|
[da8c5dc] | 35 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 36 | if test_vals['test'] == None: |
---|
| 37 | print "%s Installed (Unknown version)" % package_name |
---|
| 38 | elif package_name == 'lxml': |
---|
| 39 | verstring = str(getattr(i,'LXML_VERSION')) |
---|
| 40 | print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) |
---|
| 41 | else: |
---|
| 42 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[7665698] | 43 | except: |
---|
[da8c5dc] | 44 | print '%s NOT INSTALLED'% package_name |
---|
| 45 | |
---|
| 46 | if sys.platform == 'win32': |
---|
| 47 | print |
---|
| 48 | print "Windows Specific Packages:" |
---|
| 49 | for package_name,test_vals in win_required_package_list.iteritems(): |
---|
| 50 | try: |
---|
[443a487] | 51 | if package_name == "pywin": |
---|
| 52 | import win32api |
---|
| 53 | fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') |
---|
| 54 | print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) |
---|
| 55 | else: |
---|
| 56 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 57 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[da8c5dc] | 58 | except: |
---|
| 59 | print '%s NOT INSTALLED'% package_name |
---|
| 60 | |
---|
| 61 | if sys.platform == 'darwin': |
---|
| 62 | print |
---|
| 63 | print "MacOS Specific Packages:" |
---|
| 64 | for package_name,test_vals in mac_required_package_list.iteritems(): |
---|
| 65 | try: |
---|
| 66 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 67 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
| 68 | except: |
---|
| 69 | print '%s NOT INSTALLED'% package_name |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | print |
---|
| 73 | print "Deprecated Packages" |
---|
| 74 | print "You can remove these unless you need them for other reasons!" |
---|
| 75 | for package_name,test_vals in deprecated_package_list.iteritems(): |
---|
[131576f] | 76 | try: |
---|
[da8c5dc] | 77 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 78 | if package_name == 'pyPdf': |
---|
| 79 | #pyPdf doesn't have the version number internally |
---|
| 80 | print 'pyPDF Installed (Version unknown)' |
---|
| 81 | else: |
---|
| 82 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[131576f] | 83 | except: |
---|
[da8c5dc] | 84 | print '%s NOT INSTALLED'% package_name |
---|