def METHOD_NAME(metadata_directory, config_settings=None):
    sys.argv = sys.argv[:1] + ['dist_info', '--egg-base', _to_str(metadata_directory)]
    _run_setup()
    dist_info_directory = metadata_directory
    while True:
        dist_infos = [f for f in os.listdir(dist_info_directory)
                      if f.endswith('.dist-info')]
        if len(dist_infos) == 0 and \
                len(_get_immediate_subdirectories(dist_info_directory)) == 1:
            dist_info_directory = os.path.join(
                dist_info_directory, os.listdir(dist_info_directory)[0])
            continue
        assert len(dist_infos) == 1
        break
    # PEP 517 requires that the .dist-info directory be placed in the
    # metadata_directory. To comply, we MUST copy the directory to the root
    if dist_info_directory != metadata_directory:
        shutil.move(
            os.path.join(dist_info_directory, dist_infos[0]),
            metadata_directory)
        shutil.rmtree(dist_info_directory, ignore_errors=True)
    return dist_infos[0]