U
    @v¨gç
  ã                   @   sT   d Z ddlZddlmZ ddlmZ ddlmZ er@ddlm	Z	 G dd„ de
ƒZdS )	z`Represents a wheel file and provides access to the various parts of the
name that have meaning.
é    N)ÚTag)ÚInvalidWheelFilename)ÚMYPY_CHECK_RUNNING)ÚListc                   @   s>   e Zd ZdZe dej¡Zdd„ Zdd„ Z	dd„ Z
d	d
„ ZdS )ÚWheelzA wheel filez¨^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
        ((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
        \.whl|\.dist-info)$c                    s¦   ˆ j  |¡}|std| ƒ‚|ˆ _| d¡ dd¡ˆ _| d¡ dd¡ˆ _| d¡ˆ _| d¡ 	d¡ˆ _
| d	¡ 	d¡ˆ _| d
¡ 	d¡ˆ _‡ fdd„ˆ j
D ƒˆ _dS )zX
        :raises InvalidWheelFilename: when the filename is invalid for a wheel
        z!%s is not a valid wheel filename.ÚnameÚ_ú-ÚverÚbuildÚpyverÚ.ÚabiÚplatc                    s0   h | ](}ˆ j D ]}ˆ jD ]}t|||ƒ’qqqS © )ÚabisÚplatsr   )Ú.0ÚxÚyÚz©Úselfr   ú>/tmp/pip-unpacked-wheel-gw11q0wt/pip/_internal/models/wheel.pyÚ	<setcomp>.   s      ÿz!Wheel.__init__.<locals>.<setcomp>N)Úwheel_file_reÚmatchr   ÚfilenameÚgroupÚreplacer   ÚversionÚ	build_tagÚsplitÚ
pyversionsr   r   Ú	file_tags)r   r   Ú
wheel_infor   r   r   Ú__init__   s    ÿ
ÿzWheel.__init__c                 C   s   t dd„ | jD ƒƒS )z4Return the wheel's tags as a sorted list of strings.c                 s   s   | ]}t |ƒV  qd S ©N)Ústr©r   Útagr   r   r   Ú	<genexpr>6   s     z0Wheel.get_formatted_file_tags.<locals>.<genexpr>)Úsortedr$   r   r   r   r   Úget_formatted_file_tags3   s    zWheel.get_formatted_file_tagsc                    s   t ‡ fdd„| jD ƒƒS )aÜ  Return the lowest index that one of the wheel's file_tag combinations
        achieves in the given list of supported tags.

        For example, if there are 8 supported tags and one of the file tags
        is first in the list, then return 0.

        :param tags: the PEP 425 tags to check the wheel against, in order
            with most preferred first.

        :raises ValueError: If none of the wheel's file tags match one of
            the supported tags.
        c                 3   s    | ]}|ˆ krˆ   |¡V  qd S r'   )Úindexr)   ©Útagsr   r   r+   F   s      z*Wheel.support_index_min.<locals>.<genexpr>)Úminr$   ©r   r0   r   r/   r   Úsupport_index_min8   s    zWheel.support_index_minc                 C   s   | j  |¡ S )zŽReturn whether the wheel is compatible with one of the given tags.

        :param tags: the PEP 425 tags to check the wheel against.
        )r$   Ú
isdisjointr2   r   r   r   Ú	supportedH   s    zWheel.supportedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚreÚcompileÚVERBOSEr   r&   r-   r3   r5   r   r   r   r   r      s   ür   )r9   r:   Úpip._vendor.packaging.tagsr   Úpip._internal.exceptionsr   Úpip._internal.utils.typingr   Útypingr   Úobjectr   r   r   r   r   Ú<module>   s   