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\.]*)?')
16 platform_dependent_pkgs = set()
17 python_versions = set()
23 filenames = os.listdir(depdir)
31 for fname in filenames:
32 for ext in extensions:
33 if fname.endswith(ext):
34 m = FILENAME_RE.match(fname[:-len(ext)])
37 pythonver = (m.group(3) or '-py')[3:]
38 platform = (m.group(4) or '-')[1:]
39 except (IndexError, AttributeError, TypeError):
43 m = FILENAME_RE2.match(fname[:-len(ext)])
47 pythonver = (m.group(4) or '-py')[3:]
48 except (IndexError, AttributeError, TypeError):
51 for (alias, replacement) in platform_aliases:
52 if platform.endswith(alias):
53 platform = platform[:-len(alias)] + replacement
56 platforms.add(platform)
59 platform_dependent_pkgs.add(pkg)
60 if pythonver not in matrix:
61 python_versions.add(pythonver)
62 matrix[pythonver] = {}
63 add(matrix[pythonver], platform, (pkg, fname))
66 platform_independent_pkgs = pkgs - platform_dependent_pkgs
68 width = 100 / (len(platform_independent_pkgs) + 1)
70 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
73 print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
74 print ' <title>Software packages that Tahoe-LAFS depends on</title>'
77 print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
79 for pyver in reversed(sorted(python_versions)):
81 print '<p>Packages for Python %s that have compiled C/C++ code:</p>' % (pyver,)
82 print '<table border="1">'
84 print ' <th style="background-color: #FFFFD0" width="%d%%"> Platform </th>' % (width,)
85 for pkg in sorted(platform_dependent_pkgs):
86 print ' <th style="background-color:#FFE8FF;" width="%d%%"> %s </th>' % (width, pkg)
90 for platform in sorted(matrix[pyver]):
91 row_files = sorted(matrix[pyver][platform])
92 style1 = first and 'border-top: 2px solid #000000; background-color: #FFFFF0' or 'background-color: #FFFFF0'
93 style2 = first and 'border-top: 2px solid #000000' or ''
95 print ' <td style="%s"> %s </td>' % (style1, platform,)
96 for pkg in sorted(platform_dependent_pkgs):
97 files = [n for (p, n) in row_files if pkg == p]
98 print ' <td style="%s"> %s</td>' % (style2,
99 '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
106 print '<p>Packages that are platform-independent or source-only:</p>'
107 print '<table border="1">'
109 print ' <th style="background-color:#FFFFD0;"> Package </th>'
110 print ' <th style="background-color:#FFE8FF;"> All Python versions </th>'
113 style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
114 style2 = 'border-top: 2px solid #000000;'
116 for pkg in sorted(platform_independent_pkgs):
118 print ' <th style="%s"> %s </th>' % (style1, pkg)
119 files = [n for (p, n) in m if pkg == p]
120 print ' <td style="%s"> %s</td>' % (style2, '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
125 # The document does validate, but not when it is included at the bottom of a directory listing.
127 #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>'
128 print '</body></html>'