2010-11-04 07:39:44 +00:00
|
|
|
#!/usr/bin/env python
|
2010-11-03 04:37:18 +00:00
|
|
|
# This script generates a table of dependencies in HTML format on stdout.
|
|
|
|
# It expects to be run in the tahoe-lafs-dep-eggs directory.
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
import re, os, sys
|
2010-11-20 05:39:05 +00:00
|
|
|
import pkg_resources
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe')
|
|
|
|
platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'),
|
2010-11-03 04:33:28 +00:00
|
|
|
('win-amd64','windows-x86_64'), ('amd64','x86_64')]
|
2013-09-09 22:18:18 +00:00
|
|
|
min_supported_python = {'windows-x86': '2.7', 'windows-x86_64': '2.7'}
|
|
|
|
|
2010-11-14 08:26:43 +00:00
|
|
|
FILENAME_RE = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(-py[0-9\.]*)?(-.*)?')
|
|
|
|
FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(win32|win-amd64)?(-py[0-9\.]*)?')
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
matrix = {}
|
2010-11-14 07:35:32 +00:00
|
|
|
pkgs = set()
|
|
|
|
platform_dependent_pkgs = set()
|
|
|
|
python_versions = set()
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
depdir = '.'
|
2010-11-14 07:35:32 +00:00
|
|
|
if len(sys.argv) > 1:
|
2010-11-03 04:37:18 +00:00
|
|
|
depdir = sys.argv[1]
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
filenames = os.listdir(depdir)
|
2010-11-03 04:33:28 +00:00
|
|
|
|
|
|
|
def add(d, k, v):
|
|
|
|
if k in d:
|
|
|
|
d[k] += [v]
|
|
|
|
else:
|
|
|
|
d[k] = [v]
|
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
for fname in filenames:
|
|
|
|
for ext in extensions:
|
2010-11-03 04:33:28 +00:00
|
|
|
if fname.endswith(ext):
|
|
|
|
m = FILENAME_RE.match(fname[:-len(ext)])
|
2010-11-03 04:37:18 +00:00
|
|
|
try:
|
|
|
|
pkg = m.group(1)
|
|
|
|
pythonver = (m.group(3) or '-py')[3:]
|
|
|
|
platform = (m.group(4) or '-')[1:]
|
|
|
|
except (IndexError, AttributeError, TypeError):
|
2010-11-03 04:33:28 +00:00
|
|
|
continue
|
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
if not pythonver:
|
2010-11-03 04:33:28 +00:00
|
|
|
m = FILENAME_RE2.match(fname[:-len(ext)])
|
2010-11-03 04:37:18 +00:00
|
|
|
if m.group(3):
|
|
|
|
try:
|
|
|
|
platform = m.group(3)
|
|
|
|
pythonver = (m.group(4) or '-py')[3:]
|
|
|
|
except (IndexError, AttributeError, TypeError):
|
2010-11-03 04:33:28 +00:00
|
|
|
continue
|
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
for (alias, replacement) in platform_aliases:
|
|
|
|
if platform.endswith(alias):
|
|
|
|
platform = platform[:-len(alias)] + replacement
|
|
|
|
break
|
|
|
|
|
2010-11-14 07:35:32 +00:00
|
|
|
pkgs.add(pkg)
|
|
|
|
if platform:
|
|
|
|
platform_dependent_pkgs.add(pkg)
|
|
|
|
if pythonver not in matrix:
|
|
|
|
python_versions.add(pythonver)
|
|
|
|
matrix[pythonver] = {}
|
|
|
|
add(matrix[pythonver], platform, (pkg, fname))
|
2010-11-03 04:37:18 +00:00
|
|
|
break
|
|
|
|
|
2010-11-14 07:35:32 +00:00
|
|
|
platform_independent_pkgs = pkgs - platform_dependent_pkgs
|
|
|
|
|
|
|
|
width = 100 / (len(platform_independent_pkgs) + 1)
|
|
|
|
|
2012-10-08 18:13:33 +00:00
|
|
|
greybgstyle = '; background-color: #E0E0E0'
|
|
|
|
nobgstyle = ''
|
2013-09-09 22:18:18 +00:00
|
|
|
unsupportedstyle = '; color: #C00000'
|
2012-10-08 18:13:33 +00:00
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
|
|
|
print '<html>'
|
|
|
|
print '<head>'
|
|
|
|
print ' <meta http-equiv="Content-Type" content="text/html;charset=us-ascii">'
|
|
|
|
print ' <title>Software packages that Tahoe-LAFS depends on</title>'
|
|
|
|
print '</head>'
|
|
|
|
print '<body>'
|
2012-10-08 17:43:50 +00:00
|
|
|
print '<h2>What is this?</h2>'
|
|
|
|
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>.'
|
2010-11-03 04:37:18 +00:00
|
|
|
print '<h2>Software packages that Tahoe-LAFS depends on</h2>'
|
|
|
|
print
|
2010-11-14 07:35:32 +00:00
|
|
|
for pyver in reversed(sorted(python_versions)):
|
2012-10-08 18:13:33 +00:00
|
|
|
greybackground = False
|
2010-11-14 07:35:32 +00:00
|
|
|
if pyver:
|
|
|
|
print '<p>Packages for Python %s that have compiled C/C++ code:</p>' % (pyver,)
|
|
|
|
print '<table border="1">'
|
2010-11-03 04:37:18 +00:00
|
|
|
print ' <tr>'
|
2010-11-14 07:35:32 +00:00
|
|
|
print ' <th style="background-color: #FFFFD0" width="%d%%"> Platform </th>' % (width,)
|
|
|
|
for pkg in sorted(platform_dependent_pkgs):
|
|
|
|
print ' <th style="background-color:#FFE8FF;" width="%d%%"> %s </th>' % (width, pkg)
|
2010-11-03 04:37:18 +00:00
|
|
|
print ' </tr>'
|
2010-11-03 04:33:28 +00:00
|
|
|
|
2010-11-14 07:35:32 +00:00
|
|
|
first = True
|
|
|
|
for platform in sorted(matrix[pyver]):
|
2013-09-09 22:18:18 +00:00
|
|
|
unsupported_python = (platform in min_supported_python and
|
|
|
|
pyver.split('.') < min_supported_python[platform].split('.'))
|
|
|
|
|
2012-10-08 18:13:33 +00:00
|
|
|
if greybackground:
|
|
|
|
bgstyle = greybgstyle
|
|
|
|
else:
|
|
|
|
bgstyle = nobgstyle
|
|
|
|
greybackground = not greybackground
|
2010-11-14 07:35:32 +00:00
|
|
|
row_files = sorted(matrix[pyver][platform])
|
2012-10-08 18:13:33 +00:00
|
|
|
style1 = first and 'border-top: 2px solid #000000' or ''
|
|
|
|
style1 += bgstyle
|
2013-09-09 22:18:18 +00:00
|
|
|
style1 += unsupported_python and unsupportedstyle or ''
|
2010-11-14 07:35:32 +00:00
|
|
|
style2 = first and 'border-top: 2px solid #000000' or ''
|
2012-10-08 18:13:33 +00:00
|
|
|
style2 += bgstyle
|
2013-09-09 22:18:18 +00:00
|
|
|
annotated_platform = platform.replace('-', '‑') + (unsupported_python and ' (unsupported)' or '')
|
2010-11-14 07:35:32 +00:00
|
|
|
print ' <tr>'
|
2013-09-09 22:18:18 +00:00
|
|
|
print ' <td style="%s"> %s </td>' % (style1, annotated_platform)
|
2010-11-14 07:35:32 +00:00
|
|
|
for pkg in sorted(platform_dependent_pkgs):
|
|
|
|
files = [n for (p, n) in row_files if pkg == p]
|
2010-11-20 05:39:05 +00:00
|
|
|
bestfile = files and max([(pkg_resources.parse_version(x), x) for x in files])[1] or None
|
2010-11-14 19:35:58 +00:00
|
|
|
if pkg == 'pywin32' and not platform.startswith('windows'):
|
|
|
|
print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,)
|
|
|
|
else:
|
|
|
|
print ' <td style="%s"> %s</td>' % (style2,
|
2010-11-20 05:39:05 +00:00
|
|
|
bestfile and '<a href="%s">%s</a>' % (bestfile, bestfile) or '')
|
2010-11-14 07:35:32 +00:00
|
|
|
print ' </tr>'
|
|
|
|
first = False
|
|
|
|
|
|
|
|
print '</table>'
|
|
|
|
print
|
|
|
|
|
2010-11-03 04:37:18 +00:00
|
|
|
print '<p>Packages that are platform-independent or source-only:</p>'
|
|
|
|
print '<table border="1">'
|
|
|
|
print ' <tr>'
|
|
|
|
print ' <th style="background-color:#FFFFD0;"> Package </th>'
|
|
|
|
print ' <th style="background-color:#FFE8FF;"> All Python versions </th>'
|
|
|
|
print ' </tr>'
|
|
|
|
|
|
|
|
style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;'
|
|
|
|
style2 = 'border-top: 2px solid #000000;'
|
2010-11-14 07:35:32 +00:00
|
|
|
m = matrix['']['']
|
|
|
|
for pkg in sorted(platform_independent_pkgs):
|
|
|
|
print ' <tr>'
|
|
|
|
print ' <th style="%s"> %s </th>' % (style1, pkg)
|
|
|
|
files = [n for (p, n) in m if pkg == p]
|
|
|
|
print ' <td style="%s"> %s</td>' % (style2, '<br> '.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
|
|
|
|
print ' </tr>'
|
2010-11-03 04:37:18 +00:00
|
|
|
|
|
|
|
print '</table>'
|
|
|
|
|
|
|
|
# The document does validate, but not when it is included at the bottom of a directory listing.
|
|
|
|
#print '<hr>'
|
|
|
|
#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>'
|
|
|
|
print '</body></html>'
|