a h|@sXddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl mZddlmZmZmZe rddlmZmZmZmZmZmZmZmZmZeeefZeeeefZeeege fZ!Gd d d e"Z#Gd d d e ej$e%Z&Gd dde&Z'Gddde'Z(ddZ)Gddde'Z*e+dZ,ddZ-ddZ.Gddde&Z/dS))absolute_importdivisionprint_functionN) string_typeswith_metaclass) TYPE_CHECKING)canonicalize_version)Version LegacyVersionparse) ListDictUnionIterableIteratorOptionalCallableTuple FrozenSetc@seZdZdZdS)InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)__name__ __module__ __qualname____doc__rrK/usr/lib/python3.9/site-packages/setuptools/_vendor/packaging/specifiers.pyr"src@seZdZejddZejddZejddZejddZej d d Z e j d d Z ejdd dZ ejdddZ d S) BaseSpecifiercCsdS)z Returns the str representation of this Specifier like object. This should be representative of the Specifier itself. Nrselfrrr__str__)szBaseSpecifier.__str__cCsdS)zF Returns a hash value for this Specifier like object. Nrrrrr__hash__1szBaseSpecifier.__hash__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nrrotherrrr__eq__8szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. Nrr"rrr__ne__@szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nrrrrr prereleasesHszBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nrrvaluerrrr&PsNcCsdS)zR Determines if the given item is contained within this specifier. Nrritemr&rrrcontainsXszBaseSpecifier.containscCsdS)z Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. Nr)riterabler&rrrfilter_szBaseSpecifier.filter)N)N)rrrabcabstractmethodr r!r$r%abstractpropertyr&setterr+r-rrrrr(s        rc@seZdZiZd"ddZddZddZed d Zd d Z d dZ ddZ ddZ ddZ eddZeddZeddZejddZddZd#ddZd$d d!ZdS)%_IndividualSpecifierNcCsF|j|}|std||d|df|_||_dS)NzInvalid specifier: '{0}'operatorversion)_regexsearchrformatgroupstrip_spec _prereleases)rspecr&matchrrr__init__ls   z_IndividualSpecifier.__init__cCs0|jdurd|jnd}d|jjt||S)N, prereleases={0!r}r3z<{0}({1!r}{2})>)r<r8r& __class__rstrrZprerrr__repr__zs z_IndividualSpecifier.__repr__cCs dj|jS)Nz{0}{1})r8r;rrrrr sz_IndividualSpecifier.__str__cCs|jdt|jdfS)Nrr)r;r rrrr_canonical_specsz$_IndividualSpecifier._canonical_speccCs t|jSN)hashrErrrrr!sz_IndividualSpecifier.__hash__cCsRt|tr6z|t|}WqFty2tYS0nt||jsFtS|j|jkSrF) isinstancerrArBrNotImplementedrEr"rrrr$s    z_IndividualSpecifier.__eq__cCsRt|tr6z|t|}WqFty2tYS0nt||jsFtS|j|jkSrF)rHrrArBrrIr;r"rrrr%s    z_IndividualSpecifier.__ne__cCst|d|j|}|S)Nz _compare_{0})getattrr8 _operators)ropoperator_callablerrr _get_operatorsz"_IndividualSpecifier._get_operatorcCst|ttfst|}|SrF)rHr r r rr5rrr_coerce_versionsz$_IndividualSpecifier._coerce_versioncCs |jdS)Nrr;rrrrr4sz_IndividualSpecifier.operatorcCs |jdS)NrrQrrrrr5sz_IndividualSpecifier.versioncCs|jSrFr<rrrrr&sz _IndividualSpecifier.prereleasescCs ||_dSrFrRr'rrrr&scCs ||SrFr+rr*rrr __contains__sz!_IndividualSpecifier.__contains__cCs>|dur|j}||}|jr&|s&dS||j}|||jSNF)r&rP is_prereleaserNr4r5)rr*r&Znormalized_itemrMrrrr+s   z_IndividualSpecifier.containsccsd}g}d|dur|ndi}|D]F}||}|j|fi|r |jr\|s\|js\||q d}|Vq |s|r|D] }|VqtdS)NFr&T)rPr+rWr&append)rr,r&yieldedfound_prereleaseskwr5parsed_versionrrrr-s"  z_IndividualSpecifier.filter)r3N)N)N)rrrrKr?rDr propertyrEr!r$r%rNrPr4r5r&r1rUr+r-rrrrr2hs,          r2c@sveZdZdZededejejBZdddddd d Z d d Z d dZ ddZ ddZ ddZddZddZdS)LegacySpecifiera (?P(==|!=|<=|>=|<|>)) \s* (?P [^,;\s)]* # Since this is a "legacy" specifier, and the version # string can be just about anything, we match everything # except for whitespace, a semi-colon for marker support, # a closing paren since versions can be enclosed in # them, and a comma since it's a version separator. ) ^\s*\s*$equal not_equalless_than_equalgreater_than_equal less_than greater_than)==!=<=>=<>cCst|tstt|}|SrF)rHr rBrOrrrrP s  zLegacySpecifier._coerce_versioncCs|||kSrFrPr prospectiver=rrr_compare_equal&szLegacySpecifier._compare_equalcCs|||kSrFrmrnrrr_compare_not_equal*sz"LegacySpecifier._compare_not_equalcCs|||kSrFrmrnrrr_compare_less_than_equal.sz(LegacySpecifier._compare_less_than_equalcCs|||kSrFrmrnrrr_compare_greater_than_equal2sz+LegacySpecifier._compare_greater_than_equalcCs|||kSrFrmrnrrr_compare_less_than6sz"LegacySpecifier._compare_less_thancCs|||kSrFrmrnrrr_compare_greater_than:sz%LegacySpecifier._compare_greater_thanN)rrr _regex_strrecompileVERBOSE IGNORECASEr6rKrPrprqrrrsrtrurrrrr^s   r^cstfdd}|S)Ncst|tsdS|||SrV)rHr rnfnrrwrappedCs z)_require_version_compare..wrapped) functoolswraps)r|r}rr{r_require_version_compare?src @seZdZdZededejejBZdddddd d d d Z e d dZ e ddZ e ddZ e ddZe ddZe ddZe ddZddZeddZejddZd S)! Specifiera (?P(~=|==|!=|<=|>=|<|>|===)) (?P (?: # 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]* # We just match everything, except for whitespace # since we are only testing for strict identity. ) | (?: # 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 (?: # pre release [-_\.]? (a|b|c|rc|alpha|beta|pre|preview) [-_\.]? [0-9]* )? (?: # post release (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*) )? # You cannot use a wild card and a dev or local version # together so group them with a | and make them optional. (?: (?:[-_\.]?dev[-_\.]?[0-9]*)? # dev release (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local | \.\* # Wild card syntax of .* )? ) | (?: # 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 [-_\.]? (a|b|c|rc|alpha|beta|pre|preview) [-_\.]? [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. (?z/Specifier._compare_compatible...*rjrg)joinlist itertools takewhile_version_splitrN)rror=prefixrrr_compare_compatibles  zSpecifier._compare_compatiblec Csz|drVt|j}t|dd}tt|}|dt|}t||\}}||kSt|}|jsnt|j}||kSdS)Nr)endswithr publicrrBlen _pad_versionlocal) rror=Z split_specZsplit_prospectiveZshortened_prospectiveZ padded_specZpadded_prospectiveZ spec_versionrrrrps    zSpecifier._compare_equalcCs||| SrF)rprnrrrrqszSpecifier._compare_not_equalcCst|jt|kSrFr rrnrrrrrsz"Specifier._compare_less_than_equalcCst|jt|kSrFrrnrrrrs sz%Specifier._compare_greater_than_equalcCs<t|}||ksdS|js8|jr8t|jt|jkr8dSdSNFT)r rW base_versionrroZspec_strr=rrrrts zSpecifier._compare_less_thancCs^t|}||ksdS|js8|jr8t|jt|jkr8dS|jdurZt|jt|jkrZdSdSr)r Zis_postreleaserrrrrrru1s  zSpecifier._compare_greater_thancCst|t|kSrF)rBlowerrnrrr_compare_arbitraryRszSpecifier._compare_arbitrarycCsR|jdur|jS|j\}}|dvrN|dkr@|dr@|dd}t|jrNdSdS)N)rgrjrirrrgrrTF)r<r;rr rW)rr4r5rrrr&Vs    zSpecifier.prereleasescCs ||_dSrFrRr'rrrr&psN)rrrrvrwrxryrzr6rKrrrprqrrrsrtrurr]r&r1rrrrrMs<]   (      rz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|dD],}t|}|r0||q||q|S)Nr)split _prefix_regexr7extendgroupsrX)r5resultr*r>rrrrys  rc Csgg}}|ttdd||ttdd|||t|dd||t|dd|ddgtdt|dt|d|ddgtdt|dt|dttj|ttj|fS)NcSs|SrFisdigitrrrrrrz_pad_version..cSs|SrFrrrrrrrrr0)rXrrrrinsertmaxchain)leftrightZ left_splitZ right_splitrrrrs ,,rc@seZdZdddZddZddZd d Zd d Zd dZddZ ddZ ddZ e ddZ e jddZ ddZdddZd ddZdS)! SpecifierSetr3Nc Csldd|dD}t}|D]8}z|t|WqtyT|t|Yq0qt||_||_dS)NcSsg|]}|r|qSr)r:.0srrr rz)SpecifierSet.__init__..,) rsetaddrrr^ frozenset_specsr<)rZ specifiersr&Zsplit_specifiersparsed specifierrrrr?s  zSpecifierSet.__init__cCs*|jdurd|jnd}dt||S)Nr@r3z)r<r8r&rBrCrrrrDs zSpecifierSet.__repr__cCsdtdd|jDS)Nrcss|]}t|VqdSrF)rBrrrr rz'SpecifierSet.__str__..)rsortedrrrrrr szSpecifierSet.__str__cCs t|jSrF)rGrrrrrr!szSpecifierSet.__hash__cCst|trt|}nt|ts"tSt}t|j|jB|_|jdurX|jdurX|j|_n<|jdurv|jdurv|j|_n|j|jkr|j|_ntd|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rHrrrIrrr< ValueError)rr#rrrr__and__s        zSpecifierSet.__and__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrFrHrr2rrBrIrr"rrrr$s  zSpecifierSet.__eq__cCs6t|ttfrtt|}nt|ts*tS|j|jkSrFrr"rrrr%s  zSpecifierSet.__ne__cCs t|jSrF)rrrrrr__len__szSpecifierSet.__len__cCs t|jSrF)iterrrrrr__iter__szSpecifierSet.__iter__cCs.|jdur|jS|jsdStdd|jDS)Ncss|] }|jVqdSrFr&rrrrrrz+SpecifierSet.prereleases..)r<ranyrrrrr&s  zSpecifierSet.prereleasescCs ||_dSrFrRr'rrrr&scCs ||SrFrSrTrrrrU szSpecifierSet.__contains__csLtttfstdur$|js2jr2dStfdd|jDS)NFc3s|]}|jdVqdS)rNrSrr*r&rrr*rz(SpecifierSet.contains..)rHr r r r&rWallrr)rrrr+s zSpecifierSet.containscCs|dur|j}|jr6|jD]}|j|t|d}q|Sg}g}|D]P}t|ttfs^t|}n|}t|trnqB|jr|s|s| |qB| |qB|s|r|dur|S|SdS)Nr) r&rr-boolrHr r r rWrX)rr,r&r=ZfilteredrZr*r\rrrr-,s*       zSpecifierSet.filter)r3N)N)N)rrrr?rDr r!rr$r%rrr]r&r1rUr+r-rrrrrs"       r)0Z __future__rrrr.r~rrwZ_compatrrZ_typingrZutilsr r5r r r typingr rrrrrrrrZ ParsedVersionrBZUnparsedVersionrZCallableOperatorrrABCMetaobjectrr2r^rrrxrrrrrrrrs4  , @ 8+