def get_epoch(version):
    """
    Return a tuple of (epoch, remainder) from a `version` string.
    epoch is an integer.
    """
    if ':' not in version:
        return 0, version
    if version.startswith(':') or version.endswith(':'):
        raise ValueError('Invalid epoch with leading or trailing colon: {}'
            .format(version))
    left, _, right = version.partition(':')
    if left.isdigit():
        epoch = int(left)
        remainder = right
        return epoch, remainder
    raise ValueError('Invalid epoch: must be digits: {}'.format(version))
