def _read_requires_python(metadata):
    """Read wheel metadata to know the value of Requires-Python.

    This is surprisingly poorly supported in Distlib. This function tries
    several ways to get this information:

    * Metadata 2.0: metadata.dictionary.get("requires_python") is not None
    * Metadata 2.1: metadata._legacy.get("Requires-Python") is not None
    * Metadata 1.2: metadata._legacy.get("Requires-Python") != "UNKNOWN"
    """
    value = metadata.dictionary.get('requires_python')
    if value is not None:
        return value
    if metadata._legacy:
        value = metadata._legacy.get('Requires-Python')
        if value is not None and value != 'UNKNOWN':
            return value
    return ''
