U .e_[ @sfdZddlZddlZddlmZddlmZdddd d d d d gZee Z Gdd d e Z Gddde ZGddde ZedZddZeZGdddeZddZGdddeZeddfeddfeddfedd fed!d"fed#d"fed$d%fed&d'fed(d)fed*d+ff Zed,dfed-dfed.d%fed$d%fed/dffZed0Zd1d2Zd3d4Zed5ejZd6d6d7d6d8ddd9Zd:d;ZGdejZ"d?d@Z#dAdBZ$GdCd d eZ%GdDd d eZ&GdEdFdFe Z'e'eeee'ee!dGdHe'e$e&edIZ(e(dJe(dK<dLd Z)dS)Mz~ Implementation of a flexible versioning scheme providing support for PEP-440, setuptools-compatible and semantic versioning. N) string_typesparse_requirementNormalizedVersionNormalizedMatcher LegacyVersion LegacyMatcherSemanticVersionSemanticMatcherUnsupportedVersionError get_schemec@seZdZdZdS)r zThis is an unsupported version.N)__name__ __module__ __qualname____doc__rr?/usr/lib/python3.8/site-packages/pip/_vendor/distlib/version.pyr sc@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZeddZdS)VersioncCs"||_}|||_}dSN)strip_stringparse_parts)selfspartsrrr__init__szVersion.__init__cCs tddS)Nzplease implement in a subclassNotImplementedErrorrrrrrr%sz Version.parsecCs$t|t|kr td||fdS)Nzcannot compare %r and %r)type TypeErrorrotherrrr_check_compatible(szVersion._check_compatiblecCs|||j|jkSrr%rr#rrr__eq__,s zVersion.__eq__cCs || Srr'r#rrr__ne__0szVersion.__ne__cCs|||j|jkSrr&r#rrr__lt__3s zVersion.__lt__cCs||p|| Srr*r'r#rrr__gt__7szVersion.__gt__cCs||p||Srr+r#rrr__le__:szVersion.__le__cCs||p||Sr)r,r'r#rrr__ge__=szVersion.__ge__cCs t|jSr)hashrrrrr__hash__AszVersion.__hash__cCsd|jj|jfS)Nz%s('%s') __class__rrr0rrr__repr__DszVersion.__repr__cCs|jSrrr0rrr__str__GszVersion.__str__cCs tddS)NzPlease implement in subclasses.rr0rrr is_prereleaseJszVersion.is_prereleaseN)rrrrrr%r'r)r*r,r-r.r1r4r6propertyr7rrrrrsrc @seZdZdZddddddddddddd dd dd Zd d ZddZddZeddZ ddZ ddZ ddZ ddZ ddZddZdS) MatcherNcCs||kSrrvcprrrTzMatcher.cCs||kSrrr:rrrr>Ur?cCs||kp||kSrrr:rrrr>Vr?cCs||kp||kSrrr:rrrr>Wr?cCs||kSrrr:rrrr>Xr?cCs||kSrrr:rrrr>Yr?cCs||kp||kSrrr:rrrr>[r?cCs||kSrrr:rrrr>\r?)<><=>======~=!=cCst|Srrr rrrraszMatcher.parse_requirementcCs|jdkrtd||_}||}|s:td||j|_|j|_g}|jr|jD]d\}}| dr|dkrtd||ddd}}||n||d}}| |||fq^t ||_ dS) NzPlease specify a version classz Not valid: %rz.*)rDrGz#'.*' not allowed for %r constraintsTF) version_class ValueErrorrrrnamelowerkeyZ constraintsendswithappendtupler)rrrZclistopZvnprefixrrrrds*      zMatcher.__init__cCsxt|tr||}|jD]X\}}}|j|}t|trDt||}|s`d||jjf}t |||||sdSqdS)z Check if the provided version matches the constraints. :param version: The version to match against this instance. :type version: String or :class:`Version` instance. z%r not implemented for %sFT) isinstancerrIr _operatorsgetgetattrr3rr)rversionoperator constraintrSfmsgrrrmatchs       z Matcher.matchcCs6d}t|jdkr2|jdddkr2|jdd}|S)Nrr)rDrE)lenr)rresultrrr exact_versions zMatcher.exact_versioncCs0t|t|ks|j|jkr,td||fdS)Nzcannot compare %s and %s)r!rKr"r#rrrr%szMatcher._check_compatiblecCs"|||j|jko |j|jkSr)r%rMrr#rrrr's zMatcher.__eq__cCs || Srr(r#rrrr)szMatcher.__ne__cCst|jt|jSr)r/rMrr0rrrr1szMatcher.__hash__cCsd|jj|jfS)Nz%s(%r)r2r0rrrr4szMatcher.__repr__cCs|jSrr5r0rrrr6szMatcher.__str__)rrrrIrUrrr]r8r`r%r'r)r1r4r6rrrrr9Os* r9zk^v?(\d+!)?(\d+(\.\d+)*)((a|b|c|rc)(\d+))?(\.(post)(\d+))?(\.(dev)(\d+))?(\+([a-zA-Z\d]+(\.[a-zA-Z\d]+)?))?$c Cs|}t|}|s"td||}tdd|ddD}t|dkrl|ddkrl|dd}qF|dszd}n t|d}|dd }|d d }|d d }|d}|dkrd}n|dt|df}|dkrd}n|dt|df}|dkrd}n|dt|df}|dkr*d}nHg} |dD]0} | rTdt| f} nd| f} | | q8t| }|s|s|rd}nd}|sd}|sd}||||||fS)NzNot a valid version: %scss|]}t|VqdSrint.0r;rrr sz_pep_440_key..r.r )NNr)arg)z)_)final) rPEP440_VERSION_REr]r groupsrPsplitr^rbisdigitrO) rmrtZnumsZepochpreZpostdevZlocalrpartrrr _pep_440_keysT          r{c@s6eZdZdZddZedddddgZed d Zd S) raIA rational version. Good: 1.2 # equivalent to "1.2.0" 1.2.0 1.2a1 1.2.3a2 1.2.3b1 1.2.3c1 1.2.3.4 TODO: fill this out Bad: 1 # minimum two numbers 1.2a # release level must have a release serial 1.2.3b cCs<t|}t|}|}tdd|ddD|_|S)Ncss|]}t|VqdSrrarcrrrresz*NormalizedVersion.parse..rrf)_normalized_keyrsr]rtrPru_release_clause)rrr_rwrtrrrr s  zNormalizedVersion.parserobr<rcrycstfddjDS)Nc3s |]}|r|djkVqdS)rN) PREREL_TAGS)rdtr0rrresz2NormalizedVersion.is_prerelease..)anyrr0rr0rr7szNormalizedVersion.is_prereleaseN) rrrrrsetrr8r7rrrrrs  cCs>t|}t|}||krdS||s*dSt|}||dkS)NTFrf)str startswithr^)xynrrr _match_prefixs rc @sneZdZeZddddddddd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZdS)r_match_compatible _match_lt _match_gt _match_le _match_ge _match_eq_match_arbitrary _match_ne)rFr@rArBrCrDrErGcCsV|rd|ko|jd}n|jd o,|jd}|rN|jddd}||}||fS)N+rgrr)rrrurI)rrXrZrSZ strip_localrrrr _adjust_local6s zNormalizedMatcher._adjust_localcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrfcSsg|] }t|qSrrrdirrr Isz/NormalizedMatcher._match_lt..rr}joinrrrXrZrSZrelease_clauseZpfxrrrrDs zNormalizedMatcher._match_ltcCsD||||\}}||krdS|j}ddd|D}t|| S)NFrfcSsg|] }t|qSrrrrrrrQsz/NormalizedMatcher._match_gt..rrrrrrLs zNormalizedMatcher._match_gtcCs||||\}}||kSrrrrXrZrSrrrrTszNormalizedMatcher._match_lecCs||||\}}||kSrrrrrrrXszNormalizedMatcher._match_gecCs.||||\}}|s ||k}n t||}|SrrrrrXrZrSr_rrrr\s   zNormalizedMatcher._match_eqcCst|t|kSrrrrrrrdsz"NormalizedMatcher._match_arbitrarycCs0||||\}}|s ||k}n t|| }|Srrrrrrrgs   zNormalizedMatcher._match_necCsf||||\}}||krdS||kr*dS|j}t|dkrH|dd}ddd|D}t||S)NTFrrgrfcSsg|] }t|qSrrrrrrrzsz7NormalizedMatcher._match_compatible..)rr}r^rrrrrrros  z#NormalizedMatcher._match_compatibleN)rrrrrIrUrrrrrrrrrrrrrr's& z[.+-]$z^[.](\d)z0.\1z^[.-]z ^\((.*)\)$\1z^v(ersion)?\s*(\d+)z\2z^r(ev)?\s*(\d+)z[.]{2,}rfz\b(alfa|apha)\balphaz\b(pre-alpha|prealpha)\bz pre.alphaz \(beta\)$betaz ^[:~._+-]+z [,*")([\]]z[~:+_ -]z\.$z (\d+(\.\d+)*)cCsL|}tD]\}}|||}q|s.d}t|}|sFd}|}n|dd}dd|D}t|dkr~| dqft|dkr|| d}n8d dd|ddD|| d}|dd}d d d|D}|}|rt D]\}}|||}q|s|}nd |kr*d nd }|||}t |sHd}|S) z Try to suggest a semantic form for a version for which _suggest_normalized_version couldn't come up with anything. z0.0.0rrfcSsg|] }t|qSrrarrrrrsz-_suggest_semantic_version..NcSsg|] }t|qSrrrrrrrscSsg|] }t|qSrrrrrrrsry-r)rrL _REPLACEMENTSsub_NUMERIC_PREFIXr]rtrur^rOendr_SUFFIX_REPLACEMENTS is_semver)rr_ZpatreplrwrSsuffixseprrr_suggest_semantic_versions:      ,    rcCshzt||WStk r"YnX|}dD]\}}|||}q0tdd|}tdd|}tdd|}tdd |}td d |}|d r|d d}tdd |}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd|}tdd |}z t|Wntk rbd}YnX|S)!aSuggest a normalized version close to the given version string. If you have a version string that isn't rational (i.e. NormalizedVersion doesn't like it) then you might be able to get an equivalent (or close) rational version from this function. This does a number of simple normalizations to the given string, based on observation of versions currently in use on PyPI. Given a dump of those version during PyCon 2009, 4287 of them: - 2312 (53.93%) match NormalizedVersion without change with the automatic suggestion - 3474 (81.04%) match when using this suggestion method @param s {str} An irrational version string. @returns A rational version string, or None, if couldn't determine one. ))z-alpharo)z-betar~)rro)rr~)rr<)z-finalr)z-prer<)z-releaser)z.releaser)z-stabler)rrf)rqrf) r)z.finalr)rrrzpre$Zpre0zdev$Zdev0z([abc]|rc)[\-\.](\d+)$z\1\2z[\-\.](dev)[\-\.]?r?(\d+)$z.\1\2z[.~]?([abc])\.?rr;rNz\b0+(\d+)(?!\d)z (\d+[abc])$z\g<1>0z\.?(dev-r|dev\.r)\.?(\d+)$z.dev\2z-(a|b|c)(\d+)$z[\.\-](dev|devel)$z.dev0z(?![\.\-])dev$z(final|stable)$rz\.?(r|-|-r)\.?(\d+)$z.post\2z\.?(dev|git|bzr)\.?(\d+)$z\.?(pre|preview|-c)(\d+)$zc\g<2>zp(\d+)$z.post\1)r|r rLreplacererr)rZrsZorigrrrr_suggest_normalized_versions>      rz([a-z]+|\d+|[\.-])r<zfinal-@)rxZpreviewrrryrrfcCsrdd}g}||D]T}|dr^|dkrD|rD|ddkrD|q*|r^|ddkr^|qD||qt|S)NcSstg}t|D]R}t||}|rd|ddkrBdkrRnn |d}nd|}||q|d|S)N0r9**final) _VERSION_PARTrurL_VERSION_REPLACErVzfillrO)rr_r=rrr get_partsCs     z_legacy_key..get_partsrrrgz*final-Z00000000)rpoprOrP)rrr_r=rrr _legacy_keyBs      rc@s eZdZddZeddZdS)rcCst|Sr)rr rrrr]szLegacyVersion.parsecCs8d}|jD](}t|tr |dr |dkr d}q4q |S)NFrrT)rrTrr)rr_rrrrr7`s zLegacyVersion.is_prereleaseNrrrrr8r7rrrrr\sc@s4eZdZeZeejZded<e dZ ddZ dS)r rrFz^(\d+(\.\d+)*)cCs`||kr dS|jt|}|s2td||dS|d}d|krV|ddd}t||S)NFzACannot compute compatible match for version %s and constraint %sTrrfr) numeric_rer]rloggerZwarningrtrsplitr)rrXrZrSrwrrrrrss zLegacyMatcher._match_compatibleN) rrrrrIdictr9rUrcompilerrrrrrr ks   zN^(\d+)\.(\d+)\.(\d+)(-[a-z0-9]+(\.[a-z0-9-]+)*)?(\+[a-z0-9]+(\.[a-z0-9-]+)*)?$cCs t|Sr) _SEMVER_REr])rrrrrsrc Csndd}t|}|st||}dd|ddD\}}}||dd||dd}}|||f||fS) NcSs8|dkr|f}n$|ddd}tdd|D}|S)NrrfcSs"g|]}|r|dn|qS)r)rvr)rdr=rrrrsz5_semantic_key..make_tuple..)rurP)rZabsentr_rrrr make_tuples z!_semantic_key..make_tuplecSsg|] }t|qSrrarrrrrsz!_semantic_key..r|r)rr rt) rrrwrtmajorminorZpatchrxZbuildrrr _semantic_keys rc@s eZdZddZeddZdS)r cCst|Sr)rr rrrrszSemanticVersion.parsecCs|jdddkS)Nrrr)rr0rrrr7szSemanticVersion.is_prereleaseNrrrrrr sc@seZdZeZdS)r N)rrrr rIrrrrr sc@s6eZdZd ddZddZddZdd Zd d ZdS) VersionSchemeNcCs||_||_||_dSr)rMmatcher suggester)rrMrrrrrrszVersionScheme.__init__cCs2z|j|d}Wntk r,d}YnX|SNTF)rrIr rrr_rrris_valid_versions   zVersionScheme.is_valid_versioncCs0z||d}Wntk r*d}YnX|Sr)rr rrrris_valid_matchers   zVersionScheme.is_valid_matchercCs|d|S)z: Used for processing some metadata fields zdummy_name (%s))rr rrris_valid_constraint_listsz&VersionScheme.is_valid_constraint_listcCs|jdkrd}n ||}|Sr)rrrrrsuggests  zVersionScheme.suggest)N)rrrrrrrrrrrrrs  rcCs|Srrr rrrr>r?r>) normalizedlegacyZsemanticrdefaultcCs|tkrtd|t|S)Nzunknown scheme name: %r)_SCHEMESrJ)rKrrrr s )*rZloggingrcompatrutilr__all__Z getLoggerrrrJr objectrr9rrsr{r|rrrrrrrrIrrrrr rrrr r rrr rrrrs   1d =$ W               .r  $