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.
8 extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe')
9 platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'),
10 ('win-amd64','windows-x86_64'), ('amd64','x86_64')]
11 FILENAME_RE = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(-py[0-9\.]*)?(-.*)?')
12 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
58 platform_dependent_pkgs.add(pkg)
59 if pythonver not in matrix:
60 python_versions.add(pythonver)
61 matrix[pythonver] = {}
62 add(matrix[pythonver], platform, (pkg, fname))
65 platform_independent_pkgs = pkgs - platform_dependent_pkgs
67 width = 100 / (len(platform_independent_pkgs) + 1)
69 greybgstyle = '; background-color: #E0E0E0'
72 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
75 print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
76 print ' <title>Software packages that Tahoe-LAFS depends on</title>'
79 print '<h2>What is this?</h2>'
80 print '<p>See <a href="https://tahoe-lafs.org/trac/tahoe-lafs/browser/docs/quickstart.rst">quickstart.rst</a>, <a href="https://tahoe-lafs.org/trac/tahoe-lafs/wiki/Installation">wiki:Installation</a>, and <a href="https://tahoe-lafs.org/trac/tahoe-lafs/wiki/CompileError">wiki:CompileError</a>.'
81 print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
83 for pyver in reversed(sorted(python_versions)):
84 greybackground = False
86 print '<p>Packages for Python %s that have compiled C/C++ code:</p>' % (pyver,)
87 print '<table border="1">'
89 print ' <th style="background-color: #FFFFD0" width="%d%%"> Platform </th>' % (width,)
90 for pkg in sorted(platform_dependent_pkgs):
91 print ' <th style="background-color:#FFE8FF;" width="%d%%"> %s </th>' % (width, pkg)
95 for platform in sorted(matrix[pyver]):
100 greybackground = not greybackground
101 row_files = sorted(matrix[pyver][platform])
102 style1 = first and 'border-top: 2px solid #000000' or ''
104 style2 = first and 'border-top: 2px solid #000000' or ''
107 print ' <td style="%s"> %s </td>' % (style1, platform,)
108 for pkg in sorted(platform_dependent_pkgs):
109 files = [n for (p, n) in row_files if pkg == p]
110 bestfile = files and max([(pkg_resources.parse_version(x), x) for x in files])[1] or None
111 if pkg == 'pywin32' and not platform.startswith('windows'):
112 print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,)
114 print ' <td style="%s"> %s</td>' % (style2,
115 bestfile and '<a href="%s">%s</a>' % (bestfile, bestfile) or '')
122 print '<p>Packages that are platform-independent or source-only:</p>'
123 print '<table border="1">'
125 print ' <th style="background-color:#FFFFD0;"> Package </th>'
126 print ' <th style="background-color:#FFE8FF;"> All Python versions </th>'
129 style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
130 style2 = 'border-top: 2px solid #000000;'
132 for pkg in sorted(platform_independent_pkgs):
134 print ' <th style="%s"> %s </th>' % (style1, pkg)
135 files = [n for (p, n) in m if pkg == p]
136 print ' <td style="%s"> %s</td>' % (style2, '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
141 # The document does validate, but not when it is included at the bottom of a directory listing.
143 #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>'
144 print '</body></html>'