def _find_egg_info(directory):
    # type: (str) -> str
    """Find an .egg-info subdirectory in `directory`.
    """
    filenames = [
        f for f in os.listdir(directory) if f.endswith(".egg-info")
    ]

    if not filenames:
        raise InstallationError(
            "No .egg-info directory found in {}".format(directory)
        )

    if len(filenames) > 1:
        raise InstallationError(
            "More than one .egg-info directory found in {}".format(
                directory
            )
        )

    return os.path.join(directory, filenames[0])
Find an .egg-info subdirectory in `directory`.
    
product/gradle-plugin/src/main/python/pip/_internal/operations/build/metadata_legacy.py