def split_evr(version):
    """
    Return a tuple of epoch, version, release from a version string
    """
    if '~' in version:
        epoch, version = version.split('~', 1)
    else:
        epoch, version = ('0', version)

    release = None
    if '-' in version:
        version, release = version.rsplit('-', 1)
    else:
        version, release = (version, None)

    return epoch, version, release