[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/ |
---|
[96e151f] | 9 | try: |
---|
| 10 | import PIL.Image |
---|
| 11 | except ImportError: |
---|
| 12 | pass |
---|
| 13 | else: |
---|
| 14 | sys.modules['Image'] = PIL.Image |
---|
| 15 | |
---|
[b52f47f] | 16 | |
---|
[9939b16] | 17 | common_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'}, |
---|
[68aa210] | 22 | 'h5py':{'version':'2.5','import_name':'h5py','test':'__version__'}, |
---|
[9939b16] | 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__'}, |
---|
[243fbc0] | 27 | 'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, |
---|
[9939b16] | 28 | 'numpy':{'version':'1.6.1','import_name':'numpy','test':'__version__'}, |
---|
| 29 | 'scipy':{'version':'0.10.1','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__'}, |
---|
[61c93b3] | 32 | 'xhtml2pdf':{'version':'3.0.33','import_name':'xhtml2pdf','test':'__version__'}, |
---|
[143c801] | 33 | 'sphinx':{'version':'1.2.1','import_name':'sphinx','test':'__version__'}, |
---|
[1447af3] | 34 | 'unittest-xml-reporting':{'version':'1.10.0','import_name':'xmlrunner','test':'__version__'}, |
---|
[9939b16] | 35 | } |
---|
| 36 | win_required_package_list = { |
---|
| 37 | 'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, |
---|
| 38 | 'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, |
---|
| 39 | 'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'}, |
---|
[da8c5dc] | 40 | } |
---|
[9939b16] | 41 | mac_required_package_list = { |
---|
| 42 | 'py2app':{'version':None,'import_name':'py2app','test':'__version__'}, |
---|
[da8c5dc] | 43 | } |
---|
| 44 | |
---|
[9939b16] | 45 | deprecated_package_list = { |
---|
| 46 | 'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}, |
---|
| 47 | } |
---|
[da8c5dc] | 48 | |
---|
| 49 | print "Checking Required Package Versions...." |
---|
| 50 | print |
---|
| 51 | print "Common Packages" |
---|
| 52 | for package_name,test_vals in common_required_package_list.iteritems(): |
---|
[7665698] | 53 | try: |
---|
[da8c5dc] | 54 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 55 | if test_vals['test'] == None: |
---|
| 56 | print "%s Installed (Unknown version)" % package_name |
---|
| 57 | elif package_name == 'lxml': |
---|
| 58 | verstring = str(getattr(i,'LXML_VERSION')) |
---|
| 59 | print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) |
---|
| 60 | else: |
---|
| 61 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[7665698] | 62 | except: |
---|
[da8c5dc] | 63 | print '%s NOT INSTALLED'% package_name |
---|
| 64 | |
---|
| 65 | if sys.platform == 'win32': |
---|
| 66 | print |
---|
| 67 | print "Windows Specific Packages:" |
---|
| 68 | for package_name,test_vals in win_required_package_list.iteritems(): |
---|
| 69 | try: |
---|
[443a487] | 70 | if package_name == "pywin": |
---|
| 71 | import win32api |
---|
| 72 | fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') |
---|
| 73 | print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) |
---|
| 74 | else: |
---|
| 75 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 76 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[da8c5dc] | 77 | except: |
---|
| 78 | print '%s NOT INSTALLED'% package_name |
---|
| 79 | |
---|
| 80 | if sys.platform == 'darwin': |
---|
| 81 | print |
---|
| 82 | print "MacOS Specific Packages:" |
---|
| 83 | for package_name,test_vals in mac_required_package_list.iteritems(): |
---|
| 84 | try: |
---|
| 85 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 86 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
| 87 | except: |
---|
| 88 | print '%s NOT INSTALLED'% package_name |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | print |
---|
| 92 | print "Deprecated Packages" |
---|
| 93 | print "You can remove these unless you need them for other reasons!" |
---|
| 94 | for package_name,test_vals in deprecated_package_list.iteritems(): |
---|
[131576f] | 95 | try: |
---|
[da8c5dc] | 96 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
| 97 | if package_name == 'pyPdf': |
---|
| 98 | #pyPdf doesn't have the version number internally |
---|
| 99 | print 'pyPDF Installed (Version unknown)' |
---|
| 100 | else: |
---|
| 101 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
[131576f] | 102 | except: |
---|
[da8c5dc] | 103 | print '%s NOT INSTALLED'% package_name |
---|