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