import sys
import py

PACKAGES = [
    'netifaces',
]

class IndexBuilder(object):

    def __init__(self, wheeldir, outdir):
        self.wheeldir = py.path.local(wheeldir)
        self.outdir = py.path.local(outdir)
        self.packages = []

    def copy_wheels(self):
        for whl in self.wheeldir.visit('*.whl'):
            name, version = self.parse(whl)
            self.packages.append(name)
            d = self.outdir.join(name).ensure(dir=True)
            dst = d.join(whl.basename)
            if dst.check(file=False):
                whl.copy(d)

    def build_index(self):
        self._write_index(self.outdir, 'PyPy Wheel Index', self.packages)
        for pkg in self.packages:
            d = self.outdir.join(pkg)
            wheels = [whl.basename for whl in d.listdir('*.whl')]
            self._write_index(d, 'Links for %s' % pkg, wheels)

    def parse(self, f):
        name, version, _ = f.basename.split('-', 2)
        return name, version

    def _write_index(self, d, title, links):
        lines = [
            '<html><body><h1>{title}</h1>'.format(title=title)
            ]
        for name in links:
            line = '<a href="{name}">{name}</a>'.format(name=name)
            lines.append(line)
        lines.append('</body></html>')
        html = '\n'.join(lines)
        d.join('index.html').write(html)


def main():
    wheeldir = sys.argv[1]
    outdir = sys.argv[2]
    index = IndexBuilder(wheeldir, outdir)
    index.copy_wheels()
    index.build_index()


if __name__ == '__main__':
    main()

add a new script to build a pypi 'simple' index from a dir containing wheels