+
     hw  c                  st   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHtH	t	H
t
Ht ^RIHt ^RIHt ]]]3,          t]
! R]R7      t]]].]3,          tR R	 lt ! R
 R]4      t ! R R]P0                  R7      t ! R R]4      t]P6                  ! R4      tR R ltR R ltR R ltR R lt  ! R R]4      t!R# )z
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
)annotationsN)CallableIterableIteratorTypeVarUnion)canonicalize_version)VersionUnparsedVersionVar)Zboundc                    V ^8  d   QhRRRR/# )   versionUnparsedVersionreturnr    format   "9/usr/lib/python3.14/site-packages/packaging/specifiers.py__annotate__r      s      _      c                sH    \        V \        4      '       g   \        V 4      p V # N)
isinstancer   )r      &r   _coerce_versionr      s    gw'''"Nr   c                  s    ] tR t^ tRtRtR# )InvalidSpecifierz
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'
r   N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r       s    r   r   c                  sN   ] tR t^,t]P
                  R R l4       t]P
                  R R l4       t]P
                  R R l4       t]	]P
                  R R l4       4       t
]
P                  R	 R
 l4       t
]P
                  RR R ll4       t]P
                  RR R ll4       tRtR# )BaseSpecifierc                   V ^8  d   QhRR/# r
   r   strr   r   r   r   r   BaseSpecifier.__annotate__.   s       r   c                    R# )zv
Returns the str representation of this Specifier-like object. This
should be representative of the Specifier itself.
Nr   selfr   r   __str__ZBaseSpecifier.__str__-       r   c               r!   r
   r   Zintr   r   r   r   r   r$   5   s      # r   c                r%   )z6
Returns a hash value for this Specifier-like object.
Nr   r&   r   r   __hash__ZBaseSpecifier.__hash__4   r)   r   c               r	   r
   otherZobjectr   boolr   r   r   r   r   r$   ;   s      F t r   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   r'   r-      &&r   __eq__ZBaseSpecifier.__eq__:   r)   r   c               r!   r
   r   bool | Noner   r   r   r   r   r$   E   s      [ r   c                r%   )zWhether 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   r&   r   r   prereleasesBaseSpecifier.prereleasesC   r)   r   c               r	   r
   valuer.   r   Noner   r   r   r   r   r$   M   s       $ r   c                r%   )zASetter for :attr:`prereleases`.

:param value: The value to set.
Nr   r'   r7   r0   r   r4   r5   L   r)   r   Nc               $    V ^8  d   QhRRRRRR/# )r
   itemr#   r4   r3   r   r.   r   r   r   r   r   r$   T   s!      S { d r   c                r%   )zB
Determines if the given item is contained within this specifier.
Nr   )r'   r;   r4      &&&r   containsZBaseSpecifier.containsS   r)   r   c               r:   r
   iterablezIterable[UnparsedVersionVar]r4   r3   r   zIterator[UnparsedVersionVar]r   r   r   r   r   r$   Z   s$      4CN	%r   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?   r4   r<   r   filterZBaseSpecifier.filterY   r)   r   r   r   )r   r   r   r   abcZabstractmethodr(   r+   r1   propertyr4   setterr=   r@   r   r   r   r   r    r    ,   s      	 
 	       	 
 	 r   r    )Z	metaclassc                  s&   ] tR t^ctRtRtRt]P                  ! R],           ],           R,           ]P                  ]P                  ,          4      tRRRR	R
RRRRRRRRRRR/tRDR R llt]R R l4       t]P                   R R l4       t]R R l4       t]R R  l4       tR! R" ltR# R$ lt]R% R& l4       tR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 ltR7 R8 ltR9 R: ltR; R< lt R= R> lt!RER? R@ llt"RERA RB llt#RCt$R# )F	Specifiera+  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).
z8
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        a  
        (?P<version>
            (?:
                # 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 .*
                    |
                    (?:                                  # 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
                    (?:\+[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.
                (?<!==|!=|~=)         # We have special cases for these
                                      # operators so we want to make sure they
                                      # don't match here.

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # 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
            )
        )
        z^\s*z\s*$~=Z
compatible==Zequalz!=Z	not_equal<=Zless_than_equal>=Zgreater_than_equal<Z	less_than>Zgreater_than===Z	arbitraryNc               r:   )r
   specr#   r4   r3   r   r8   r   r   r   r   r   Specifier.__annotate__   s!     ( (S (K (4 (r   c                s    V P                   P                  V4      pV'       g   \        RV: 24      hVP                  R4      P	                  4       VP                  R4      P	                  4       3V n        W n        R# )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: operatorr   N)_regexsearchr   Zgroupstrip_spec_prereleases)r'   rL   r4   match   &&& r   __init__ZSpecifier.__init__   sk     ""4("%8#ABB KK
#))+KK	"((*'

 (r   c               r!   )r
   r   r.   r   r   r   r   r   rM      s      T r   c                	s    V P                   e   V P                   # V P                  w  rVR9   dA   VR8X  d   VP                  R4      '       d   VR R p\        V4      P                  '       d   R# R# )NrF   .*TF)rF   rH   rG   rE   rK   rJ   rI   )rS   rR   endswithr   is_prerelease)r'   rN   r      &  r   r4   Specifier.prereleases   sq     ($$$
 !JJ@@ 4G$4$4T$:$:!#2, w---r   c               r	   r6   r   r   r   r   r   rM          " " "$ "r   c                	    Wn         R # r   rS   r9   r0   r   r4   r\         !r   c               r!   r"   r   r   r   r   r   rM     s      # r   c                s(    V P                   ^ ,          # )zHThe operator of this specifier.

>>> Specifier("==1.2.3").operator
'=='
rR   r&   r   r   rN   ZSpecifier.operator       zz!}r   c               r!   r"   r   r   r   r   r   rM     s       r   c                s(    V P                   ^,          # )zIThe version of this specifier.

>>> Specifier("==1.2.3").version
'1.2.3'
ra   r&   r   r   r   ZSpecifier.version  rb   r   c               r!   r"   r   r   r   r   r   rM   &  s     B B# Br   c                s    V P                   e   RV P                  : 2MRpRV P                  P                   R\	        V 4      : V R2# )a  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)>
, prereleases= rI   Z()>)rS   r4   	__class__r   r#   r'   Zpre   & r   __repr__ZSpecifier.__repr__&  sU       , T--01 	 4>>**+1SYM#bAAr   c               r!   r"   r   r   r   r   r   rM   8  s     * * *r   c                s6    RP                   ! V P                  !  # )zA 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{}{})r   rR   r&   r   r   r(   ZSpecifier.__str__8  s     }}djj))r   c               r!   )r
   r   ztuple[str, str]r   r   r   r   r   rM   C  s     0 0 0r   c                	s    \        V P                  ^,          V P                  ^ ,          R8g  R7      pV P                  ^ ,          V3# )i   rE   Zstrip_trailing_zero)r   rR   )r'   Zcanonical_versionrh   r   _canonical_specZSpecifier._canonical_specB  s>    0JJqM!%A$!6
 zz!}///r   c               r!   r*   r   r   r   r   r   rM   J  s     * *# *r   c                	,    \        V P                  4      # r   )hashrk   r&   r   r   r+   ZSpecifier.__hash__J  s    D(())r   c               r	   r,   r   r   r   r   r   rM   M  s     = =F =t =r   c                s   \        V\        4      '       d    V P                  \        V4      4      pM!\        WP                  4      '       g   \        # V P
                  VP
                  8H  #   \         d
    \        u # i ; i)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#   rf   r   NotImplementedrk   r/   r0   r   r1   ZSpecifier.__eq__M  sm    & eS!!&s5z2 E>>22!!##u'<'<<< $ &%%&s   A- -B Bc               r	   )r
   opr#   r   CallableOperatorr   r   r   r   r   rM   j  s     ! ! !(8 !r   c                	sF    \        V R V P                  V,           24      pV# )Z	_compare_)Zgetattr
_operators)r'   ro   operator_callable   && r   _get_operatorZSpecifier._get_operatorj  s+    .5Idoob123/
 ! r   c               r:   r
   prospectiver   rL   r#   r   r.   r   r   r   r   r   rM   p  s!     
 
w 
c 
d 
r   c           
     	s    \        \        \        P                  ! \        \        V4      4      4      R R 4      pVR,          pV P                  R4      ! W4      ;'       d    V P                  R4      ! W4      # )NrW   rH   rF   i)_version_joinlist	itertools	takewhile_is_not_suffix_version_splitrt   )r'   rv   rL   prefixrU   r   _compare_compatibleZSpecifier._compare_compatiblep  ss     $$^^D5IJKCRP

 	$!!$': 
 
t?Q?QRV?W@
 	
r   c               r:   ru   r   r   r   r   r   rM     s!     &/ &/' &/ &/ &/r   c                	sT   VP                  R 4      '       d]   \        VP                  RR7      p\        VRR RR7      p\        V4      p\        V4      p\	        We4      w  rxVR\        V4       p	W8H  # \        V4      p
V
P                  '       g   \        VP                  4      pW8H  # )rW   Frj   NrX   )rY   r   publicr|   _pad_versionlenr   local)r'   rv   rL   Znormalized_prospectiveZnormalized_specZ
split_specZsplit_prospectiveZpadded_prospective_Zshortened_prospectiveZspec_versions   &&&        r   _compare_equalZSpecifier._compare_equal  s    ==%9""&" 349RWXO (8J
 !//E F %11B$O!
 %77HZ$I!(66 #4=L
  %%%%k&8&89..r   c               r:   ru   r   r   r   r   r   rM     s!     : :g :S :T :r   c                	s.    V P                  W4      '       * # r   )r   r'   rv   rL   r<   r   _compare_not_equalZSpecifier._compare_not_equal  s    &&{999r   c               r:   ru   r   r   r   r   r   rM     s!     < <G <3 <4 <r   c                	sD    \        VP                  4      \        V4      8*  # r   r   r   r   r<   r   _compare_less_than_equalZ"Specifier._compare_less_than_equal       {))*gdm;;r   c               r:   ru   r   r   r   r   r   rM     s!     < <w <c <d <r   c                	sD    \        VP                  4      \        V4      8  # r   r   r   r<   r   _compare_greater_than_equalZ%Specifier._compare_greater_than_equal  r   r   c               r:   r
   rv   r   spec_strr#   r   r.   r   r   r   r   r   rM     s!      g   r   c                	s    \        V4      pW8  g   R # VP                  '       gB   VP                  '       d0   \        VP                  4      \        VP                  4      8X  d   R # R# FT)r   rZ   base_versionr'   rv   r   rL   rU   r   _compare_less_thanZSpecifier._compare_less_than  sX     x 
 ! !!!k&?&?&?{//0GD<M<M4NN
 r   c               r:   r   r   r   r   r   r   rM     s!       C D r   c                	sL   \        V4      pW8  g   R # VP                  '       gB   VP                  '       d0   \        VP                  4      \        VP                  4      8X  d   R # VP                  e0   \        VP                  4      \        VP                  4      8X  d   R # R# r   )r   Zis_postreleaser   r   r   rU   r   _compare_greater_thanZSpecifier._compare_greater_than  s     x 
 ! """{'A'A'A{//0GD<M<M4NN ({//0GD<M<M4NN
 r   c               r:   ru   r   r   r   r   r   rM     s!     = =g =S =T =r   c                	sh    \        V4      P                  4       \        V4      P                  4       8H  # r   )r#   Zlowerr   r<   r   _compare_arbitraryZSpecifier._compare_arbitrary  s&    ;%%'3t9??+<<<r   c               r	   )r
   r;   zstr | Versionr   r.   r   r   r   r   r   rM     s     # # #4 #r   c                $    V P                  V4      # )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")
False
>>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
True
r=   r'   r;   r0   r   __contains__ZSpecifier.__contains__      & }}T""r   c               r:   )r
   r;   r   r4   r3   r   r.   r   r   r   r   r   rM   	  s'     *@ *@_ *@; *@RV *@r   c                s    Vf   V P                   p\        V4      pVP                  '       d   V'       g   R# V P                  V P                  4      pV! W0P
                  4      # )a  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 uses :attr:`prereleases` to determine
    whether or not prereleases are allowed.

>>> 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")
False
>>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1")
True
>>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True)
True
F)r4   r   rZ   rt   rN   r   )r'   r;   r4   Znormalized_itemrr      &&&  r   r=   ZSpecifier.contains	  sZ    4 **K *$/
 ((( /3.@.@.O ,,??r   c               r:   r>   r   r   r   r   r   rM   5  s$     ; ;4;CN;	%;r   c              #  sT  "   Rp. pRVe   TMR/pV Fn  p\        V4      pV P                  ! V3/ VB '       g   K)  VP                  '       d.   V'       g&   V P                  '       g   VP	                  V4       Kh  RpVx  Kp  	  V'       g   V'       d   V F  pVx  K	  	  R# R# R# 5i)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 be intelligently decide whether to allow
    prereleases or not (based on the :attr:`prereleases` attribute, and
    whether the only versions matching are prereleases).

This method is smarter than just ``filter(Specifier().contains, [...])``
because it implements the rule from :pep:`440` that a prerelease item
SHOULD be accepted if no other versions match the given specifier.

>>> 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']
Fr4   NT)r   r=   rZ   r4   append)r'   r?   r4   Zyieldedfound_prereleasesZkwr   parsed_version   &&&     r   r@   ZSpecifier.filter5  s     < K,C[N  G,W5N}}^2r22 "///4#3#3#3%,,W5 #G!M  ( ,, - -ws(   5B(B(B(B(($B(B(B()rS   rR   rd   Nr   )%r   r   r   r   r   Z_operator_regex_strZ_version_regex_strrecompileZVERBOSEZ
IGNORECASErO   rq   rV   rB   r4   rC   rN   r   ri   r(   rk   r+   r1   rt   r~   r   r   r   r   r   r   r   r   r=   r@   r   r   r   r   rD   rD   c   sH   \| ZZ%%(::WD


R]]"F 	lgk"[^{	J(4  . " "    B$* 0 0*=:!
(&/P:<<0<=#**@X; ;r   rD   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c               r	   )r
   r   r#   r   	list[str]r   r   r   r   r   r   v  s      C I r   c                s6   . pV P                  R4      w  r#pTP                  T;'       g    R4       VP                  R4       FR  p\        P	                  V4      pV'       d"   VP                  VP                  4       4       KA  VP                  V4       KT  	  V# )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.)Z
rpartitionr   split_prefix_regexrP   ZextendZgroups)r   Zresultepochr   restr;   rT   s   &      r   r|   r|   v  sy     F'',NEd
MM%,,3

3$$T*MM%,,.)MM$   Mr   c               r	   )r
   
componentsr   r   r#   r   r   r   r   r   r     s     ' 'i 'C 'r   c                s4    V vrV RRP                  V4       2# )zJoin 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.
r   r   )join)r   r   r   r[   r   rw   rw     s%     LEWAchhtn%&&r   c               r	   )r
   segmentr#   r   r.   r   r   r   r   r   r     s      C D r   c                s   a  \         ;QJ d)    V 3R  lR 4       F  '       g   K   R'       * # 	  R'       * # ! V 3R  lR 4       4      '       * # )c              3  sF   <"   T F  pSP                  V4      x  K  	  R # 5ir   )Z
startswith).0r}   r   s   & r   	<genexpr>Z!_is_not_suffix.<locals>.<genexpr>  s#      1Pv6""1Ps   !TF)ZdevZaZbZrcZpost)any)r   s   fr   r{   r{     sM    s 1Pss  s  s 1P   r   c               s$    V ^8  d   QhRRRRRR/# )r
   leftr   rightr   ztuple[list[str], list[str]]r   r   r   r   r   r     s"      y  7R r   c                s$   . . r2VP                  \        \        P                  ! R  V 4      4      4       VP                  \        \        P                  ! R V4      4      4       VP                  V \	        V^ ,          4      R 4       VP                  V\	        V^ ,          4      R 4       VP                  ^R.\        ^ \	        V^ ,          4      \	        V^ ,          4      ,
          4      ,          4       VP                  ^R.\        ^ \	        V^ ,          4      \	        V^ ,          4      ,
          4      ,          4       \        \        P                  P                  V4      4      \        \        P                  P                  V4      4      3# )c                "    V P                  4       # r   ZisdigitZxr   r   <lambda>_pad_version.<locals>.<lambda>  s
    r   c                r   r   r   r   r   r   r   r     s
    !))+r   Nr   )	r   rx   ry   rz   r   ZinsertZmaxZchainZfrom_iterable)r   r   Z
left_splitZright_splits   &&  r   r   r     s3    " d9../DdKLMtI//0EuMNO d3z!}-/01uSQ0234 a#QKN(;c*Q->P(P!QQRq3%#aZ]);c+a.>Q)Q"RRS 	Y__**:67Y__**;78 r   c                  s    ] tR tRtRtRR R llt]R R l4       t]P                  R R	 l4       tR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R R lltR!R R lltRtR# )"SpecifierSeti  zThis 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.
Nc               r:   )r
   
specifierszstr | Iterable[Specifier]r4   r3   r   r8   r   r   r   r   r   SpecifierSet.__annotate__  s(     $( $(-$( !$( 
	$(r   c                s0   \        V\        4      '       de   VP                  R4       Uu. uF*  q3P                  4       '       g   K  VP                  4       NK,  	  pp\	        \        \        V4      4      V n        M\	        V4      V n        W n        R# u upi )aL  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.
,N)	r   r#   r   rQ   	frozensetZmaprD   _specsrS   )r'   r   r4   sZsplit_specifiersr   r   rV   ZSpecifierSet.__init__  su    , j#&& 4>3C3CC3HV3HaGGI		3HV $C	3C$DEDK $J/DK (  Ws   BBc               r!   r2   r   r   r   r   r   r     s     7 7[ 7r   c                	s    V P                   e   V P                   # V P                  '       g   R # \        ;QJ d&    R V P                   4       F  '       g   K   R# 	  R# ! R V P                   4       4      # )Nc              3  s8   "   T F  qP                   x  K  	  R # 5ir   r4   r   r   rh   r   r   Z+SpecifierSet.prereleases.<locals>.<genexpr>  s     6+Q==+   TF)rS   r   r   r&   r   r   r4   SpecifierSet.prereleases  s]     ($$$
 {{{ s6$++6ss6s6s6$++666r   c               r	   r6   r   r   r   r   r   r     r]   r   c                	r^   r   r_   r9   r0   r   r4   r     r`   r   c               r!   r"   r   r   r   r   r   r     s     5 5# 5r   c                sf    V P                   e   RV P                  : 2MRpR\        V 4      : V R2# )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)>
rc   rd   z<SpecifierSet(re   )rS   r4   r#   rg   rh   r   ri   ZSpecifierSet.__repr__  sD       , T--01 	  D	}SE44r   c               r!   r"   r   r   r   r   r   r   	  s     = = =r   c                sX    RP                  \        R V P                   4       4      4      # )a6  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              3  s8   "   T F  p\        V4      x  K  	  R # 5ir   )r#   r   rh   r   r   Z'SpecifierSet.__str__.<locals>.<genexpr>  s     ;{!s1vv{r   )r   Zsortedr   r&   r   r   r(   ZSpecifierSet.__str__	  s"     xx;t{{;;<<r   c               r!   r*   r   r   r   r   r   r     s     ! !# !r   c                	rl   r   )rm   r   r&   r   r   r+   ZSpecifierSet.__hash__  s    DKK  r   c               r	   )r
   r-   zSpecifierSet | strr   r   r   r   r   r   r   r     s      / L r   c                s   \        V\        4      '       d   \        V4      pM\        V\        4      '       g   \        # \        4       p\	        V P
                  VP
                  ,          4      Vn        V P                  f"   VP                  e   VP                  Vn        V# V P                  e"   VP                  f   V P                  Vn        V# V P                  VP                  8X  d   V P                  Vn        V# \        R4      h)aR  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')>
zFCannot combine SpecifierSets with True and False prerelease overrides.)r   r#   r   rn   r   r   rS   
ValueError)r'   r-   Z	specifierrs   r   __and__ZSpecifierSet.__and__  s     eS!! 'EE<00!! N	$T[[5<<%?@	$););)G%*%7%7I"  *u/A/A/I%)%6%6I"  %"4"44%)%6%6I" 	 X r   c               r	   r,   r   r   r   r   r   r   8  s     + +F +t +r   c                s    \        V\        \        34      '       d   \        \        V4      4      pM\        V\        4      '       g   \        # V P
                  VP
                  8H  # )a1  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#   rD   r   rn   r   r/   r0   r   r1   ZSpecifierSet.__eq__8  sJ    & ec9-.. U,EE<00!!{{ell**r   c               r!   r*   r   r   r   r   r   r   R  s          r   c                rl   )z7Returns the number of specifiers in this specifier set.)r   r   r&   r   r   __len__ZSpecifierSet.__len__R  s    4;;r   c               r!   )r
   r   zIterator[Specifier]r   r   r   r   r   r   V  s     ! !- !r   c                rl   )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   r&   r   r   __iter__ZSpecifierSet.__iter__V  s     DKK  r   c               r	   )r
   r;   r   r   r.   r   r   r   r   r   r   `  s     # # #T #r   c                r   )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 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")
False
>>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
True
r   r   r0   r   r   ZSpecifierSet.__contains__`  r   r   c               s(    V ^8  d   QhRRRRRRRR/# )r
   r;   r   r4   r3   	installedr   r.   r   r   r   r   r   r   u  s8     7S 7S7S !7S 	7S
 
7Sr   c                s  aa \        S\        4      '       g   \        S4      oSf   V P                  oS'       g   SP                  '       d   R# V'       d(   SP                  '       d   \        SP                  4      o\
        ;QJ d*    VV3R lV P                   4       F  '       d   K   R# 	  R# ! VV3R lV P                   4       4      # )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 uses :attr:`prereleases` to determine
    whether or not prereleases are allowed.

>>> 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")
False
>>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True).contains("1.3.0a1")
True
>>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
True
Fc              3  sH   <"   T F  qP                  SSR 7      x  K  	  R# 5i)r   Nr   )r   r   r;   r4   s   & r   r   Z(SpecifierSet.contains.<locals>.<genexpr>  s     Rk::d:<<ks   "T)r   r   r4   rZ   r   Zallr   )r'   r;   r4   r   s   &ff&r   r=   ZSpecifierSet.containsu  s    < $((4=D
 **K t111+++4,,-D sRdkkRssRsRsRdkkRRRr   c               r:   r>   r   r   r   r   r   r     s)     M" M"4M"CNM"	%M"r   c                s   Vf   V P                   pV P                  '       d;   V P                   F  pVP                  V\        V4      R7      pK!  	  \	        V4      # . p. pV FV  p\        V4      pVP                  '       d&   V'       g   V'       g   VP                  V4       KC  KE  VP                  V4       KX  	  V'       g   V'       d   Vf   \	        V4      # \	        V4      # )a.  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 be intelligently decide whether to allow
    prereleases or not (based on the :attr:`prereleases` attribute, and
    whether the only versions matching are prereleases).

This method is smarter than just ``filter(SpecifierSet(...).contains, [...])``
because it implements the rule from :pep:`440` that a prerelease item
SHOULD be accepted if no other versions match the given specifier.

>>> 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"]))
[]
>>> 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']

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']
r   )r4   r   r@   r.   r   r   rZ   r   )r'   r?   r4   rL   Zfilteredr   r;   r   r   r   r@   ZSpecifierSet.filter  s    X **K
 ;;;;;xT+=N;O $>!
 24H:< !0!6 "///#)006 $ OOD) !  1k6I-..>!r   )rS   r   r   )NNr   )r   r   r   r   r   rV   rB   r4   rC   ri   r(   r+   r   r1   r   r   r   r=   r@   r   r   r   r   r   r     sv    $(L 7 7  " "5*=!>+4 !#*7SrM" M"r   r   )"r   Z
__future__r    rA   ry   r   Ztypingr   r   r   r   r   Zutilsr   r   r   r#   r   r   r.   rp   r   r   r   ZABCMetar    rD   r   r   r|   rw   r{   r   r   r   r   r   <module>r      s    # 
  	 ? ? ' %1I WcND01 	z 	4ckk 4nM M` 

<=,'*I"= I"r   