Compares two version string, returning {-1|0|1} just as cmp().
    (-1: ver1 < ver2, 0: ver1==ver2, 1: ver1 > ver2)

    >>> compare("0.1.1", "0.1.2")
    -1
    >>> compare("0.1.2", "0.1.1")
    1
    >>> compare("0.1", "0.1.1")
    0
    >>> compare("0.1.1rc1", "0.1.1a")
    1
    >>> compare("0.1.1rc1", "0.1.1")
    -1

def compare(ver1, ver2):
    # type: (Union[str, unicode], Union[str, unicode]) -> int
    """Compares two version string, returning {-1|0|1} just as cmp().
    (-1: ver1 < ver2, 0: ver1==ver2, 1: ver1 > ver2)

    >>> compare("0.1.1", "0.1.2")
    -1
    >>> compare("0.1.2", "0.1.1")
    1
    >>> compare("0.1", "0.1.1")
    0
    >>> compare("0.1.1rc1", "0.1.1a")
    1
    >>> compare("0.1.1rc1", "0.1.1")
    -1
    """
    chunks1 = parse(str(ver1))
    chunks2 = parse(str(ver2))
    min_len = min(len(chunks1), len(chunks2))
    for i in range(min_len):
        if chunks1[i] > chunks2[i]:
            return 1
        elif chunks1[i] < chunks2[i]:
            return -1
    if len(chunks1) > min_len and isinstance(chunks1[min_len], str):
        return -1
    if len(chunks2) > min_len and isinstance(chunks2[min_len], str):
        return 1
    return 0