def parse_sources(source):
    """
    Parse the input string for sources and separate based on config file type.

    Parameters
    ----------
    source : str
        Input source specification.

    Returns
    -------
    sources : dict
        Dictionary of parse sources. Keys are config file names.
    """
    sources = {"setup.cfg": [], "pyproject.toml": []}
    valid_sources = {
        "install": {"file": "setup.cfg", "option": "install_requires"},
        "extras": {"file": "setup.cfg", "option": "options.extras_require"},
        "build": {"file": "pyproject.toml", "option": "build-system"},
    }
    for entry in sorted(source.strip().split(",")):
        if entry not in valid_sources:
            raise ValueError(
                f"Invalid source '{entry}'. Must be one of {list(valid_sources.keys())}."
            )
        sources[valid_sources[entry]["file"]].append(valid_sources[entry]["option"])
    return sources