biZUdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZmZejdkrdd l mZne rdd lmZgd Zd]d Zd^dZd_dZedZeee fZ!ede!Z"e ee ge#fZ$edZ%de&d<d`dZ'Gddej(Z)ej*Gd d!Z+ej*Gd"d#Z,ej*Gd$d%Z-e j reee+dfZ.e/e,e-fZ0e,dd&Z1e-dd&Z2e1e2ffZ3d'e&d(<dad,Z4dbd1Z5dcd4Z6dcd5Z7ddd8Z8dcd9Z9dcd:Z:dcd;Z;ded>Z<Gd?d@e=Z>GdAdBej?CZ@GdDdEe@ZAejBdFZCdfdLZDdgdNZEdhdPZFdidRZGdjdUZHdkdWZIdldZZJGd[d\e@ZKdS)mz .. testsetup:: from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier from packaging.version import Version ) annotationsN) TYPE_CHECKINGAnyCallableFinalIterableIteratorSequenceTypeVarUnion)canonicalize_version)InvalidVersionVersion) ) TypeGuard) BaseSpecifierInvalidSpecifier Specifier SpecifierSetreturn list[str]ctSN)__all__l/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/packaging/specifiers.py__dir__r 0s NrspecobjectTypeGuard[tuple[str, str]]ct|toHt|dko5t|dtot|dtS)Nrr ) isinstancetuplelenstr)r!s r_validate_specr*4sT4 % IIN % tAw $ $ % tAw $ $ rpreTypeGuard[bool | None]c4|dupt|tSr)r&bool)r+s r _validate_prer/=s $; /*S$///rTUnparsedVersionVar)boundz0.dev0zFinal[Version] _MIN_VERSIONreleasetuple[int, ...]ct|}|dkr)||dz dkr|dz}|dkr||dz dk|t|kr|n |d|S)zDStrip trailing zeros from a release tuple for normalized comparison.r rN)r()r4ends r _trim_releaser8Jsr g,,C ''gcAg&!++ q ''gcAg&!++S\\))77wtt}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_releaseversionrGrkindr:rNonecT||_||_t|j|_dSr)rGrEr8r4rF)selfrGrHs r__init__z_BoundaryVersion.__init__qs(  -go > >rotherr.c*|j}|j|jkr-t|j|jkr|j|jksdS|jtjkr |j |j ko|j |j kS|j |j kp|j duS)z6Is ``other`` a version that this boundary sorts above?FN) rGepochr8r4rFr+rEr:rApostdev)rKrMvs r _is_familyz_BoundaryVersion._is_familyvs L K17 " "em,,0EEE QU""5 :3 3 3:'>EI,> >yAE!;UZt%;;rr"czt|tr |j|jko|j|jkStSr)r&rDrGrENotImplementedrKrMs r__eq__z_BoundaryVersion.__eq__s9 e- . . O<5=0NTZ5;5N Nr_BoundaryVersion | Versionct|tr:|j|jkr|j|jkS|jj|jjkS|| o |j|kSr)r&rDrGrEvaluerSrVs r__lt__z_BoundaryVersion.__lt__si e- . . 8|u},,|em33:#ek&77 7??5)))BdlU.BBrintc8t|j|jfSr)hashrGrErKs r__hash__z_BoundaryVersion.__hash__sT\4:.///rr)cJ|jjd|jd|jjdS)N(z, )) __class__r;rGrEnamer_s r__repr__z_BoundaryVersion.__repr__s,.)PPDLPPdjoPPPPrN)rGrrHr:rrI)rMrrr.rMr"rr.)rMrXrr.rr\rr)) r;r<r=r> __slots__rLrSrWr[r`rfrrrrDrDYs(9I???? < < < < CCCC0000QQQQQQrrDc>eZdZdZdZdd Zdd Zdd ZddZddZ dS) _LowerBoundzLower 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.  inclusiverGrG_VersionOrBoundaryrnr.rrIc"||_||_dSrrGrnrKrGrns rrLz_LowerBound.__init__ "rrMr"czt|tstS|j|jko|j|jkSrr&rlrUrGrnrVs rrWz_LowerBound.__eq__7%-- "! !|u},R5?1RRrct|tstS|j |jduS|jdS|j|jkr|j|jkS|jo|j S)NFrurVs rr[z_LowerBound.__lt__sl%-- "! ! < =, , = 5 <5= ( (<%-/ /~5eo"55rr\c8t|j|jfSrr^rGrnr_s rr`z_LowerBound.__hash__T\4>2333rr)cL|jrdnd}d|jjd||jdS)N[rb< >rnrdr;rGrKbrackets rrfz_LowerBound.__repr__s70##SG4>*GGWGdlGGGGrNrGrornr.rrIrg)rMrlrr.rhri r;r<r=r>rjrLrWr[r`rfrrrrlrl)I####SSSS 6 6 6 64444HHHHHHrrlc>eZdZdZdZdd Zdd Zdd ZddZddZ dS) _UpperBoundzUpper 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. rmrGrornr.rrIc"||_||_dSrrqrrs rrLz_UpperBound.__init__rsrrMr"czt|tstS|j|jko|j|jkSrr&rrUrGrnrVs rrWz_UpperBound.__eq__rvrct|tstS|jdS|jdS|j|jkr|j|jkS|j o|jSNFTrrVs rr[z_UpperBound.__lt__sd%-- "! ! < 5 = 4 <5= ( (<%-/ />!5eo5rr\c8t|j|jfSrryr_s rr`z_UpperBound.__hash__rzrr)cL|jrdnd}d|jjd|j|dS)N]rcr}r~rrrs rrfz_UpperBound.__repr__s70##SG4>*GGT\GWGGGGrNrrg)rMrrr.rhrirrrrrrrrrFztuple[_VersionRange] _FULL_RANGElowerupperr.c|j|jdS|j|jkr|jo|j S|j|jkS)zHTrue when the range defined by *lower* and *upper* contains no versions.NFrq)rrs r_range_is_emptyrsF } 5u } %%O788 =5= ((rleftSequence[_VersionRange]rightlist[_VersionRange]cg}dx}}|t|kr|t|kr||\}}||\}}t||} t||} t| | s|| | f||kr|dz }n|dz }|t|kr|t|k|S)zFIntersect two sorted, non-overlapping range lists (two-pointer merge).rr )r(maxminrappend) rrresult left_index right_index left_lower left_upper right_lower right_upperrrs r_intersect_rangesrs #%F  J s4yy [3u::%=%=!%j!1 J#(#5 [J ,,J ,,ue,, * MM5%. ) ) )  # # !OJJ 1 K s4yy [3u::%=%= MrrGrc~g|jdd|jddzR}tj|j|dS)z5Smallest version in the next prefix: 1.2 -> 1.3.dev0.Nr rrOr4rQ)r4r from_partsrO)rGr4s r_next_prefix_dev0rsE>$>gob&9A&=>>G  GM7 J J JJrcDtj|j|jdS)z7The .dev0 of a version's base release: 1.2 -> 1.2.dev0.rr)rrrOr4rGs r _base_dev0rs  GM7?PQ R R RRrUnparsedVersionVersion | Nonectt|ts" t|}n#t$rYdSwxYw|Sr)r&rrrs r_coerce_versionr$sO gw ' ' g&&GG   44  Ns ' 55c@|j|S|dS)N)local)r __replace__rs r_public_versionr-s&}   T  * **rc2|dddS)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. NrPrQrrrs r _post_baser3s   Dd$  ? ??rc0|ddS)zZEarliest pre-release of *version*. 1.2 -> 1.2.dev0, 1.2.post1 -> 1.2.post1.dev0. rNrQrrrs r_earliest_prereleaser;s   1D  1 11rrRroc|dSt|trP|j}|jr|dddS|j |jdznd}||dS|js|S|dddS)z:Smallest non-pre-release version at or above *v*, or None.N)r+rQrr r)rPr)r&rDrG is_prereleaserrP)rRinnerks r_nearest_non_prereleaserCs yt!%&&5    E$$4t$DD D!& 6UZ!^^A  at 444 ? ==Tt4= 8 88rceZdZdZdS)ra 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)r;r<r=r>rrrrrXsrrceZdZdZdZed$dZejd$dZ ejd%dZ ejd&d Z eejd'dZ e j d(dZ ejd)d*dZej d+d,dZej d+d-dZej d.d/d#ZdS)0rr)_strrr)c t|S)z Internal property for match_argsr)r_s rrzBaseSpecifier._strhs4yyrcdS)z Returns the str representation of this Specifier-like object. This should be representative of the Specifier itself. Nrr_s r__str__zBaseSpecifier.__str__mrr\cdS)zF Returns a hash value for this Specifier-like object. Nrr_s rr`zBaseSpecifier.__hash__trrrMr"r.cdS)z Returns a boolean representing whether or not the two Specifier-like objects are equal. :param other: The other object to check against. NrrVs rrWzBaseSpecifier.__eq__zrr bool | NonecdS)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. Nrr_s r prereleaseszBaseSpecifier.prereleasesrrrZrIcdS)zQSetter for :attr:`prereleases`. :param value: The value to set. NrrKrZs rrzBaseSpecifier.prereleasesrrNitemrcdS)zR Determines if the given item is contained within this specifier. NrrKrrs rcontainszBaseSpecifier.containsrr.iterableIterable[UnparsedVersionVar]keyIterator[UnparsedVersionVar]cdSrrrKrrrs rfilterzBaseSpecifier.filter (+sr Iterable[T]Callable[[T], UnparsedVersion] Iterator[T]cdSrrrs rrzBaseSpecifier.filter cr Iterable[Any]'Callable[[Any], UnparsedVersion] | None Iterator[Any]cdS)z Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. Nrrs rrzBaseSpecifier.filterrrrirhrgrr)rZr.rrIr)rr)rrrr.N.rrrrrrIrrrrrrrrrrNNrrrrrrrr)r;r<r=rj__match_args__propertyrabcabstractmethodrr`rWrsetterrtypingoverloadrrrrrrdsIN X                  X            _$( ++++_+ _$(.1 _ $(7;         rr) metaclassc (eZdZUdZdZdZejdezdzejej zZ ddddd d d d d Z de d<dZd[dZ d\dZd]dZd^dZd_d#Zd_d$Zed`d%Zejdad'Zdbd)Zdcd,Zeddd-Zeddd.Zddd/Zddd0Zeded2Zdfd4Zdgd7Zdhd9Zdid;Z djd=Z!did>Z"did?Z#did@Z$didAZ%dkdCZ&dkdDZ'dldFZ(dmdIZ)dndodKZ*e+j, dpdqdQZ-e+j, dpdrdUZ- dsdtdYZ-dS)uraThis 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* compatibleequal not_equalless_than_equalgreater_than_equal less_than greater_than arbitrary)~===!=<=>=r}r===r _operatorsNr!r)rrrrIc |j|std||}|dr'|dd|dd}}nb|dr'|dd|dd}}n&|dd|dd}}||f|_||_d|_d|_d|_ dS)aInitialize 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). zInvalid specifier: rNr)rrrrrr%r ) _regex fullmatchrstrip startswithrrrrr)rKr!roperatorrGs rrLzSpecifier.__init__=s{$$T** C"#A#A#ABB Bzz|| ??5 ! ! ; $RaR$qrr(..*:*:gHH __; < < ; $RaR$qrr(..*:*:gHH $RaR$qrr(..*:*:gH'/&9 (:>>B8< rrGrc|j|jd|kr |jdSt|}|dS||f|_|S)zDOne element cache, as only one spec Version is needed per Specifier.Nrr )rr)rKrGversion_specifiers r_get_spec_versionzSpecifier._get_spec_versioncsX   )d.@.Cw.N.N%a( (+G44  $4%'89  rrc8||}|J|S)zGet 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 ===). )r)rKrG spec_versions r_require_spec_versionzSpecifier._require_spec_versionos) --g66 '''rrc|j|jS|j}|j}|dkrt|_tS|dr|||}n|||}||_|S)zConvert 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.*)rrrGrendswith_wildcard_ranges_standard_ranges)rKopver_strrs r _to_rangeszSpecifier._to_rangesys < #<  ], ;;&DL    D ! ! 8**2w77FF**2w77F  rrrrc"||dd}t|}t|}|dkr!t|dt |dfgSt t |dft|dt fgS)NrTF)rrrrlr_NEG_INF_POS_INF)rKrrbaserrs rrzSpecifier._wildcard_rangess))'#2#,774  !$'' :: --{5%/H/HIJ J{5%00 1  % %x 0  rc||}|dkrt|dtfgS|dkr0tt t |t jdfgS|dkr|j7| |jdzd}t|dtfgS|j 8| |j dzdd}t|dtfgStt |t j d tfgS|d krE|j r|n| dd}|tkrgStt |d fgSd |v}t |t j}|r|n|}|d kr!t|dt |dfgS|d kr.tt |d ft|d tfgS|dkrQ| |jdd} t|dt t| d fgSt!d|)NrTrrr rrrFr}+rrrr)r4Unknown operator: )rrlr rrrDr:rArQrrPrBrr3r4r ValueError) rKrrrR lower_verr2 has_local after_localsrprefixs rrzSpecifier._standard_rangessv  & &w / / :: D))845 5 :: 0M4N O OQUVV  99u MMaeaitMDD $Y55x@AAv!MMqvzqMMM $Y55x@AA 0M4M N NPUVV  99NAAammm.N.NE $$ {5%889: :7N '=+EFF 0L :: D));ud+C+CDE E ::;q%001UE**H5  ::]]19SbS>]::FQ%%{3DV3L3Le'T'TU 4b44555rc|j|jS|j\}}|dkrdS|dkr|drdS||}|dS|jS)NrFrr)rrrrr)rKr version_strrGs rrzSpecifier.prereleasess   ($ $!% + t  5 t   4 4T : : 5((55 ?4$$rrZc||_dSr)rrs rrzSpecifier.prereleasess!r#tuple[tuple[str, str], bool | None]c|j|jfSr)rrr_s r __getstate__zSpecifier.__getstate__s D-..rstater"cd|_d|_d|_t|trt |dkr3|\}}t |rt|r||_||_ dSt |dkryt|dtr^|\}}| d}| dd}t |rt|r||_||_ dSt|trY| d}| dd}t |rt|r||_||_ dStd|)Nr%r rrinvalidzCannot restore Specifier from ) rrrr&r'r(r*r/rrdictget TypeError)rKr0r!r_ slot_dicts r __setstate__zSpecifier.__setstate__sx!# eU # # 5zzQ$)!k!$''M+,F,F!%DJ(3D%F5zzQ:eAh#=#=$ 9 }}W--'mmNIFF !$''M+,F,F!%DJ(3D%F eT " " 99W%%D))NI>>Kd##  k(B(B ! $/!BBBCCCrc|jdS)z`The operator of this specifier. >>> Specifier("==1.2.3").operator '==' rrr_s rrzSpecifier.operator$z!}rc|jdS)zaThe version of this specifier. >>> Specifier("==1.2.3").version '1.2.3' r r:r_s rrGzSpecifier.version-r;rcl|j d|jnd}d|jjdt ||dS)aTA representation of the Specifier that shows all internal state. >>> Specifier('>=1.0.0') =1.0.0')> >>> Specifier('>=1.0.0', prereleases=False) =1.0.0', prereleases=False)> >>> Specifier('>=1.0.0', prereleases=True) =1.0.0', prereleases=True)> N, prereleases=rr}rb)>rrrdr;r)rKr+s rrfzSpecifier.__repr__6sT , 2T- 1 1 1 B4>*AASYYA#AAAArc dj|jS)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{}{})formatrr_s rrzSpecifier.__str__Hsv}dj))rtuple[str, str]c|j\}}|dks|dr||fS||}t||dk}||fS)Nrrrstrip_trailing_zero)rrrr)rKrrGrcanonical_versions r_canonical_speczSpecifier._canonical_specRsw J' u   0 0 6 6 W$ $11':: 0 x4/?   ***rr\c*t|jSr)r^rIr_s rr`zSpecifier.__hash__`sD()))rrMr.ct|tr; |t|}n3#t$r tcYSwxYwt||jstS|j|jkS)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)rdrrUrIrVs rrWzSpecifier.__eq__cs& eS ! ! " &s5zz22# & & &%%%% &E4>22 "! !#u'<<>> Specifier("==1.*")._get_wildcard_split("1.*") (['0', '1'], 2) >>> Specifier("==3.10.*")._get_wildcard_split("3.10.*") (['0', '3', '10'], 3) NrFrF)rrrY_numeric_prefix_len)rKr!wildcard_split normalized split_specs r_get_wildcard_splitzSpecifier._get_wildcard_splitsZ-  !-d3B3iUSSSJ' 33J(*=j*I*IJN#1D rcr|drr||\}}tt|d}t |}t ||}|dt |}||kS||} | jst|}|| kS)NrFrF) rrcrrrY _left_padr(rr) rKrRr!rbspec_numeric_lennormalized_prospectivesplit_prospectivepadded_prospectiveshortened_prospectivers rr[zSpecifier._compare_equals ==   /+/+C+CD+I+I (J(&: ,,%&&& " !//E F F "++<>N!O!O  %77HZ7H$I !(J6 6 55d;;L  % ;-k:: ,. .rc0||| Sr)r[rKrRr!s r_compare_not_equalzSpecifier._compare_not_equals&&{D9999rcNt|||kSrrrrls r_compare_less_than_equalz"Specifier._compare_less_than_equal%{++t/I/I$/O/OOOrcNt|||kSrrorls rrZz%Specifier._compare_greater_than_equalrqrspec_strc||}||ksdS|js|jr|t|krdSdSr)rrrrKrRrsr!s r_compare_less_thanzSpecifier._compare_less_thansc))(33 T!!5 " ) 3D99995 trc||}||ksdS|js|jrt||krdS|jt ||krdSdSr)ris_postreleaserrrrus r_compare_greater_thanzSpecifier._compare_greater_thans))(33 T!!5 # * ;''4//5   (_[-I-IT-Q-Q5 tr Version | strct|t|kSrr)rrls r_compare_arbitraryzSpecifier._compare_arbitrarys1;%%''3t99??+<+<<>> "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 rrKrs r __contains__zSpecifier.__contains__&}}T"""rrcftt||g|S)asReturn 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.rUrrs rrzSpecifier.contains.s,2DdVEEFFGGGr.rrrrcdSrrrs rrzSpecifier.filterIrrrrrcdSrrrs rrzSpecifier.filterQrrrrrc#$Kg}d}||n|j}||j}|D]}t||n ||} d} | +|jdkr|||jr|VnE|jdkr)|||n |||j} n|| |j} | r2| 0| jr|rd}|V||jdur|||s||jdur|Ed{VdSdSdSdS)aFilter 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', ] >>> 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'}] FNrT) rrQrrr}rGrrr) rKrrrprereleases_versionsfound_non_prereleasesinclude_prereleasesrPrGparsed_versionmatchs rrzSpecifier.filterYsF " %'2KK8H  !..t}==  9 9G, WWWVVNE%=E))d.E.ET\//)"MMM%''//"{GGG dl*).$,GG 93%397J9,0)!MMMM (T->e-K-K(//888 & ,#!..+ + + + + + + + + +  , ,##..rrN)r!r)rrrrI)rGr)rr)rGr)rrrr)rr)rr)rrrrZrrrI)rr-r0r"rrIri)rrDrhrg)rr)rrL)rRrr!r)rr.)r!r)rr])rRrrsr)rr.)rRrzr!r)rr.)rr~rr.r)rrrrrr.rrrrr).r;r<r=r>rj_specifier_regex_strrecompileVERBOSE IGNORECASEr r__annotations__rLrrrrrrrrr/r8rrGrfrrIr`rWrQr\rcr[rmrprZrvryr}rrrrrrrrrrs&IZ xRZ%%. R]0JF "    J    $<$<$<$<$ * !((...##D))) #  #,,,,,,,," JJJ  &    % % %    rr)cLg}|d\}}}||pd|dD][}t|}|r(||F||\|S)aSplit 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.) rpartitionrsplit _prefix_regexr extendgroups)rGrrOr6restrrs rrYrYsF'',,NE1d MM%,3 3  ''--  MM%,,.. ) ) ) ) MM$     Mr componentsc>|^}}|dd|S)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. rr)join)rrOrs rrTrTs+LED & &chhtnn & &&rsegmentc<tfddD S)Nc3BK|]}|VdSr)r ).0r)rs r z!_is_not_suffix..sB'-6""r)rQabrcrP)any)rs`rrXrXs@1P rrr\cJd}|D]}|sn|dz }|S)zCount leading numeric components in a :func:`_version_split` result. >>> _numeric_prefix_len(["0", "1", "2", "a1"]) 3 rr )isdigit)rcountrs rr_r_s? E    E   Lrtarget_numeric_lencrt|}||z }|dkr|Sg|d|dg|z||dS)zPad 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'] rNr)r_)rr numeric_len pad_neededs rrere sW&e,,K#k1JQ NU=, <=, >, <), 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 rrrr%)rrrr}r rrrrr$)rr%)rr6verrs r_operator_costrsJAsB Tzz T**1qq1 ###q Tzzq Tzz T**1qq1 U{{q 0"00 1 11rcNeZdZdZdZ dd Zed?dZej d@dZdAdZ dBdZ dCdZ dCdZ dDdZdEdZdFdZdDd ZdGd"ZdHd$ZdId%ZdId&ZdId'ZdJd*Z dKdLd,Zej dMdNd2Zej dMdOd6Z dKdPd:Z dQdRd;ZdS)SraThis 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_specsrN specifiersstr | Iterable[Specifier]rrrrIct|trPd|dD}tt t ||_d|v|_n7t||_td|jD|_t|jdk|_ d|_ ||_ d|_ dS)aInitialize 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^g|]*}||+Sr)r rss r z)SpecifierSet.__init__..ks-VVVaAGGIIV VVVr,rc38K|]}dt|vVdSrNrrs rrz(SpecifierSet.__init__..ts,%K%K!es1vvo%K%K%K%K%K%Krr N)r&r)rr'maprrrrr(rrrr)rKrrsplit_specifierss rrLzSpecifierSet.__init__Rs, j# & & L WV:3C3CC3H3HVVV 16s9FV7W7W1X1XDK"':"5D   ++DK#&%K%Kt{%K%K%K"K"KD !$+..!3MQ(.2rtuple[Specifier, ...]c|jsZttt |jt |_d|_d|_d|_|jS)zBDeduplicate, sort, and cache specs for order-sensitive operations.rTN) rr'r3fromkeyssortedrr)rrr_s r_canonical_specszSpecifierSet._canonical_specssW" * fT[c.J.J.J K KLLDK"&D !%D %)D "{rct|j|jS|jsdStd|jDrdSdS)Nc3$K|] }|jV dSrrrs rrz+SpecifierSet.prereleases..s$22q}222222rT)rrrr_s rrzSpecifierSet.prereleasessT   ($ $ { 4 22dk222 2 2 4trrZc"||_d|_dSr)rrrs rrzSpecifierSet.prereleasess!!%r)tuple[tuple[Specifier, ...], bool | None]c|j|jfSr)rrr_s rr/zSpecifierSet.__getstate__s T.//rr0r"cd|_d|_t|trt |dkr|\}}t|trnt d|DrUt |rF||_||_t |dk|_ td|D|_ dSt |dkrt|dtr|\}}| dd}| d}t|tr#tt|t }t|trxt d |Dr_t |rP||_||_t |jdk|_ td |jD|_ dSt|tr| dd}| d}t|tr#tt|t }t|trxt d |Dr_t |rP||_||_t |jdk|_ td |jD|_ dSt#d |)Nr%c3@K|]}t|tVdSrr&rrs rrz,SpecifierSet.__setstate__..,DDJq)44DDDDDDrr c38K|]}dt|vVdSrrrs rrz,SpecifierSet.__setstate__..s,-M-M!es1vvo-M-M-M-M-M-Mrrrrrc3@K|]}t|tVdSrrrs rrz,SpecifierSet.__setstate__..rrc38K|]}dt|vVdSrrrs rrz,SpecifierSet.__setstate__..s,-S-S!es1vvo-S-S-S-S-S-Src3@K|]}t|tVdSrrrs rrz,SpecifierSet.__setstate__..s,@@Q 1i00@@@@@@rc38K|]}dt|vVdSrrrs rrz,SpecifierSet.__setstate__..s,)O)Oa%3q66/)O)O)O)O)O)Orz!Cannot restore SpecifierSet from )rrr&r'r(allr/rrrrrr3r4 frozensetrr)r5)rKr0specsrr6r7s rr8zSpecifierSet.__setstate__s!!% eU # # 5zzQ%*"{ue,, DDeDDDDD &k22  #(DK(3D%*-e**/D'*--M-Mu-M-M-M*M*MD'F5zzQ:eAh#=#=$ 9! h33'mmN;; eY//:!&C"8"8"899Eue,, DDeDDDDD &k22  #(DK(3D%*-dk*:*:a*?D'*--S-St{-S-S-S*S*SD'F eT " " IIh++E))N33K%++ 6fU444555%(( @@%@@@@@ "+..  $ $/!&)$+&6&6!&;#&))O)O4;)O)O)O&O&O#EEEEFFFrr)cl|j d|jnd}d|jjdt ||dS)aA 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') =1.0.0')> >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False) =1.0.0', prereleases=False)> >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True) =1.0.0', prereleases=True)> Nr>rr}rbr?r@rAs rrfzSpecifierSet.__repr__sT , 2T- 1 1 1 B4>*AASYYA#AAAArcddd|DS)anA 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' rc34K|]}t|VdSrrrs rrz'SpecifierSet.__str__..s(@@1A@@@@@@r)rrr_s rrzSpecifierSet.__str__s1xx@@(=(=(?(?@@@@@@rr\cDt|Sr)r^rr_s rr`zSpecifierSet.__hash__sD))++,,,rrMSpecifierSet | strct|trt|}nt|tstSt}|j|jz|_t |jdk|_|jp|j|_d|_|j |j |j kr |j |_ n#|j |j |_ ntd|S)aReturn 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' =1.0.0')> >>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1') =1.0.0')> r NzFCannot combine SpecifierSets with True and False prerelease overrides.) r&r)rrUrr(rrrrr%)rKrM specifiers r__and__zSpecifierSet.__and__s eS ! ! " ''EEE<00 "! ! NN ;5 #&y'7#8#8A#=  #'#6#N%:N  "&    $(9U=O(O(O%*%7I " "   '%)%6I " "X rr.ct|ttfrtt|}nt|tstS||kS)aWhether 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)rrrUrrVs rrWzSpecifierSet.__eq__&sk& ec9- . . " U,,EEE<00 "! !$$&&%*@*@*B*BBBrc*t|jS)z7Returns the number of specifiers in this specifier set.)r(rr_s r__len__zSpecifierSet.__len__@s4;rIterator[Specifier]c*t|jS)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) [, =1.0.0')>] )iterrr_s r__iter__zSpecifierSet.__iter__DsDK   rrc|j}d}|D]?}||}t||}|sn@|td|S)aIntersect 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)rrr RuntimeError)rKrrrs r _get_rangeszSpecifierSet._get_rangesNsw 15  A~*61<<>>BBE >ABB B rc|j}||S|js d|_dS| }|s|}|s|jdur|}||_|S)aCheck 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)rrr_check_arbitrary_unsatisfiabler_check_prerelease_only_ranges)rKcachedrs ris_unsatisfiablezSpecifierSet.is_unsatisfiableds'  M{ %*D "5%%''' ;88::F :$*e337799F!' rc|D]H\}}t|j}|dS|j ||jkrdS||jkr |jrdSIdS)zWith prereleases=False, check if every range contains only pre-release versions (which would be excluded from matching).NFT)rrrGrn)rKrrnearests rrz*SpecifierSet._check_prerelease_only_rangessz!,,..  LE5-em<.s$CCC1qzU/B/BQ/B/B/BrFrc3RK|]!}|jkV"dSr)rGr)rrfirsts rrz>SpecifierSet._check_arbitrary_unsatisfiable..s4AAaqy  E)AAAAAArr NTc(g|]}|jdk |Srrrs rrz?SpecifierSet._check_arbitrary_unsatisfiable..s$BBB!ajE.A.AA.A.A.Arc3BK|]}|VdSrr)rr candidates rrz>SpecifierSet._check_arbitrary_unsatisfiable..s/??qzz),,??????r)rrGrrrrrr)rKrstandardr rs @@rrz+SpecifierSet._check_arbitrary_unsatisfiablesDC CCC  5! $**,, AAAA9QRR=AAA A A 4$IaL$899   % %%'&4BBt{BBB 5  4????h???????rrrc,||S)aqReturn 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 rrs rrzSpecifierSet.__contains__rr installedct|}| |r |jrd}||jrt|ts|}n|}t t ||g|S)aReturn 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 NTr)rrrr&rr.rUr)rKrrrrG check_items rrzSpecifierSet.containssz@"$''  9 1F K ?t2?:dG;T;T?JJ JDj\{KKLLMMMr.rrrrcdSrrrs rrzSpecifierSet.filterrrrrrcdSrrrs rrzSpecifierSet.filterrrrrrc||j|j}|jrpt|jdkr(|jd||dn|}n|||dn|}||St |S|durt |S|durfd|DSt |S) acFilter 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', ] >>> 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 rT)rrrFc3hK|],}t|n |x j(|V-dSr)rr)rrrrGs rrz&SpecifierSet.filter..^sj / T S SSW"0 r)rrr(r_filter_versionsrr)rKrrrfilteredrGs ` @rrzSpecifierSet.filter s%d  4#3#?*K ; = 4;1$$;q>00(3(;1  00(3(;1 &-h<< < $  >> ! %  $ *(C888rc#dK|j*td|jDt|_|j}|du}|D]kt n  t fd|DrV@|rjrJt fd|DrVldS)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. Nc3dK|]+}||j|j|jfV,dSr)rQrrG)rr!s rrz0SpecifierSet._filter_versions..{sQ'' 66 dmTrrFc3K|]E\}}}|dko6t|kVFdSrr|)rr6rrrs rrz0SpecifierSet._filter_versions..sc"3%KDCIIOO$5$5$Drc3K|]^\}}}|dkrDtn |kn ||V_dSrr|)rop_fnrrrrrs rrz0SpecifierSet._filter_versions..s#E3;;CKDDSSYY77==??399;;NNU63''r)rrrrrrr)rKrrropsexclude_prereleasesrrs ` @@rrzSpecifierSet._filter_versionsksG   %!' $ # """D  )U2  D$S[TTcc$iiHHF~&)JJJ$ )= '*   '  rr)rrrrrrI)rrrr)rrrrirh)rMrrrrg)rrr)rr.)rrrr.r)rrrrrrrr.rrrrr)rrrrrrrr)r;r<r=r>rjrLrrrrr/r8rfrr`rrWrrrrrrrrrrrrrrrrr6s$I13#'+3+3+3+3+3ZX&&&&&0000 7G7G7G7GrBBBB* A A A A----BCCCC4    !!!!,B    %@%@%@%@N####0$(!% +N+N+N+N+NZ _$( ++++_+ _$(.1 _$(7; ^9^9^9^9^9H$( ,,,,,,,rr)rr)r!r"rr#)r+r"rr,)r4r5rr5)rrlrrrr.)rrrrrr)rGrrr)rGrrr)rRrorr)rrrrrr)rGr)rr)rrrr))rr)rr.)rrrr\)rrrr\rr)rrrr\)Lr> __future__rrr? functoolsrVrsysrrrrrrr r r r utilsrrGrr version_infortyping_extensionsrr r*r/r0r)rr1r.rLr3rr8Enumr:total_orderingrDrlrror' _VersionRangerr rrrrrrrrrrr%rABCMetarrrrrrYrTrXr_rerrrrrr(s#"""""                        (''''',,,,,,,,w       ,++++++   0000 GCLL %W1IIIWcND01 'wx00 0000====DI ;Q;Q;Q;Q;Q;Q;Q;Q| %H%H%H%H%H%H%H%HP %H%H%H%H%H%H%H%HP 4w(8$>?+{23M ;tU # # ;tU # #&.%9$; ;;;;))))4KKKK SSSS ++++ @@@@22229999*     z   O O O O O ckO O O O dr ,r ,r ,r ,r , r ,r ,r ,j :;; ' ' ' ' T,''''     O O O O22226a a a a a =a a a a a r