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 min_supported_python = {'windows-x86': '2.7', 'windows-x86_64': '2.7'}
12 pkg_name_continuations = ('modules')
14 FILENAME_RE = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(-py[0-9\.]*)?(-.*)?')
15 FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(win32|win-amd64)?(-py[0-9\.]*)?')
19 platform_dependent_pkgs = set()
20 python_versions = set()
22 depdirs = ['.', '../tahoe-dep-sdists']
24 depdirs = sys.argv[1 :]
27 for depdir in depdirs:
28 filenames = filenames.union(os.listdir(depdir))
36 for fname in filenames:
37 for ext in extensions:
38 if fname.endswith(ext):
39 m = FILENAME_RE.match(fname[:-len(ext)])
43 if pkg2 in pkg_name_continuations:
46 pythonver = (m.group(3) or '-py')[3:]
47 platform = (m.group(4) or '-')[1:]
48 except (IndexError, AttributeError, TypeError):
51 if not pkg2 in pkg_name_continuations and not pythonver:
52 m = FILENAME_RE2.match(fname[:-len(ext)])
56 pythonver = (m.group(4) or '-py')[3:]
57 except (IndexError, AttributeError, TypeError):
60 for (alias, replacement) in platform_aliases:
61 if platform.endswith(alias):
62 platform = platform[:-len(alias)] + replacement
67 platform_dependent_pkgs.add(pkg)
68 if pythonver not in matrix:
69 python_versions.add(pythonver)
70 matrix[pythonver] = {}
71 add(matrix[pythonver], platform, (pkg, fname))
74 platform_independent_pkgs = pkgs - platform_dependent_pkgs
76 width = 100 / (len(platform_dependent_pkgs) + 1)
78 def file_list(all_files, pkg):
79 files = sorted([(pkg_resources.parse_version(n), n) for (p, n) in all_files if pkg == p])
80 return '<br> '.join(['<a href="%s">%s</a>' % (f, f) for (v, f) in files])
82 greybgstyle = '; background-color: #E0E0E0'
84 unsupportedstyle = '; color: #C00000'
86 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
89 print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
90 print ' <title>Software packages that Tahoe-LAFS depends on</title>'
93 print '<h2>What is this?</h2>'
94 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>.'
95 print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
97 for pyver in reversed(sorted(python_versions)):
98 greybackground = False
100 print '<p>Packages for Python %s that have compiled C/C++ code:</p>' % (pyver,)
101 print '<table border="1">'
103 print ' <th style="background-color: #FFFFD0" width="%d%%"> Platform </th>' % (width,)
104 for pkg in sorted(platform_dependent_pkgs):
105 print ' <th style="background-color: #FFE8FF;" width="%d%%"> %s </th>' % (width, pkg)
109 for platform in sorted(matrix[pyver]):
110 unsupported_python = (platform in min_supported_python and
111 pyver.split('.') < min_supported_python[platform].split('.'))
114 bgstyle = greybgstyle
117 greybackground = not greybackground
118 row_files = sorted(matrix[pyver][platform])
119 style1 = first and 'border-top: 2px solid #000000' or ''
121 style1 += unsupported_python and unsupportedstyle or ''
122 style2 = first and 'border-top: 2px solid #000000' or ''
124 annotated_platform = platform.replace('-', '‑') + (unsupported_python and ' (unsupported)' or '')
126 print ' <td style="%s"> %s </td>' % (style1, annotated_platform)
127 for pkg in sorted(platform_dependent_pkgs):
128 if pkg == 'pywin32' and not platform.startswith('windows'):
129 print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,)
131 print ' <td style="%s"> %s</td>' % (style2, file_list(row_files, pkg))
138 print '<p>Packages that are platform-independent or source-only:</p>'
139 print '<table border="1">'
141 print ' <th style="background-color:#FFFFD0;"> Package </th>'
142 print ' <th style="background-color:#FFE8FF;"> All Python versions </th>'
145 style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
146 style2 = 'border-top: 2px solid #000000;'
148 for pkg in sorted(platform_independent_pkgs):
150 print ' <th style="%s"> %s </th>' % (style1, pkg)
151 print ' <td style="%s"> %s</td>' % (style2, file_list(m, pkg))
156 # The document does validate, but not when it is included at the bottom of a directory listing.
158 #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>'
159 print '</body></html>'