from typing import Tuple
from typing import List
import re


def _split_dependency(dep_str: str) -> Tuple[str, ...]:
    """Splits a string like those coming from PIP constraints into 3 parts: package name, operator, version.
    The operator and version fields can be empty if no constraint is found at all

    :param dep_str: A pip constraint string, like "package-name>=1.0.1"
    :return: A tuple of [package name, operator, version]
    """
    parts: List[str] = re.split('(<=|==|=|>=|<|>)', dep_str)
    if len(parts) == 1:
        return (parts[0].strip(), "", "")
    if len(parts) == 3:
        return tuple(p.strip() for p in parts)
    raise ValueError(f"Unable to split this package string: {dep_str}")