#!/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')] 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_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() depdirs = ['.', '../tahoe-dep-sdists'] if len(sys.argv) > 1: depdirs = sys.argv[1 :] filenames = set() for depdir in depdirs: filenames = filenames.union(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) pkg2 = m.group(2) if pkg2 in pkg_name_continuations: pkg += '-' + pkg2 else: pythonver = (m.group(3) or '-py')[3:] platform = (m.group(4) or '-')[1:] except (IndexError, AttributeError, TypeError): continue if not pkg2 in pkg_name_continuations and 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_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 '
 '.join(['%s' % (f, f) for (v, f) in files]) greybgstyle = '; background-color: #E0E0E0' nobgstyle = '' unsupportedstyle = '; color: #C00000' print('') print('') print('') print(' ') print(' Software packages that Tahoe-LAFS depends on') print('') print('') print('

What is this?

') print('

See quickstart.rst, wiki:Installation, and wiki:CompileError.') print('

Software packages that Tahoe-LAFS depends on

') print() for pyver in reversed(sorted(python_versions)): greybackground = False if pyver: print('

Packages for Python %s that have compiled C/C++ code:

' % (pyver,)) print('') print(' ') print(' ' % (width,)) for pkg in sorted(platform_dependent_pkgs): print(' ' % (width, pkg)) print(' ') first = True for platform in sorted(matrix[pyver]): unsupported_python = (platform in min_supported_python and pyver.split('.') < min_supported_python[platform].split('.')) if greybackground: bgstyle = greybgstyle else: bgstyle = nobgstyle greybackground = not greybackground row_files = sorted(matrix[pyver][platform]) style1 = first and 'border-top: 2px solid #000000' or '' style1 += bgstyle style1 += unsupported_python and unsupportedstyle or '' style2 = first and 'border-top: 2px solid #000000' or '' style2 += bgstyle annotated_platform = platform.replace('-', '‑') + (unsupported_python and ' (unsupported)' or '') print(' ') print(' ' % (style1, annotated_platform)) for pkg in sorted(platform_dependent_pkgs): if pkg == 'pywin32' and not platform.startswith('windows'): print(' ' % (style2,)) else: print(' ' % (style2, file_list(row_files, pkg))) print(' ') first = False print('
 Platform  %s 
 %s  n/a  %s
') print() print('

Packages that are platform-independent or source-only:

') print('') print(' ') print(' ') print(' ') print(' ') style1 = 'border-top: 2px solid #000000; background-color:#FFFFF0;' style2 = 'border-top: 2px solid #000000;' m = matrix[''][''] for pkg in sorted(platform_independent_pkgs): print(' ') print(' ' % (style1, pkg)) print(' ' % (style2, file_list(m, pkg))) print(' ') print('
 Package  All Python versions 
 %s  %s
') # The document does validate, but not when it is included at the bottom of a directory listing. #print('
') #print('Valid HTML 4.01 Transitional') print('')