def make_package_index(download_dir):
    if not os.path.isdir(download_dir):
        raise ValueError("No such directory: %r" % download_dir)

    pkg_rootdir = os.path.join(download_dir, "simple")
    if os.path.isdir(pkg_rootdir):
        shutil.rmtree(pkg_rootdir, ignore_errors=True)
    os.mkdir(pkg_rootdir)

    package_dirs = [download_dir]
    wheelhouse_dir = os.path.join(download_dir, "wheelhouse")
    if os.path.isdir(wheelhouse_dir):
        print("Using wheelhouse: %s" % wheelhouse_dir)
        package_dirs.append(wheelhouse_dir)

    # -- STEP: Collect all packages.
    package_map = {}
    packages = []
    for package_dir in package_dirs:
        new_packages = collect_packages(package_dir, package_map)
        packages.extend(new_packages)

    # -- STEP: Make local PYTHON PACKAGE INDEX.
    root_package = Package(None, "Python Package Index")
    root_package.files = [ os.path.join(pkg_rootdir, pkg.name, "index.html")
                           for pkg in packages ]
    make_index_for(root_package, pkg_rootdir)
    for package in packages:
        index_dir = os.path.join(pkg_rootdir, package.name)
        make_index_for(package, index_dir)


# -----------------------------------------------------------------------------
# MAIN:
# -----------------------------------------------------------------------------
Create a pypi server like file structure below download directory.
dataset/ETHPy150Open behave/behave/bin/make_localpi.py/make_package_index