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