Update copy of gen-package-table.py in source tree.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2015-05-13 13:36:04 +01:00
parent 07aa5e76b5
commit a2e116b330

View File

@ -9,6 +9,7 @@ extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe')
platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'), platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'),
('win-amd64','windows-x86_64'), ('amd64','x86_64')] ('win-amd64','windows-x86_64'), ('amd64','x86_64')]
min_supported_python = {'windows-x86': '2.7', 'windows-x86_64': '2.7'} min_supported_python = {'windows-x86': '2.7', 'windows-x86_64': '2.7'}
pkg_name_continuations = ('modules')
FILENAME_RE = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(-py[0-9\.]*)?(-.*)?') 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\.]*)?') FILENAME_RE2 = re.compile(r'([a-zA-Z_0-9\.]*)-([0-9\.a-vx-z_]*)(win32|win-amd64)?(-py[0-9\.]*)?')
@ -18,11 +19,13 @@ pkgs = set()
platform_dependent_pkgs = set() platform_dependent_pkgs = set()
python_versions = set() python_versions = set()
depdir = '.' depdirs = ['.', '../tahoe-dep-sdists']
if len(sys.argv) > 1: if len(sys.argv) > 1:
depdir = sys.argv[1] depdirs = sys.argv[1 :]
filenames = os.listdir(depdir) filenames = set()
for depdir in depdirs:
filenames = filenames.union(os.listdir(depdir))
def add(d, k, v): def add(d, k, v):
if k in d: if k in d:
@ -36,12 +39,16 @@ for fname in filenames:
m = FILENAME_RE.match(fname[:-len(ext)]) m = FILENAME_RE.match(fname[:-len(ext)])
try: try:
pkg = m.group(1) pkg = m.group(1)
pkg2 = m.group(2)
if pkg2 in pkg_name_continuations:
pkg += '-' + pkg2
else:
pythonver = (m.group(3) or '-py')[3:] pythonver = (m.group(3) or '-py')[3:]
platform = (m.group(4) or '-')[1:] platform = (m.group(4) or '-')[1:]
except (IndexError, AttributeError, TypeError): except (IndexError, AttributeError, TypeError):
continue continue
if not pythonver: if not pkg2 in pkg_name_continuations and not pythonver:
m = FILENAME_RE2.match(fname[:-len(ext)]) m = FILENAME_RE2.match(fname[:-len(ext)])
if m.group(3): if m.group(3):
try: try:
@ -66,7 +73,11 @@ for fname in filenames:
platform_independent_pkgs = pkgs - platform_dependent_pkgs platform_independent_pkgs = pkgs - platform_dependent_pkgs
width = 100 / (len(platform_independent_pkgs) + 1) width = 100 / (len(platform_dependent_pkgs) + 1)
def file_list(all_files, pkg):
files = sorted([(pkg_resources.parse_version(n), n) for (p, n) in all_files if pkg == p])
return '<br>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for (v, f) in files])
greybgstyle = '; background-color: #E0E0E0' greybgstyle = '; background-color: #E0E0E0'
nobgstyle = '' nobgstyle = ''
@ -91,7 +102,7 @@ for pyver in reversed(sorted(python_versions)):
print ' <tr>' print ' <tr>'
print ' <th style="background-color: #FFFFD0" width="%d%%">&nbsp;Platform&nbsp;</th>' % (width,) print ' <th style="background-color: #FFFFD0" width="%d%%">&nbsp;Platform&nbsp;</th>' % (width,)
for pkg in sorted(platform_dependent_pkgs): for pkg in sorted(platform_dependent_pkgs):
print ' <th style="background-color:#FFE8FF;" width="%d%%">&nbsp;%s&nbsp;</th>' % (width, pkg) print ' <th style="background-color: #FFE8FF;" width="%d%%">&nbsp;%s&nbsp;</th>' % (width, pkg)
print ' </tr>' print ' </tr>'
first = True first = True
@ -114,13 +125,10 @@ for pyver in reversed(sorted(python_versions)):
print ' <tr>' print ' <tr>'
print ' <td style="%s">&nbsp;%s&nbsp;</td>' % (style1, annotated_platform) print ' <td style="%s">&nbsp;%s&nbsp;</td>' % (style1, annotated_platform)
for pkg in sorted(platform_dependent_pkgs): for pkg in sorted(platform_dependent_pkgs):
files = [n for (p, n) in row_files if pkg == p]
bestfile = files and max([(pkg_resources.parse_version(x), x) for x in files])[1] or None
if pkg == 'pywin32' and not platform.startswith('windows'): if pkg == 'pywin32' and not platform.startswith('windows'):
print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,) print ' <td style="border: 0; text-align: center; %s"> n/a </td>' % (style2,)
else: else:
print ' <td style="%s">&nbsp;%s</td>' % (style2, print ' <td style="%s">&nbsp;%s</td>' % (style2, file_list(row_files, pkg))
bestfile and '<a href="%s">%s</a>' % (bestfile, bestfile) or '')
print ' </tr>' print ' </tr>'
first = False first = False
@ -140,8 +148,7 @@ m = matrix['']['']
for pkg in sorted(platform_independent_pkgs): for pkg in sorted(platform_independent_pkgs):
print ' <tr>' print ' <tr>'
print ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg) print ' <th style="%s">&nbsp;%s&nbsp;</th>' % (style1, pkg)
files = [n for (p, n) in m if pkg == p] print ' <td style="%s">&nbsp;%s</td>' % (style2, file_list(m, pkg))
print ' <td style="%s">&nbsp;%s</td>' % (style2, '<br>&nbsp;'.join(['<a href="%s">%s</a>' % (f, f) for f in files]))
print ' </tr>' print ' </tr>'
print '</table>' print '</table>'