2 # This script generates a table of dependencies in HTML format on stdout.
3 # It expects to be run in the tahoe-lafs-dep-eggs directory.
7 extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe')
8 platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'),
9 ('win-amd64','windows-x86_64'), ('amd64','x86_64')]
10 FILENAME_RE = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(-py[0-9\.]*)?(-.*)?')
11 FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(win32|win-amd64)?(-py[0-9\.]*)?')
15 platform_dependent_pkgs = set()
16 python_versions = set()
22 filenames = os.listdir(depdir)
30 for fname in filenames:
31 for ext in extensions:
32 if fname.endswith(ext):
33 m = FILENAME_RE.match(fname[:-len(ext)])
36 pythonver = (m.group(3) or '-py')[3:]
37 platform = (m.group(4) or '-')[1:]
38 except (IndexError, AttributeError, TypeError):
42 m = FILENAME_RE2.match(fname[:-len(ext)])
46 pythonver = (m.group(4) or '-py')[3:]
47 except (IndexError, AttributeError, TypeError):
50 for (alias, replacement) in platform_aliases:
51 if platform.endswith(alias):
52 platform = platform[:-len(alias)] + replacement
57 platform_dependent_pkgs.add(pkg)
58 if pythonver not in matrix:
59 python_versions.add(pythonver)
60 matrix[pythonver] = {}
61 add(matrix[pythonver], platform, (pkg, fname))
64 platform_independent_pkgs = pkgs - platform_dependent_pkgs
66 width = 100 / (len(platform_independent_pkgs) + 1)
68 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
71 print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
72 print ' <title>Software packages that Tahoe-LAFS depends on</title>'
75 print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
77 for pyver in reversed(sorted(python_versions)):
79 print '<p>Packages for Python %s that have compiled C/C++ code:</p>' % (pyver,)
80 print '<table border="1">'
82 print ' <th style="background-color: #FFFFD0" width="%d%%"> Platform </th>' % (width,)
83 for pkg in sorted(platform_dependent_pkgs):
84 print ' <th style="background-color:#FFE8FF;" width="%d%%"> %s </th>' % (width, pkg)
88 for platform in sorted(matrix[pyver]):
89 row_files = sorted(matrix[pyver][platform])
90 style1 = first and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'background-color: #FFFFF0'
91 style2 = first and 'border-top: 2px solid #000000' or ''
93 print ' <td style="%s"> %s </td>' % (style1, platform,)
94 for pkg in sorted(platform_dependent_pkgs):
95 files = [n for (p, n) in row_files if pkg == p]
96 if pkg == 'pywin32' and not platform.startswith('windows'):
97 print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,)
99 print ' <td style="%s"> %s</td>' % (style2,
100 '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
107 print '<p>Packages that are platform-independent or source-only:</p>'
108 print '<table border="1">'
110 print ' <th style="background-color:#FFFFD0;"> Package </th>'
111 print ' <th style="background-color:#FFE8FF;"> All Python versions </th>'
114 style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
115 style2 = 'border-top: 2px solid #000000;'
117 for pkg in sorted(platform_independent_pkgs):
119 print ' <th style="%s"> %s </th>' % (style1, pkg)
120 files = [n for (p, n) in m if pkg == p]
121 print ' <td style="%s"> %s</td>' % (style2, '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
126 # The document does validate, but not when it is included at the bottom of a directory listing.
128 #print '<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img border="0" src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>'
129 print '</body></html>'