o
    Ñ­jZ ã                   @  s°  U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
mZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ ejdkrUdd	l	mZ ne
r]dd	lmZ g d
¢Zdqdd„Zdrdd„Zdsdd„ZedƒZeee f Z!ede!d�Z"eee ge#f Z$edƒZ%de&d< dtd d!„Z'G d"d#„ d#ej(ƒZ)ej*G d$d%„ d%ƒƒZ+ej*G d&d'„ d'ƒƒZ,ej*G d(d)„ d)ƒƒZ-e	j
rÌeee+df Z.e/e,e-f Z0e,dd*ƒZ1e-dd*ƒZ2e1e2ffZ3d+e&d,< dud0d1„Z4dvd6d7„Z5dwd:d;„Z6dwd<d=„Z7dxd@dA„Z8dwdBdC„Z9dwdDdE„Z:dwdFdG„Z;dydJdK„Z<G dLdM„ dMe=ƒZ>G dNdO„ dOej?dP�Z@G dQdR„ dRe@ƒZAe BdS¡ZCdzdYdZ„ZDd{d\d]„ZEd|d_d`„ZFd}dbdc„ZGd~dfdg„ZHddidj„ZId€dmdn„ZJG dodp„ dpe@ƒZKdS )�zŠ
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
é    )ÚannotationsN)	ÚTYPE_CHECKINGÚAnyÚCallableÚFinalÚIterableÚIteratorÚSequenceÚTypeVarÚUnioné   )Úcanonicalize_version)ÚInvalidVersionÚVersion)é   é
   )Ú	TypeGuard)ÚBaseSpecifierÚInvalidSpecifierÚ	SpecifierÚSpecifierSetÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r   r   úQ/var/www/html/CropPilot/venv/lib/python3.10/site-packages/packaging/specifiers.pyÚ__dir__0   s   r   ÚspecÚobjectúTypeGuard[tuple[str, str]]c                C  s2   t | tƒot| ƒdkot | d tƒot | d tƒS )Né   r   r   )Ú
isinstanceÚtupleÚlenÚstr)r   r   r   r   Ú_validate_spec4   s   

ÿþür&   ÚpreúTypeGuard[bool | None]c                C  s   | d u pt | tƒS r   )r"   Úbool)r'   r   r   r   Ú_validate_pre=   s   r*   ÚTÚUnparsedVersionVar)Úboundz0.dev0zFinal[Version]Ú_MIN_VERSIONÚreleaseútuple[int, ...]c                 C  s\   t | ƒ}|dkr | |d  dkr |d8 }|dkr | |d  dks|t | ƒkr(| S | d|… S )zDStrip trailing zeros from a release tuple for normalized comparison.r   r   N)r$   )r/   Úendr   r   r   Ú_trim_releaseJ   s
   ÿr2   c                   @  s    e Zd ZdZe ¡ Ze ¡ ZdS )Ú_BoundaryKindz5Where a boundary marker sits in the version ordering.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚenumÚautoÚAFTER_LOCALSÚAFTER_POSTSr   r   r   r   r3   R   s    r3   c                   @  sP   e Zd ZdZdZdd	d
„Zddd„Zddd„Zddd„Zd dd„Z	d!dd„Z
dS )"Ú_BoundaryVersiona  A point on the version line between two real PEP 440 versions.

    Some specifier semantics imply boundaries between real versions:
    ``<=1.0`` includes ``1.0+local`` and ``>1.0`` excludes
    ``1.0.post0``.  No real :class:`Version` falls on those boundaries,
    so this class creates values that sort between the real versions
    on either side.

    Two kinds exist, shown relative to a base version V::

        V < V+local < AFTER_LOCALS(V) < V.post0 < AFTER_POSTS(V)

    ``AFTER_LOCALS`` sits after V and every V+local, but before
    V.post0.  Upper bound of ``<=V``, ``==V``, ``!=V``.

    ``AFTER_POSTS`` sits after every V.postN, but before the next
    release segment.  Lower bound of ``>V`` (final or pre-release V)
    to exclude post-releases per PEP 440.
    )Ú_kindÚ_trimmed_releaseÚversionr?   r   Úkindr3   r   ÚNonec                 C  s   || _ || _t|jƒ| _d S r   )r?   r=   r2   r/   r>   )Úselfr?   r@   r   r   r   Ú__init__q   s   z_BoundaryVersion.__init__Úotherr)   c                 C  sl   | j }|j|jkrt|jƒ| jkr|j|jksdS | jtjkr+|j	|j	ko*|j
|j
kS |j
|j
kp5|j	duS )z6Is ``other`` a version that this boundary sorts above?FN)r?   Úepochr2   r/   r>   r'   r=   r3   r:   ÚpostÚdev)rB   rD   Úvr   r   r   Ú
_is_familyv   s   z_BoundaryVersion._is_familyr   c                 C  s&   t |tƒr| j|jko| j|jkS tS r   )r"   r<   r?   r=   ÚNotImplemented©rB   rD   r   r   r   Ú__eq__…   s   
z_BoundaryVersion.__eq__ú_BoundaryVersion | Versionc                 C  sH   t |tƒr| j|jkr| j|jk S | jj|jjk S |  |¡ o#| j|k S r   )r"   r<   r?   r=   ÚvaluerI   rK   r   r   r   Ú__lt__Š   s
   
z_BoundaryVersion.__lt__Úintc                 C  ó   t | j| jfƒS r   )Úhashr?   r=   ©rB   r   r   r   Ú__hash__‘   ó   z_BoundaryVersion.__hash__r%   c                 C  s    | j j› d| j›d| jj› d�S )Nú(z, ú))Ú	__class__r4   r?   r=   ÚnamerS   r   r   r   Ú__repr__”   s    z_BoundaryVersion.__repr__N)r?   r   r@   r3   r   rA   )rD   r   r   r)   ©rD   r   r   r)   )rD   rM   r   r)   ©r   rP   ©r   r%   )r4   r5   r6   r7   Ú	__slots__rC   rI   rL   rO   rT   rZ   r   r   r   r   r<   Y   s    




r<   c                   @  óF   e Zd ZdZdZdd	d
„Zddd„Zddd„Zddd„Zddd„Z	dS )Ú_LowerBoundzÂLower bound of a version range.

    A version *v* of ``None`` means unbounded below (-inf).
    At equal versions, ``[v`` sorts before ``(v`` because an inclusive
    bound starts earlier.
    ©Ú	inclusiver?   r?   Ú_VersionOrBoundaryrb   r)   r   rA   c                 C  ó   || _ || _d S r   ©r?   rb   ©rB   r?   rb   r   r   r   rC   £   ó   
z_LowerBound.__init__rD   r   c                 C  ó&   t |tƒstS | j|jko| j|jkS r   ©r"   r`   rJ   r?   rb   rK   r   r   r   rL   §   ó   
z_LowerBound.__eq__c                 C  sV   t |tƒstS | jd u r|jd uS |jd u rdS | j|jkr$| j|jk S | jo*|j S )NFri   rK   r   r   r   rO   ¬   s   



z_LowerBound.__lt__rP   c                 C  rQ   r   ©rR   r?   rb   rS   r   r   r   rT   ¹   rU   z_LowerBound.__hash__r%   c                 C  s*   | j rdnd}d| jj› d|› | j›d�S )Nú[rV   ú<ú ú>©rb   rX   r4   r?   ©rB   Úbracketr   r   r   rZ   ¼   ó   z_LowerBound.__repr__N©r?   rc   rb   r)   r   rA   r[   )rD   r`   r   r)   r\   r]   ©
r4   r5   r6   r7   r^   rC   rL   rO   rT   rZ   r   r   r   r   r`   ˜   ó    



r`   c                   @  r_   )Ú_UpperBoundzÀUpper bound of a version range.

    A version *v* of ``None`` means unbounded above (+inf).
    At equal versions, ``v)`` sorts before ``v]`` because an exclusive
    bound ends earlier.
    ra   r?   rc   rb   r)   r   rA   c                 C  rd   r   re   rf   r   r   r   rC   Ì   rg   z_UpperBound.__init__rD   r   c                 C  rh   r   ©r"   rw   rJ   r?   rb   rK   r   r   r   rL   Ð   rj   z_UpperBound.__eq__c                 C  sP   t |tƒstS | jd u rdS |jd u rdS | j|jkr!| j|jk S | j o'|jS ©NFTrx   rK   r   r   r   rO   Õ   s   


z_UpperBound.__lt__rP   c                 C  rQ   r   rk   rS   r   r   r   rT   â   rU   z_UpperBound.__hash__r%   c                 C  s*   | j rdnd}d| jj› d| j›|› d�S )Nú]rW   rm   rn   ro   rp   rq   r   r   r   rZ   å   rs   z_UpperBound.__repr__Nrt   r[   )rD   rw   r   r)   r\   r]   ru   r   r   r   r   rw   Á   rv   rw   Fztuple[_VersionRange]Ú_FULL_RANGEÚlowerÚupperr)   c                 C  s>   | j du s
|j du rdS | j |j kr| jo|j S | j |j kS )zHTrue when the range defined by *lower* and *upper* contains no versions.NFre   )r|   r}   r   r   r   Ú_range_is_emptyö   s
   r~   ÚleftúSequence[_VersionRange]Úrightúlist[_VersionRange]c                 C  sž   g }d }}|t | ƒk rM|t |ƒk rM| | \}}|| \}}t||ƒ}	t||ƒ}
t|	|
ƒs4| |	|
f¡ ||k r=|d7 }n|d7 }|t | ƒk rM|t |ƒk s|S )zFIntersect two sorted, non-overlapping range lists (two-pointer merge).r   r   )r$   ÚmaxÚminr~   Úappend)r   r�   ÚresultÚ
left_indexÚright_indexÚ
left_lowerÚ
left_upperÚright_lowerÚright_upperr|   r}   r   r   r   Ú_intersect_rangesÿ   s   



òr�   r?   r   c                 C  s4   g | j dd… ¢| j d d ‘R }tj| j|dd�S )z5Smallest version in the next prefix: 1.2 -> 1.3.dev0.Néÿÿÿÿr   r   ©rE   r/   rG   )r/   r   Ú
from_partsrE   )r?   r/   r   r   r   Ú_next_prefix_dev0  s   "r‘   c                 C  s   t j| j| jdd�S )z7The .dev0 of a version's base release: 1.2 -> 1.2.dev0.r   r�   )r   r�   rE   r/   ©r?   r   r   r   Ú
_base_dev0  s   r“   ÚUnparsedVersionúVersion | Nonec                 C  s2   t | tƒszt| ƒ} W | S  ty   Y d S w | S r   )r"   r   r   r’   r   r   r   Ú_coerce_version$  s   

þÿr–   c                 C  s   | j d u r| S | jd d�S )N)Úlocal)r—   Ú__replace__r’   r   r   r   Ú_public_version-  s   
r™   c                 C  s   | j dddd�S )zyThe version that *version* is a post-release of.

    1.0.post1 -> 1.0, 1.0a1.post0 -> 1.0a1, 1.0.post0.dev1 -> 1.0.
    N©rF   rG   r—   ©r˜   r’   r   r   r   Ú
_post_base3  s   rœ   c                 C  s   | j ddd�S )zZEarliest pre-release of *version*.

    1.2 -> 1.2.dev0, 1.2.post1 -> 1.2.post1.dev0.
    r   N©rG   r—   r›   r’   r   r   r   Ú_earliest_prerelease;  s   rž   rH   rc   c                 C  sr   | du rdS t | tƒr,| j}|jr|jdddd�S |jdur#|jd nd}|j|dd�S | js1| S | jdddd�S )z:Smallest non-pre-release version at or above *v*, or None.N)r'   rG   r—   r   r   )rF   r—   )r"   r<   r?   Úis_prereleaser˜   rF   )rH   ÚinnerÚkr   r   r   Ú_nearest_non_prereleaseC  s   
r¢   c                   @  s   e Zd ZdZdS )r   a  
    Raised when attempting to create a :class:`Specifier` with a specifier
    string that is invalid.

    >>> Specifier("lolwat")
    Traceback (most recent call last):
        ...
    packaging.specifiers.InvalidSpecifier: Invalid specifier: 'lolwat'
    N)r4   r5   r6   r7   r   r   r   r   r   X  s    r   c                   @  sÊ   e Zd ZdZdZed+dd„ƒZejd+dd„ƒZ	ejd,d
d„ƒZ
ejd-dd„ƒZeejd.dd„ƒƒZejd/dd„ƒZejd0d1dd„ƒZej		d2d3d!d"„ƒZej		d2d4d&d"„ƒZej		d5d6d*d"„ƒZdS )7r   r   )Ú_strr   r%   c                 C  s   t | ƒS )z Internal property for match_args©r%   rS   r   r   r   r£   h  s   zBaseSpecifier._strc                 C  ó   dS )zŽ
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr   rS   r   r   r   Ú__str__m  ó    zBaseSpecifier.__str__rP   c                 C  r¥   )zF
        Returns a hash value for this Specifier-like object.
        Nr   rS   r   r   r   rT   t  r§   zBaseSpecifier.__hash__rD   r   r)   c                 C  r¥   )z«
        Returns a boolean representing whether or not the two Specifier-like
        objects are equal.

        :param other: The other object to check against.
        Nr   rK   r   r   r   rL   z  r§   zBaseSpecifier.__eq__úbool | Nonec                 C  r¥   )zîWhether or not pre-releases as a whole are allowed.

        This can be set to either ``True`` or ``False`` to explicitly enable or disable
        prereleases or it can be set to ``None`` (the default) to use default semantics.
        Nr   rS   r   r   r   Úprereleasesƒ  r§   zBaseSpecifier.prereleasesrN   rA   c                 C  r¥   )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr   ©rB   rN   r   r   r   r©   Œ  r§   NÚitemr©   c                 C  r¥   )zR
        Determines if the given item is contained within this specifier.
        Nr   ©rB   r«   r©   r   r   r   Úcontains“  r§   zBaseSpecifier.contains.ÚiterableúIterable[UnparsedVersionVar]ÚkeyúIterator[UnparsedVersionVar]c                 C  ó   d S r   r   ©rB   r®   r©   r°   r   r   r   Úfilter™  ó   zBaseSpecifier.filterúIterable[T]úCallable[[T], UnparsedVersion]úIterator[T]c                 C  r²   r   r   r³   r   r   r   r´   ¡  rµ   úIterable[Any]ú'Callable[[Any], UnparsedVersion] | NoneúIterator[Any]c                 C  r¥   )z•
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr   r³   r   r   r   r´   ©  r§   r]   r\   r[   ©r   r¨   )rN   r)   r   rA   r   )r«   r%   r©   r¨   r   r)   ©N.©r®   r¯   r©   r¨   r°   rA   r   r±   ©r®   r¶   r©   r¨   r°   r·   r   r¸   ©NN©r®   r¹   r©   r¨   r°   rº   r   r»   )r4   r5   r6   r^   Ú__match_args__Úpropertyr£   ÚabcÚabstractmethodr¦   rT   rL   r©   Úsetterr­   ÚtypingÚoverloadr´   r   r   r   r   r   d  s<    üüür   )Ú	metaclassc                	   @  sÌ  e Zd ZU dZdZdZe de d ejej	B ¡Z
ddddd	d
dddœZded< dwdxdd„Zdydd„Zdzdd „Zd{d"d#„Zd|d'd(„Zd|d)d*„Zed}d+d,„ƒZejd~d.d,„ƒZdd0d1„Zd€d4d5„Zed�d6d7„ƒZed�d8d9„ƒZd�d:d;„Zd�d<d=„Zed‚d?d@„ƒZdƒdBdC„Zd„dFdG„Zd…dIdJ„Zd†dLdM„Z d‡dOdP„Z!d†dQdR„Z"d†dSdT„Z#d†dUdV„Z$d†dWdX„Z%dˆdZd[„Z&dˆd\d]„Z'd‰d_d`„Z(dŠdcdd„Z)d‹dŒdfdg„Z*e+j,		hd�dŽdmdn„ƒZ-e+j,		hd�d�drdn„ƒZ-		d�d‘dvdn„Z-dS )’r   aí  This class abstracts handling of version specifiers.

    .. tip::

        It is generally not required to instantiate this manually. You should instead
        prefer to work with :class:`SpecifierSet` instead, which can parse
        comma-separated version specifiers (which is what package metadata contains).

    Instances are safe to serialize with :mod:`pickle`. They use a stable
    format so the same pickle can be loaded in future packaging releases.

    .. versionchanged:: 26.2

        Added a stable pickle format. Pickles created with packaging 26.2+ can
        be unpickled with future releases.  Backward compatibility with pickles
        from packaging < 26.2 is supported but may be removed in a future
        release.
    )Ú_prereleasesÚ_rangesÚ_specÚ_spec_versionÚ_wildcard_splita  
        (?:
            (?:
                # The identity operators allow for an escape hatch that will
                # do an exact string match of the version you wish to install.
                # This will not be parsed by PEP 440 and we cannot determine
                # any semantic meaning from it. This operator is discouraged
                # but included entirely as an escape hatch.
                ===  # Only match for the identity operator
                \s*
                [^\s;)]*  # The arbitrary version can be just about anything,
                          # we match everything except for whitespace, a
                          # semi-colon for marker support, and a closing paren
                          # since versions can be enclosed in them.
            )
            |
            (?:
                # The (non)equality operators allow for wild card and local
                # versions to be specified so we have to define these two
                # operators separately to enable that.
                (?:==|!=)            # Only match for equals and not equals

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release

                # You cannot use a wild card and a pre-release, post-release, a dev or
                # local version together so group them with a | and make them optional.
                (?:
                    \.\*  # Wild card syntax of .*
                    |
                    (?a:                                  # pre release
                        [-_\.]?
                        (alpha|beta|preview|pre|a|b|c|rc)
                        [-_\.]?
                        [0-9]*
                    )?
                    (?a:                                  # post release
                        (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                    )?
                    (?a:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?a:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                )?
            )
            |
            (?:
                # The compatible operator requires at least two digits in the
                # release segment.
                (?:~=)               # Only match for the compatible operator

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)+   # release  (We have a + instead of a *)
                (?:                   # pre release
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
            |
            (?:
                # All other operators only allow a sub set of what the
                # (non)equality operators do. Specifically they do not allow
                # local versions to be specified nor do they allow the prefix
                # matching wild cards.
                (?:<=|>=|<|>)

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?a:                   # pre release
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?a:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?a:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        z\s*Ú
compatibleÚequalÚ	not_equalÚless_than_equalÚgreater_than_equalÚ	less_thanÚgreater_thanÚ	arbitrary)ú~=ú==ú!=ú<=ú>=rm   ro   ú===r   Ú
_operatorsÚ Nr   r%   r©   r¨   r   rA   c                 C  sº   | j  |¡std|›�ƒ‚| ¡ }| d¡r&|dd… |dd…  ¡ }}n$| d¡r;|dd… |dd…  ¡ }}n|dd… |dd…  ¡ }}||f| _|| _d| _d| _d| _	dS )að  Initialize a Specifier instance.

        :param spec:
            The string representation of a specifier which will be parsed and
            normalized before use.
        :param prereleases:
            This tells the specifier if it should accept prerelease versions if
            applicable or not. The default of ``None`` will autodetect it from the
            given specifiers.
        :raises InvalidSpecifier:
            If the given specifier is invalid (i.e. bad syntax).
        zInvalid specifier: rÜ   Nr   )r×   rØ   rÙ   rÚ   rÛ   r!   r   )
Ú_regexÚ	fullmatchr   ÚstripÚ
startswithrÌ   rÊ   rÍ   rÎ   rË   )rB   r   r©   Úoperatorr?   r   r   r   rC   =  s   
 
 

zSpecifier.__init__r?   r•   c                 C  sD   | j dur| j d |kr| j d S t|ƒ}|du rdS ||f| _ |S )zDOne element cache, as only one spec Version is needed per Specifier.Nr   r   )rÍ   r–   )rB   r?   Úversion_specifierr   r   r   Ú_get_spec_versionc  s   

zSpecifier._get_spec_versionr   c                 C  s   |   |¡}|dusJ ‚|S )zÕGet spec version, asserting it's valid (not for === operator).

        This method should only be called for operators where version
        strings are guaranteed to be valid PEP 440 versions (not ===).
        N)rå   )rB   r?   Úspec_versionr   r   r   Ú_require_spec_versiono  s   
zSpecifier._require_spec_versionr€   c                 C  s\   | j dur| j S | j}| j}|dkrt| _ tS | d¡r#|  ||¡}n|  ||¡}|| _ |S )zØConvert this specifier to sorted, non-overlapping version ranges.

        Each standard operator maps to one or two ranges.  ``===`` is
        modeled as full range (actual check done separately).  Cached.
        NrÜ   ú.*)rË   rã   r?   r{   ÚendswithÚ_wildcard_rangesÚ_standard_ranges)rB   ÚopÚver_strr†   r   r   r   Ú
_to_rangesy  s   

zSpecifier._to_rangesrì   rí   r‚   c                 C  s\   |   |d d… ¡}t|ƒ}t|ƒ}|dkr t|dƒt|dƒfgS tt|dƒft|dƒtfgS )NéþÿÿÿrØ   TF)rç   r“   r‘   r`   rw   Ú_NEG_INFÚ_POS_INF)rB   rì   rí   Úbaser|   r}   r   r   r   rê   ‘  s   þzSpecifier._wildcard_rangesc           
      C  s¤  |   |¡}|dkrt|dƒtfgS |dkr!ttt|tjƒdƒfgS |dkr`|jd ur<|j	|jd d d�}t|dƒtfgS |j
d urT|j	|j
d dd d�}t|dƒtfgS tt|tjƒd	ƒtfgS |d
kr~|jri|n|j	dd d�}|tkrvg S tt|d	ƒfgS d|v }t|tjƒ}|rŒ|n|}|dkr�t|dƒt|dƒfgS |dkr¯tt|d	ƒft|d	ƒtfgS |dkrË|j	|jd d… d�}	t|dƒtt|	ƒd	ƒfgS td|›�ƒ‚)NrÛ   TrÚ   ro   r   r�   r   rš   Frm   ú+rØ   rÙ   r×   rŽ   )r/   úUnknown operator: )rç   r`   rñ   rð   rw   r<   r3   r:   rG   r˜   rF   r;   rŸ   r.   r/   r‘   Ú
ValueError)
rB   rì   rí   rH   Ú	lower_verr-   Ú	has_localÚafter_localsr}   Úprefixr   r   r   rë   ž  sL   
þÿ

þÿþÿzSpecifier._standard_rangesc                 C  sX   | j d ur| j S | j\}}|dkrdS |dkr| d¡rdS |  |¡}|d u r)d S |jS )NrÙ   FrØ   rè   )rÊ   rÌ   ré   rå   rŸ   )rB   rã   Úversion_strr?   r   r   r   r©   Ü  s   


zSpecifier.prereleasesrN   c                 C  s
   || _ d S r   )rÊ   rª   r   r   r   r©   ø  ó   
ú#tuple[tuple[str, str], bool | None]c                 C  ó   | j | jfS r   )rÌ   rÊ   rS   r   r   r   Ú__getstate__ü  ó   zSpecifier.__getstate__Ústater   c                 C  sö   d | _ d | _d | _t|tƒrTt|ƒdkr(|\}}t|ƒr(t|ƒr(|| _|| _	d S t|ƒdkrTt|d t
ƒrT|\}}| d¡}| dd¡}t|ƒrTt|ƒrT|| _|| _	d S t|t
ƒrt| d¡}| dd¡}t|ƒrtt|ƒrt|| _|| _	d S td|›�ƒ‚)Nr!   r   rÌ   rÊ   ÚinvalidzCannot restore Specifier from )rÍ   rÎ   rË   r"   r#   r$   r&   r*   rÌ   rÊ   ÚdictÚgetÚ	TypeError)rB   r   r   r©   Ú_Ú	slot_dictr   r   r   Ú__setstate__  s4   



zSpecifier.__setstate__c                 C  ó
   | j d S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   ©rÌ   rS   r   r   r   rã   $  ó   
zSpecifier.operatorc                 C  r  )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r   r	  rS   r   r   r   r?   -  r
  zSpecifier.versionc                 C  ó8   | j durd| j›�nd}d| jj› dt| ƒ›|› d�S )aT  A representation of the Specifier that shows all internal state.

        >>> Specifier('>=1.0.0')
        <Specifier('>=1.0.0')>
        >>> Specifier('>=1.0.0', prereleases=False)
        <Specifier('>=1.0.0', prereleases=False)>
        >>> Specifier('>=1.0.0', prereleases=True)
        <Specifier('>=1.0.0', prereleases=True)>
        Nú, prereleases=rÞ   rm   rV   ú)>©rÊ   r©   rX   r4   r%   ©rB   r'   r   r   r   rZ   6  s
   
ÿýzSpecifier.__repr__c                 C  s   dj | jŽ S )zÐA string representation of the Specifier that can be round-tripped.

        >>> str(Specifier('>=1.0.0'))
        '>=1.0.0'
        >>> str(Specifier('>=1.0.0', prereleases=False))
        '>=1.0.0'
        z{}{})ÚformatrÌ   rS   r   r   r   r¦   H  s   zSpecifier.__str__útuple[str, str]c                 C  sF   | j \}}|dks| d¡r||fS |  |¡}t||dkd�}||fS )NrÜ   rè   r×   ©Ústrip_trailing_zero)rÌ   ré   rç   r   )rB   rã   r?   ræ   Úcanonical_versionr   r   r   Ú_canonical_specR  s   

ÿzSpecifier._canonical_specrP   c                 C  ó
   t | jƒS r   )rR   r  rS   r   r   r   rT   `  s   
zSpecifier.__hash__rD   r)   c                 C  sP   t |tƒrz	|  t|ƒ¡}W n ty   t Y S w t || jƒs"tS | j|jkS )a>  Whether or not the two Specifier-like objects are equal.

        :param other: The other object to check against.

        The value of :attr:`prereleases` is ignored.

        >>> Specifier("==1.2.3") == Specifier("== 1.2.3.0")
        True
        >>> (Specifier("==1.2.3", prereleases=False) ==
        ...  Specifier("==1.2.3", prereleases=True))
        True
        >>> Specifier("==1.2.3") == "==1.2.3"
        True
        >>> Specifier("==1.2.3") == Specifier("==1.2.4")
        False
        >>> Specifier("==1.2.3") == Specifier("~=1.2.3")
        False
        )r"   r%   rX   r   rJ   r  rK   r   r   r   rL   c  s   
ÿzSpecifier.__eq__ÚCallableOperatorc                 C  s   t | d| j| › �ƒ}|S )NÚ	_compare_)ÚgetattrrÝ   )rB   rì   Úoperator_callabler   r   r   Ú_get_operator€  s   ÿzSpecifier._get_operatorÚprospectivec                 C  s@   t tt tt|ƒ¡ƒd d… ƒ}|d7 }|  ||¡o|  ||¡S )NrŽ   rè   )Ú_version_joinÚlistÚ	itertoolsÚ	takewhileÚ_is_not_suffixÚ_version_splitÚ_compare_greater_than_equalÚ_compare_equal)rB   r  r   rù   r   r   r   Ú_compare_compatible†  s   	ÿ
ÿzSpecifier._compare_compatibleútuple[list[str], int]c                 C  s@   | j }|du rt|dd… dd�}t|ƒ}|t|ƒf}|| _ |S )zýCached split of a wildcard spec into components and numeric length.

        >>> Specifier("==1.*")._get_wildcard_split("1.*")
        (['0', '1'], 2)
        >>> Specifier("==3.10.*")._get_wildcard_split("3.10.*")
        (['0', '3', '10'], 3)
        Nrï   Fr  )rÎ   r   r"  Ú_numeric_prefix_len)rB   r   Úwildcard_splitÚ
normalizedÚ
split_specr   r   r   Ú_get_wildcard_splitš  s   zSpecifier._get_wildcard_splitc           
      C  sr   |  d¡r)|  |¡\}}tt|ƒdd�}t|ƒ}t||ƒ}|d t|ƒ… }||kS |  |¡}	|	js5t|ƒ}||	kS )Nrè   Fr  )	ré   r+  r   r™   r"  Ú	_left_padr$   rç   r—   )
rB   r  r   r*  Úspec_numeric_lenÚnormalized_prospectiveÚsplit_prospectiveÚpadded_prospectiveÚshortened_prospectiveræ   r   r   r   r$  ª  s   
ÿ

zSpecifier._compare_equalc                 C  s   |   ||¡ S r   )r$  ©rB   r  r   r   r   r   Ú_compare_not_equalÎ  s   zSpecifier._compare_not_equalc                 C  s   t |ƒ|  |¡kS r   ©r™   rç   r2  r   r   r   Ú_compare_less_than_equalÑ  ó   z"Specifier._compare_less_than_equalc                 C  s   t |ƒ|  |¡kS r   r4  r2  r   r   r   r#  ×  r6  z%Specifier._compare_greater_than_equalÚspec_strc                 C  s6   |   |¡}||k sdS |js|jr|t|ƒkrdS dS ry   )rç   rŸ   rž   ©rB   r  r7  r   r   r   r   Ú_compare_less_thanÝ  s   
ÿþzSpecifier._compare_less_thanc                 C  sP   |   |¡}||ksdS |js|jrt|ƒ|krdS |jd ur&t|ƒ|kr&dS dS ry   )rç   Úis_postreleaserœ   r—   r™   r8  r   r   r   Ú_compare_greater_thanö  s   
ÿþzSpecifier._compare_greater_thanúVersion | strc                 C  s   t |ƒ ¡ t |ƒ ¡ kS r   ©r%   r|   r2  r   r   r   Ú_compare_arbitrary  s   zSpecifier._compare_arbitraryr«   ústr | Versionc                 C  ó
   |   |¡S )a:  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

        This is used for the ``in`` operator and behaves the same as
        :meth:`contains` with no ``prereleases`` argument passed.

        >>> "1.2.3" in Specifier(">=1.2.3")
        True
        >>> Version("1.2.3") in Specifier(">=1.2.3")
        True
        >>> "1.0.0" in Specifier(">=1.2.3")
        False
        >>> "1.3.0a1" in Specifier(">=1.2.3")
        True
        >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
        True
        ©r­   ©rB   r«   r   r   r   Ú__contains__  ó   
zSpecifier.__contains__r”   c                 C  s   t t| j|g|d�ƒƒS )as  Return whether or not the item is contained in this specifier.

        :param item:
            The item to check for, which can be a version string or a
            :class:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this Specifier. If set to
            ``None`` (the default), it will follow the recommendation from
            :pep:`440` and match prereleases, as there are no other versions.

        >>> Specifier(">=1.2.3").contains("1.2.3")
        True
        >>> Specifier(">=1.2.3").contains(Version("1.2.3"))
        True
        >>> Specifier(">=1.2.3").contains("1.0.0")
        False
        >>> Specifier(">=1.2.3").contains("1.3.0a1")
        True
        >>> Specifier(">=1.2.3", prereleases=False).contains("1.3.0a1")
        False
        >>> Specifier(">=1.2.3").contains("1.3.0a1")
        True
        ©r©   )r)   r  r´   r¬   r   r   r   r­   .  s   zSpecifier.contains.r®   r¯   r°   r±   c                 C  r²   r   r   r³   r   r   r   r´   I  rµ   zSpecifier.filterr¶   r·   r¸   c                 C  r²   r   r   r³   r   r   r   r´   Q  rµ   r¹   rº   r»   c                 c  s  � g }d}|dur|n| j }|  | j¡}|D ]^}t|du r|n||ƒƒ}	d}
|	du r:| jdkr9|  || j¡r9|V  n| jdkrO|  |du rG|n||ƒ| j¡}
n||	| jƒ}
|
rt|	durt|	jr`|rfd}|V  q|du rt| jdurt| |¡ q|s‡|du r‰| jdur‹|E dH  dS dS dS dS )a€  Filter items in the given iterable, that match the specifier.

        :param iterable:
            An iterable that can contain version strings and :class:`Version` instances.
            The items in the iterable will be filtered according to the specifier.
        :param prereleases:
            Whether or not to allow prereleases in the returned iterator. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases if there are no other versions.
        :param key:
            A callable that takes a single argument (an item from the iterable) and
            returns a version string or :class:`Version` instance to be used for
            filtering.

        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
        ['1.3']
        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.2.3", "1.3", Version("1.4")]))
        ['1.2.3', '1.3', <Version('1.4')>]
        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.5a1"]))
        ['1.5a1']
        >>> list(Specifier(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        >>> list(Specifier(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']
        >>> list(Specifier(">=1.2.3").filter(
        ... [{"ver": "1.2"}, {"ver": "1.3"}],
        ... key=lambda x: x["ver"]))
        [{'ver': '1.3'}]
        FNrÜ   T)	r©   r  rã   r–   r>  r?   rŸ   rÊ   r…   )rB   r®   r©   r°   Úprereleases_versionsÚfound_non_prereleasesÚinclude_prereleasesr  r?   Úparsed_versionÚmatchr   r   r   r´   Y  sF   €#ÿÿ€
ÿ

€ÿ
û©rÞ   N)r   r%   r©   r¨   r   rA   )r?   r%   r   r•   )r?   r%   r   r   ©r   r€   )rì   r%   rí   r%   r   r‚   r¼   ©rN   r¨   r   rA   )r   rü   ©r   r   r   rA   r]   )r   r  r\   r[   )rì   r%   r   r  )r  r   r   r%   r   r)   )r   r%   r   r&  )r  r   r7  r%   r   r)   )r  r<  r   r%   r   r)   )r«   r?  r   r)   r   )r«   r”   r©   r¨   r   r)   r½   r¾   r¿   rÀ   rÁ   ).r4   r5   r6   r7   r^   Ú_specifier_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASErß   rÝ   Ú__annotations__rC   rå   rç   rî   rê   rë   rÃ   r©   rÆ   rþ   r  rã   r?   rZ   r¦   r  rT   rL   r  r%  r+  r$  r3  r5  r#  r9  r;  r>  rC  r­   rÇ   rÈ   r´   r   r   r   r   r   ¶  sz   
 \ÿø
&




>

"









$




 
üü
ür   z([0-9]+)((?:a|b|c|rc)[0-9]+)r®   r¹   r°   rº   r»   c                 c  sž   � g }g }d}| D ]:}t |du r|n||ƒƒ}|du r,|r!|V  n
| |¡ | |¡ q	|js<|s8|E dH  d}|V  q	|sC| |¡ q	|sM|E dH  dS dS )z?Filter per PEP 440: exclude prereleases unless no finals exist.FNT)r–   r…   rŸ   )r®   r°   Úall_nonfinalÚarbitrary_stringsÚfound_finalr«   Úparsedr   r   r   Ú_pep440_filter_prereleases®  s0   €



€ÿrY  r%   c                 C  s^   g }|   d¡\}}}| |pd¡ | d¡D ]}t |¡}|r'| | ¡ ¡ q| |¡ q|S )a  Split version into components.

    The split components are intended for version comparison. The logic does
    not attempt to retain the original version string, so joining the
    components back with :func:`_version_join` may not produce the original
    version string.
    ú!Ú0Ú.)Ú
rpartitionr…   ÚsplitÚ_prefix_regexrà   ÚextendÚgroups)r?   r†   rE   r  Úrestr«   rJ  r   r   r   r"  Ø  s   
r"  Ú
componentsc                 C  s   | ^}}|› dd  |¡› �S )zñJoin split version components into a version string.

    This function assumes the input came from :func:`_version_split`, where the
    first component must be the epoch (either empty or numeric), and all other
    components numeric.
    rZ  r\  )Újoin)rc  rE   rb  r   r   r   r  î  s   r  Úsegmentc                   s   t ‡ fdd„dD ƒƒ S )Nc                 3  s   � | ]}ˆ   |¡V  qd S r   )râ   )Ú.0rù   ©re  r   r   Ú	<genexpr>ú  s   € 

ÿz!_is_not_suffix.<locals>.<genexpr>)rG   ÚaÚbÚrcrF   )Úanyrg  r   rg  r   r!  ù  s   
ÿr!  r^  rP   c                 C  s(   d}| D ]}|  ¡ s |S |d7 }q|S )zƒCount leading numeric components in a :func:`_version_split` result.

    >>> _numeric_prefix_len(["0", "1", "2", "a1"])
    3
    r   r   )Úisdigit)r^  Úcountre  r   r   r   r'  ÿ  s   
ÿr'  Útarget_numeric_lenc                 C  sB   t | ƒ}|| }|dkr| S g | d|… ¢dg| ¢| |d… ¢S )zÝPad a :func:`_version_split` result with ``"0"`` segments to reach
    ``target_numeric_len`` numeric components.  Suffix segments are preserved.

    >>> _left_pad(["0", "1", "a1"], 4)
    ['0', '1', '0', '0', 'a1']
    r   Nr[  )r'  )r^  ro  Únumeric_lenÚ
pad_neededr   r   r   r,    s
   &r,  Úop_entryú!tuple[CallableOperator, str, str]c                 C  sp   | \}}}|dkr|  d¡sdS dS |dv rdS |dkrdS |dkr+|  d¡s)d	S d
S |dkr1dS td|›�ƒ‚)aL  Sort key for Cost Based Ordering of specifier operators in _filter_versions.

    Operators run sequentially on a shrinking candidate set, so operators that
    reject the most versions should run first to minimize work for later ones.

    Tier 0: Exact equality (==, ===), likely to narrow candidates to one version
    Tier 1: Range checks (>=, <=, >, <), cheap and usually reject a large portion
    Tier 2: Wildcard equality (==.*) and compatible release (~=), more expensive
    Tier 3: Exact !=, cheap but rarely rejects
    Tier 4: Wildcard !=.*, expensive and rarely rejects
    rØ   rè   r   r!   )rÛ   rÚ   ro   rm   r   r×   rÙ   r   é   rÜ   rô   )ré   rõ   )rr  r  Úverrì   r   r   r   Ú_operator_cost  s   
rv  c                   @  s2  e Zd ZdZdZ		dPdQdd„ZdRdd„ZedSdd„ƒZej	dTdd„ƒZdUdd„Z
dVdd„ZdWdd„ZdWdd„ZdXd!d"„ZdYd%d&„ZdZd(d)„ZdXd*d+„Zd[d-d.„Zd\d0d1„Zd]d2d3„Zd]d4d5„Zd]d6d7„Zd^d:d;„Z		d_d`d=d>„Zej		?dadbdDdE„ƒZej		?dadcdIdE„ƒZ		d_dddMdE„Z	dedfdNdO„ZdS )gr   a…  This class abstracts handling of a set of version specifiers.

    It can be passed a single specifier (``>=3.0``), a comma-separated list of
    specifiers (``>=3.0,!=3.1``), or no specifier at all.

    Instances are safe to serialize with :mod:`pickle`. They use a stable
    format so the same pickle can be loaded in future packaging
    releases.

    .. versionchanged:: 26.2

        Added a stable pickle format. Pickles created with
        packaging 26.2+ can be unpickled with future releases.
        Backward compatibility with pickles from
        packaging < 26.2 is supported but may be removed in a future
        release.
    )Ú_canonicalizedÚ_has_arbitraryÚ_is_unsatisfiablerÊ   Ú_resolved_opsÚ_specsrÞ   NÚ
specifiersústr | Iterable[Specifier]r©   r¨   r   rA   c                 C  s€   t |tƒrdd„ | d¡D ƒ}ttt|ƒƒ| _d|v | _nt|ƒ| _tdd„ | jD ƒƒ| _t	| jƒdk| _
d| _|| _d| _dS )	a´  Initialize a SpecifierSet instance.

        :param specifiers:
            The string representation of a specifier or a comma-separated list of
            specifiers which will be parsed and normalized before use.
            May also be an iterable of ``Specifier`` instances, which will be used
            as is.
        :param prereleases:
            This tells the SpecifierSet if it should accept prerelease versions if
            applicable or not. The default of ``None`` will autodetect it from the
            given specifiers.

        :raises InvalidSpecifier:
            If the given ``specifiers`` are not parseable than this exception will be
            raised.
        c                 S  s   g | ]
}|  ¡ r|  ¡ ‘qS r   )rá   ©rf  Úsr   r   r   Ú
<listcomp>k  s    z)SpecifierSet.__init__.<locals>.<listcomp>ú,rÜ   c                 s  ó   � | ]	}d t |ƒv V  qdS ©rÜ   Nr¤   r~  r   r   r   rh  t  ó   € z(SpecifierSet.__init__.<locals>.<genexpr>r   N)r"   r%   r^  r#   Úmapr   r{  rx  rl  r$   rw  rz  rÊ   ry  )rB   r|  r©   Úsplit_specifiersr   r   r   rC   R  s   


zSpecifierSet.__init__útuple[Specifier, ...]c                 C  s8   | j stt t| jtd�¡ƒ| _d| _ d| _d| _| jS )zBDeduplicate, sort, and cache specs for order-sensitive operations.©r°   TN)	rw  r#   r  ÚfromkeysÚsortedr{  r%   rz  ry  rS   r   r   r   Ú_canonical_specs  s   zSpecifierSet._canonical_specsc                 C  s6   | j d ur| j S | jsd S tdd„ | jD ƒƒrdS d S )Nc                 s  s   � | ]}|j V  qd S r   rE  r~  r   r   r   rh  —  s   € z+SpecifierSet.prereleases.<locals>.<genexpr>T)rÊ   r{  rl  rS   r   r   r   r©   ˆ  s   
zSpecifierSet.prereleasesrN   c                 C  s   || _ d | _d S r   )rÊ   ry  rª   r   r   r   r©   œ  s   
ú)tuple[tuple[Specifier, ...], bool | None]c                 C  rý   r   )r{  rÊ   rS   r   r   r   rþ   ¡  rÿ   zSpecifierSet.__getstate__r   r   c                 C  sÎ  d | _ d | _t|tƒr–t|ƒdkr@|\}}t|tƒr@tdd„ |D ƒƒr@t|ƒr@|| _|| _t|ƒdk| _	t
dd„ |D ƒƒ| _d S t|ƒdkr–t|d tƒr–|\}}| dd¡}| d¡}t|tƒritt|td	�ƒ}t|tƒr–td
d„ |D ƒƒr–t|ƒr–|| _|| _t| jƒdk| _	t
dd„ | jD ƒƒ| _d S t|tƒrà| dd¡}| d¡}t|tƒr³tt|td	�ƒ}t|tƒràtdd„ |D ƒƒràt|ƒrà|| _|| _t| jƒdk| _	t
dd„ | jD ƒƒ| _d S td|›�ƒ‚)Nr!   c                 s  ó   � | ]}t |tƒV  qd S r   ©r"   r   r~  r   r   r   rh  ²  ó   € z,SpecifierSet.__setstate__.<locals>.<genexpr>r   c                 s  r‚  rƒ  r¤   r~  r   r   r   rh  ¸  r„  r{  r   rÊ   rˆ  c                 s  r�  r   rŽ  r~  r   r   r   rh  Ä  r�  c                 s  r‚  rƒ  r¤   r~  r   r   r   rh  Ê  r„  c                 s  r�  r   rŽ  r~  r   r   r   rh  Õ  r�  c                 s  r‚  rƒ  r¤   r~  r   r   r   rh  Û  r„  z!Cannot restore SpecifierSet from )rz  ry  r"   r#   r$   Úallr*   r{  rÊ   rw  rl  rx  r  r  Ú	frozensetrŠ  r%   r  )rB   r   Úspecsr©   r  r  r   r   r   r  §  sd   
ÿþý

ÿþý


ÿþýzSpecifierSet.__setstate__r%   c                 C  r  )a  A representation of the specifier set that shows all internal state.

        Note that the ordering of the individual specifiers within the set may not
        match the input string.

        >>> SpecifierSet('>=1.0.0,!=2.0.0')
        <SpecifierSet('!=2.0.0,>=1.0.0')>
        >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False)
        <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=False)>
        >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True)
        <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=True)>
        Nr  rÞ   rm   rV   r  r  r  r   r   r   rZ   à  s
   
ÿýzSpecifierSet.__repr__c                 C  s   d  dd„ |  ¡ D ƒ¡S )an  A string representation of the specifier set that can be round-tripped.

        Note that the ordering of the individual specifiers within the set may not
        match the input string.

        >>> str(SpecifierSet(">=1.0.0,!=1.0.1"))
        '!=1.0.1,>=1.0.0'
        >>> str(SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False))
        '!=1.0.1,>=1.0.0'
        r�  c                 s  s   � | ]}t |ƒV  qd S r   r¤   r~  r   r   r   rh     s   € z'SpecifierSet.__str__.<locals>.<genexpr>)rd  r‹  rS   r   r   r   r¦   õ  s   zSpecifierSet.__str__rP   c                 C  s   t |  ¡ ƒS r   )rR   r‹  rS   r   r   r   rT     s   zSpecifierSet.__hash__rD   úSpecifierSet | strc                 C  sš   t |tƒr
t|ƒ}nt |tƒstS tƒ }| j|j |_t|jƒdk|_| jp(|j|_d|_| j	du s8| j	|j	kr>|j	|_	|S |j	du rI| j	|_	|S t
dƒ‚)a‚  Return a SpecifierSet which is a combination of the two sets.

        :param other: The other object to combine with.

        >>> SpecifierSet(">=1.0.0,!=1.0.1") & '<=2.0.0,!=2.0.1'
        <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
        >>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1')
        <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
        r   NzFCannot combine SpecifierSets with True and False prerelease overrides.)r"   r%   r   rJ   r{  r$   rw  rx  rz  rÊ   rõ   )rB   rD   Ú	specifierr   r   r   Ú__and__  s$   




ùüÿzSpecifierSet.__and__r)   c                 C  s:   t |ttfƒrtt|ƒƒ}nt |tƒstS |  ¡ | ¡ kS )a¡  Whether or not the two SpecifierSet-like objects are equal.

        :param other: The other object to check against.

        The value of :attr:`prereleases` is ignored.

        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> (SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False) ==
        ...  SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True))
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == ">=1.0.0,!=1.0.1"
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.2")
        False
        )r"   r%   r   r   rJ   r‹  rK   r   r   r   rL   &  s
   
zSpecifierSet.__eq__c                 C  r  )z7Returns the number of specifiers in this specifier set.)r$   r{  rS   r   r   r   Ú__len__@  rû   zSpecifierSet.__len__úIterator[Specifier]c                 C  r  )zð
        Returns an iterator over all the underlying :class:`Specifier` instances
        in this specifier set.

        >>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str)
        [<Specifier('!=1.0.1')>, <Specifier('>=1.0.0')>]
        )Úiterr{  rS   r   r   r   Ú__iter__D  s   
zSpecifierSet.__iter__r€   c                 C  sP   | j }d}|D ]}|du r| ¡ }qt|| ¡ ƒ}|s nq|du r&tdƒ‚|S )a  Intersect all specifiers into a single list of version ranges.

        Returns an empty list when unsatisfiable.  ``===`` specs are
        modeled as full range; string matching is checked separately
        by :meth:`_check_arbitrary_unsatisfiable`.
        Nz _get_ranges called with no specs)r{  rî   r�   ÚRuntimeError)rB   r’  r†   r  r   r   r   Ú_get_rangesN  s   
ÿzSpecifierSet._get_rangesc                 C  sX   | j }|dur	|S | jsd| _ dS |  ¡  }|s|  ¡ }|s'| jdu r'|  ¡ }|| _ |S )a¦  Check whether this specifier set can never be satisfied.

        Returns True if no version can satisfy all specifiers simultaneously.

        >>> SpecifierSet(">=2.0,<1.0").is_unsatisfiable()
        True
        >>> SpecifierSet(">=1.0,<2.0").is_unsatisfiable()
        False
        >>> SpecifierSet("").is_unsatisfiable()
        False
        >>> SpecifierSet("==1.0,!=1.0").is_unsatisfiable()
        True
        NF)ry  r{  r›  Ú_check_arbitrary_unsatisfiabler©   Ú_check_prerelease_only_ranges)rB   Úcachedr†   r   r   r   Úis_unsatisfiabled  s   
zSpecifierSet.is_unsatisfiablec                 C  s^   |   ¡ D ](\}}t|jƒ}|du r dS |jdu s||jk r! dS ||jkr,|jr, dS qdS )z€With prereleases=False, check if every range contains only
        pre-release versions (which would be excluded from matching).NFT)r›  r¢   r?   rb   )rB   r|   r}   Únearestr   r   r   r�  …  s   
€z*SpecifierSet._check_prerelease_only_rangesc                   s®   dd„ | j D ƒ}|sdS |d j ¡ ‰t‡fdd„|dd… D ƒƒr$d	S t|d jƒ‰ | jdu r9ˆ dur9ˆ jr9d	S d
d„ | j D ƒ}|sEdS ˆ du rKd	S t‡ fdd„|D ƒƒ S )a  Check === (arbitrary equality) specs for unsatisfiability.

        === uses case-insensitive string comparison, so the only candidate
        that can match ``===V`` is the literal string V.  This method
        checks whether that candidate is excluded by other specifiers.
        c                 S  s   g | ]	}|j d kr|‘qS ©rÜ   ©rã   r~  r   r   r   r€  ™  ó    z?SpecifierSet._check_arbitrary_unsatisfiable.<locals>.<listcomp>Fr   c                 3  s   � | ]
}|j  ¡ ˆ kV  qd S r   )r?   r|   r~  )Úfirstr   r   rh  Ÿ  s   € z>SpecifierSet._check_arbitrary_unsatisfiable.<locals>.<genexpr>r   NTc                 S  s   g | ]	}|j d kr|‘qS r¡  r¢  r~  r   r   r   r€  ¯  r£  c                 3  s   � | ]}|  ˆ ¡V  qd S r   rA  r~  )Ú	candidater   r   rh  ·  r�  )r{  r?   r|   rl  r–   r©   rŸ   r�  )rB   rÖ   Ústandardr   )r¥  r¤  r   rœ  ’  s$   
ÿz+SpecifierSet._check_arbitrary_unsatisfiabler«   r”   c                 C  r@  )aq  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

        This is used for the ``in`` operator and behaves the same as
        :meth:`contains` with no ``prereleases`` argument passed.

        >>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1")
        False
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
        True
        rA  rB  r   r   r   rC  ¹  rD  zSpecifierSet.__contains__Ú	installedc                 C  sX   t |ƒ}|dur|r|jrd}|du s| jrt|tƒs|}n|}tt| j|g|d�ƒƒS )a‡  Return whether or not the item is contained in this SpecifierSet.

        :param item:
            The item to check for, which can be a version string or a
            :class:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this SpecifierSet. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases, as there are no other versions.
        :param installed:
            Whether or not the item is installed. If set to ``True``, it will
            accept prerelease versions even if the specifier does not allow them.

        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.2.3")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains(Version("1.2.3"))
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.0.1")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False).contains("1.3.0a1")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
        True
        NTrE  )r–   rŸ   rx  r"   r   r)   r  r´   )rB   r«   r©   r§  r?   Ú
check_itemr   r   r   r­   Î  s    zSpecifierSet.contains.r®   r¯   r°   r±   c                 C  r²   r   r   r³   r   r   r   r´   û  rµ   zSpecifierSet.filterr¶   r·   r¸   c                 C  r²   r   r   r³   r   r   r   r´     rµ   r¹   rº   r»   c                   s¸   |du r| j dur| j }| jrAt| jƒdkr(| jd j||du r"dn|ˆ d�}n| j|ˆ |du r2dn|d�}|dur<|S t|ˆ ƒS |du rIt|ƒS |du rW‡ ‡fdd	„|D ƒS t|ˆ ƒS )
ac  Filter items in the given iterable, that match the specifiers in this set.

        :param iterable:
            An iterable that can contain version strings and :class:`Version` instances.
            The items in the iterable will be filtered according to the specifier.
        :param prereleases:
            Whether or not to allow prereleases in the returned iterator. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases if there are no other versions.
        :param key:
            A callable that takes a single argument (an item from the iterable) and
            returns a version string or :class:`Version` instance to be used for
            filtering.

        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
        ['1.3']
        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", Version("1.4")]))
        ['1.3', <Version('1.4')>]
        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"]))
        ['1.5a1']
        >>> list(SpecifierSet(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        >>> list(SpecifierSet(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']
        >>> list(SpecifierSet(">=1.2.3").filter(
        ... [{"ver": "1.2"}, {"ver": "1.3"}],
        ... key=lambda x: x["ver"]))
        [{'ver': '1.3'}]

        An "empty" SpecifierSet will filter items based on the presence of prerelease
        versions in the set.

        >>> list(SpecifierSet("").filter(["1.3", "1.5a1"]))
        ['1.3']
        >>> list(SpecifierSet("").filter(["1.5a1"]))
        ['1.5a1']
        >>> list(SpecifierSet("", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']
        >>> list(SpecifierSet("").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        Nr   r   T)r©   r°   rE  Fc                 3  s:   � | ]}t ˆ d u r|nˆ |ƒƒ ‰d u sˆjs|V  qd S r   )r–   rŸ   )rf  r«   ©r°   r?   r   r   rh  ^  s   € ÿþýüz&SpecifierSet.filter.<locals>.<genexpr>)r©   r{  r$   r´   Ú_filter_versionsrY  r˜  )rB   r®   r©   r°   Úfilteredr   r©  r   r´     s0   2
ýý
þ
c                 #  s¬   � | j du rtdd„ | jD ƒtd�| _ | j }|du }|D ]7‰ tˆdu r%ˆ nˆˆ ƒƒ‰ˆdu r=t‡ fdd„|D ƒƒr<ˆ V  q|rCˆjrCqt‡ ‡‡fdd„|D ƒƒrSˆ V  qdS )a?  Filter versions against all specifiers in a single pass.

        Uses Cost Based Ordering: specifiers are sorted by _operator_cost so
        that cheap range operators reject versions early, avoiding expensive
        wildcard or compatible operators on versions that would have been
        rejected anyway.
        Nc                 s  s&   � | ]}|  |j¡|j|jfV  qd S r   )r  rã   r?   )rf  r   r   r   r   rh  {  s
   € ÿ
ÿz0SpecifierSet._filter_versions.<locals>.<genexpr>rˆ  Fc                 3  s2   � | ]\}}}|d kot ˆ ƒ ¡ | ¡ kV  qdS rƒ  r=  )rf  r  ru  rì   )r«   r   r   rh  ‰  s
   € ÿ
ÿc                 3  sL   � | ]!\}}}|d krt ˆdu rˆ nˆˆ ƒƒ ¡ | ¡ kn|ˆ|ƒV  qdS rƒ  r=  )rf  Úop_fnru  rì   ©r«   r°   rX  r   r   rh  �  s   € þ$ÿ
ý)rz  rŠ  r{  rv  r–   r�  rŸ   )rB   r®   r°   r©   ÚopsÚexclude_prereleasesr   r­  r   rª  k  s4   €
þûþ€
ü€ízSpecifierSet._filter_versionsrK  )r|  r}  r©   r¨   r   rA   )r   r‡  r¼   rM  )r   rŒ  rN  r]   r\   )rD   r“  r   r   r[   )r   r—  rL  )r   r)   )r«   r”   r   r)   rÀ   )r«   r”   r©   r¨   r§  r¨   r   r)   r½   r¾   r¿   rÁ   r   )r®   r¹   r°   rº   r©   r¨   r   r»   )r4   r5   r6   r7   r^   rC   r‹  rÃ   r©   rÆ   rþ   r  rZ   r¦   rT   r•  rL   r–  r™  r›  rŸ  r�  rœ  rC  r­   rÇ   rÈ   r´   rª  r   r   r   r   r   6  sR    ý
-	


9



!





!

'ü-üü
üdür   )r   r   )r   r   r   r    )r'   r   r   r(   )r/   r0   r   r0   )r|   r`   r}   rw   r   r)   )r   r€   r�   r€   r   r‚   )r?   r   r   r   )r?   r”   r   r•   )rH   rc   r   r•   )r®   r¹   r°   rº   r   r»   )r?   r%   r   r   )rc  r   r   r%   )re  r%   r   r)   )r^  r   r   rP   )r^  r   ro  rP   r   r   )rr  rs  r   rP   )Lr7   Ú
__future__r   rÄ   r8   Ú	functoolsr  rP  ÚsysrÇ   r   r   r   r   r   r   r	   r
   r   Úutilsr   r?   r   r   Úversion_infor   Útyping_extensionsr   r   r&   r*   r+   r%   r”   r,   r)   r  r.   rT  r2   ÚEnumr3   Útotal_orderingr<   r`   rw   rc   r#   Ú_VersionRangerð   rñ   r{   r~   r�   r‘   r“   r–   r™   rœ   rž   r¢   rõ   r   ÚABCMetar   r   rQ  r_  rY  r"  r  r!  r'  r,  rv  r   r   r   r   r   Ú<module>   s‚   ,



	
>((



	



	


R     
z

*




