#!/usr/bin/env python # This script generates a table of dependencies in HTML format on stdout. # It expects to be run in the tahoe-lafs-dep-eggs directory. import re, os, sys import pkg_resources extensions = ('.egg', '.tar.bz2', '.tar.gz', '.exe') platform_aliases = [('i686','x86'), ('i386','x86'), ('i86pc','x86'), ('win32','windows-x86'), ('win-amd64','windows-x86_64'), ('amd64','x86_64')] 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\.]*)?') matrix = {} pkgs = set() platform_dependent_pkgs = set() python_versions = set() depdir = '.' if len(sys.argv) > 1: depdir = sys.argv[1] filenames = os.listdir(depdir) def add(d, k, v): if k in d: d[k] += [v] else: d[k] = [v] for fname in filenames: for ext in extensions: if fname.endswith(ext): m = FILENAME_RE.match(fname[:-len(ext)]) try: pkg = m.group(1) pythonver = (m.group(3) or '-py')[3:] platform = (m.group(4) or '-')[1:] except (IndexError, AttributeError, TypeError): continue if not pythonver: m = FILENAME_RE2.match(fname[:-len(ext)]) if m.group(3): try: platform = m.group(3) pythonver = (m.group(4) or '-py')[3:] except (IndexError, AttributeError, TypeError): continue for (alias, replacement) in platform_aliases: if platform.endswith(alias): platform = platform[:-len(alias)] + replacement break 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)) break platform_independent_pkgs = pkgs - platform_dependent_pkgs width = 100 / (len(platform_independent_pkgs) + 1) print '' print '' print '
' print ' ' print 'Packages for Python %s that have compiled C/C++ code:
' % (pyver,) print 'Platform | ' % (width,) for pkg in sorted(platform_dependent_pkgs): print '%s | ' % (width, pkg) print '|
---|---|---|
%s | ' % (style1, platform,) 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'): print 'n/a | ' % (style2,) else: print '%s | ' % (style2, bestfile and '%s' % (bestfile, bestfile) or '') print '
Packages that are platform-independent or source-only:
' print 'Package | ' print 'All Python versions | ' print '
---|---|
%s | ' % (style1, pkg) files = [n for (p, n) in m if pkg == p] print '%s | ' % (style2, '