1 | """ |
---|
2 | Checking and reinstalling the external packages |
---|
3 | """ |
---|
4 | import os |
---|
5 | import sys |
---|
6 | |
---|
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 | try: |
---|
10 | import PIL.Image |
---|
11 | except ImportError: |
---|
12 | pass |
---|
13 | else: |
---|
14 | sys.modules['Image'] = PIL.Image |
---|
15 | |
---|
16 | |
---|
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'}, |
---|
22 | 'lxml':{'version':'2.3','import_name':'lxml.etree','test':'LXML_VERSION'}, |
---|
23 | 'PIL':{'version':'1.1.7','import_name':'Image','test':'VERSION'}, |
---|
24 | 'pylint':{'version':None,'import_name':'pylint','test':None}, |
---|
25 | 'periodictable':{'version':'1.3.0','import_name':'periodictable','test':'__version__'}, |
---|
26 | 'bumps':{'version':'0.7.5.9','import_name':'bumps','test':'__version__'}, |
---|
27 | 'numpy':{'version':'1.6.1','import_name':'numpy','test':'__version__'}, |
---|
28 | 'scipy':{'version':'0.10.1','import_name':'scipy','test':'__version__'}, |
---|
29 | 'wx':{'version':'2.8.12.1','import_name':'wx','test':'__version__'}, |
---|
30 | 'matplotlib':{'version':'1.1.0','import_name':'matplotlib','test':'__version__'}, |
---|
31 | 'xhtml2pdf':{'version':'3.0.33','import_name':'xhtml2pdf','test':'__version__'}, |
---|
32 | 'sphinx':{'version':'1.2.1','import_name':'sphinx','test':'__version__'}, |
---|
33 | 'unittest-xml-reporting':{'version':'1.10.0','import_name':'xmlrunner','test':'__version__'}, |
---|
34 | } |
---|
35 | win_required_package_list = { |
---|
36 | 'comtypes':{'version':'0.6.2','import_name':'comtypes','test':'__version__'}, |
---|
37 | 'pywin':{'version':'217','import_name':'pywin','test':'__version__'}, |
---|
38 | 'py2exe':{'version':'0.6.9','import_name':'py2exe','test':'__version__'}, |
---|
39 | } |
---|
40 | mac_required_package_list = { |
---|
41 | 'py2app':{'version':None,'import_name':'py2app','test':'__version__'}, |
---|
42 | } |
---|
43 | |
---|
44 | deprecated_package_list = { |
---|
45 | 'pyPdf':{'version':'1.13','import_name':'pyPdf','test':'__version__'}, |
---|
46 | } |
---|
47 | |
---|
48 | print "Checking Required Package Versions...." |
---|
49 | print |
---|
50 | print "Common Packages" |
---|
51 | for package_name,test_vals in common_required_package_list.iteritems(): |
---|
52 | try: |
---|
53 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
54 | if test_vals['test'] == None: |
---|
55 | print "%s Installed (Unknown version)" % package_name |
---|
56 | elif package_name == 'lxml': |
---|
57 | verstring = str(getattr(i,'LXML_VERSION')) |
---|
58 | print "%s Version Installed: %s"% (package_name,verstring.replace(', ','.').lstrip('(').rstrip(')')) |
---|
59 | else: |
---|
60 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
61 | except: |
---|
62 | print '%s NOT INSTALLED'% package_name |
---|
63 | |
---|
64 | if sys.platform == 'win32': |
---|
65 | print |
---|
66 | print "Windows Specific Packages:" |
---|
67 | for package_name,test_vals in win_required_package_list.iteritems(): |
---|
68 | try: |
---|
69 | if package_name == "pywin": |
---|
70 | import win32api |
---|
71 | fixed_file_info = win32api.GetFileVersionInfo(win32api.__file__,'\\') |
---|
72 | print "%s Version Installed: %s"% (package_name,fixed_file_info['FileVersionLS'] >> 16) |
---|
73 | else: |
---|
74 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
75 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
76 | except: |
---|
77 | print '%s NOT INSTALLED'% package_name |
---|
78 | |
---|
79 | if sys.platform == 'darwin': |
---|
80 | print |
---|
81 | print "MacOS Specific Packages:" |
---|
82 | for package_name,test_vals in mac_required_package_list.iteritems(): |
---|
83 | try: |
---|
84 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
85 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
86 | except: |
---|
87 | print '%s NOT INSTALLED'% package_name |
---|
88 | |
---|
89 | |
---|
90 | print |
---|
91 | print "Deprecated Packages" |
---|
92 | print "You can remove these unless you need them for other reasons!" |
---|
93 | for package_name,test_vals in deprecated_package_list.iteritems(): |
---|
94 | try: |
---|
95 | i = __import__(test_vals['import_name'],fromlist=['']) |
---|
96 | if package_name == 'pyPdf': |
---|
97 | #pyPdf doesn't have the version number internally |
---|
98 | print 'pyPDF Installed (Version unknown)' |
---|
99 | else: |
---|
100 | print "%s Version Installed: %s"% (package_name,getattr(i,test_vals['test'])) |
---|
101 | except: |
---|
102 | print '%s NOT INSTALLED'% package_name |
---|