a ‚oe{ã@sÆddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZmZddlmZmZddlmZmZmZddlmZmZddlmZmZddlm Z m!Z!dd l"m#Z#dd l$m%Z%dd l&m'Z'dd l m(Z(dd l)m*Z*m+Z+m,Z,m-Z-gd¢Z.Gdd„de/ƒZ0Gdd„dƒZ1Gdd„dƒZ2Gdd„de2ƒZ3Gdd„de4ƒZ5Gdd„de5ƒZ6Gdd„dƒZ7Gdd„de7e8ƒZ9Gdd „d ej:ƒZ;Gd!d"„d"ƒZGd'd(„d(ƒZ?Gd)d*„d*ƒZ@Gd+d,„d,ƒZAeGd-d.„d.ee>ƒƒZBGd/d0„d0e=ƒZCd1d2„ZDd3d4„ZEej d5œd6d7„ZFd8d9„ZGe jHeejId:�ZJe-e6e9fd5œd;d<„ZKd=d>„ZLd?d@„ZMe+eNe*eNfd5œdAdB„ZOdCdD„ZPdEdF„ZQdS)GéNé)Ú _adaptersÚ_metaÚ _py39compat)ÚFreezableDefaultDictÚPair)Ú NullFinderÚinstallÚ pypy_partial)Ú method_cacheÚ pass_none)Úalways_iterableÚunique_everseen)ÚPackageMetadataÚ SimplePath)Úsuppress)Ú import_module)ÚMetaPathFinder)Ústarmap)ÚListÚMappingÚOptionalÚUnion) Ú DistributionÚDistributionFinderrÚPackageNotFoundErrorÚ distributionÚ distributionsÚ entry_pointsÚfilesÚmetadataÚpackages_distributionsÚrequiresÚversionc@s$eZdZdZdd„Zedd„ƒZdS)rzThe package was not found.cCs d|j›�S)Nz"No package metadata was found for ©Úname©Úself©r(ú>> for item in Sectioned.read(Sectioned._sample): ... print(item) Pair(name='sec1', value='# comments ignored') Pair(name='sec1', value='a = 1') Pair(name='sec1', value='b = 2') Pair(name='sec2', value='a = 2') >>> res = Sectioned.section_pairs(Sectioned._sample) >>> item = next(res) >>> item.name 'sec1' >>> item.value Pair(name='a', value='1') >>> item = next(res) >>> item.value Pair(name='b', value='2') >>> item = next(res) >>> item.name 'sec2' >>> item.value Pair(name='a', value='2') >>> list(res) [] zm [sec1] # comments ignored a = 1 b = 2 [sec2] a = 2 cCsdd„|j||jd�DƒS)Ncss,|]$}|jdur|jt |j¡d�VqdS)N)Úvalue)r%Ú_replacerÚparser4)Ú.0Úsectionr(r(r)Ú js þz*Sectioned.section_pairs..)Úfilter_)ÚreadÚvalid)ÚclsÚtextr(r(r)Ú section_pairshsþzSectioned.section_pairsNccsXt|ttj| ¡ƒƒ}d}|D]4}| d¡o4| d¡}|rF| d¡}qt||ƒVqdS)Nú[ú]z[])ÚfilterÚmapÚstrÚstripÚ splitlinesÚ startswithÚendswithr)r>r:Úlinesr%r4Z section_matchr(r(r)r;ps zSectioned.readcCs|o| d¡ S)Nú#)rG)Úliner(r(r)r<{szSectioned.valid)N) r.r/r0r1ÚtextwrapÚdedentÚlstripZ_sampleÚ classmethodr?Ú staticmethodr;r<r(r(r(r)r3?sÿ   r3c@s0eZdZdZejejdee dƒd�Z dd„Z dS)ÚDeprecatedTuplea Provide subscript item access for backward compatibility. >>> recwarn = getfixture('recwarn') >>> ep = EntryPoint(name='name', value='value', group='group') >>> ep[:] ('name', 'value', 'group') >>> ep[0] 'name' >>> len(recwarn) 1 zAEntryPoint tuple interface is deprecated. Access members by name.é©Ú stacklevelcCs| ¡| ¡|Sr+)Ú_warnÚ_key)r'Úitemr(r(r)Ú __getitem__•szDeprecatedTuple.__getitem__N) r.r/r0r1Ú functoolsÚpartialÚwarningsÚwarnÚDeprecationWarningr rUrXr(r(r(r)rQ€s ürQc@sÀeZdZUdZe d¡Zeed<eed<eed<dZ e ded<d d „Z d d „Z e d d„ƒZe dd„ƒZe dd„ƒZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„ZdS)%Ú EntryPointa An entry point as defined by Python packaging conventions. See `the packaging docs on entry points `_ for more information. >>> ep = EntryPoint( ... name=None, group=None, value='package.module:attr [extra1, extra2]') >>> ep.module 'package.module' >>> ep.attr 'attr' >>> ep.extras ['extra1', 'extra2'] zH(?P[\w.]+)\s*(:\s*(?P[\w.]+)\s*)?((?P\[.*\])\s*)?$r%r4ÚgroupNrÚdistcCst|ƒj|||d�dS)N©r%r4r_©ÚvarsÚupdate)r'r%r4r_r(r(r)Ú__init__ÆszEntryPoint.__init__cCsD|j |j¡}t| d¡ƒ}td| d¡p,d d¡ƒ}t t ||¡S)z¦Load the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object. ÚmoduleNÚattrÚÚ.) ÚpatternÚmatchr4rr_rBÚsplitrYÚreduceÚgetattr)r'rkrfÚattrsr(r(r)ÚloadÉszEntryPoint.loadcCs|j |j¡}| d¡S)Nrf©rjrkr4r_©r'rkr(r(r)rfÓszEntryPoint.modulecCs|j |j¡}| d¡S)Nrgrqrrr(r(r)rgØszEntryPoint.attrcCs$|j |j¡}t d| d¡p d¡S)Nz\w+Úextrasrh)rjrkr4ÚreÚfindallr_rrr(r(r)rsÝszEntryPoint.extrascCst|ƒj|d�|S)N©r`rb)r'r`r(r(r)Ú_forâszEntryPoint._forcCsd}t |t¡t|j|fƒS)zP Supply iter so one may construct dicts of EntryPoints by name. zJConstruction of dict of EntryPoints is deprecated in favor of EntryPoints.)r[r\r]Úiterr%)r'Úmsgr(r(r)Ú__iter__æsÿ zEntryPoint.__iter__c s(‡fdd„|Dƒ}tttj| ¡|ƒƒS)a$ EntryPoint matches the given parameters. >>> ep = EntryPoint(group='foo', name='bar', value='bing:bong [extra1, extra2]') >>> ep.matches(group='foo') True >>> ep.matches(name='bar', value='bing:bong [extra1, extra2]') True >>> ep.matches(group='foo', name='other') False >>> ep.matches() True >>> ep.matches(extras=['extra1', 'extra2']) True >>> ep.matches(module='bing') True >>> ep.matches(attr='bong') True c3s|]}tˆ|ƒVqdSr+©rn)r7Zparamr&r(r)r9óz%EntryPoint.matches..)ÚallrCÚoperatorÚeqÚvalues)r'Úparamsror(r&r)ÚmatchesñszEntryPoint.matchescCs|j|j|jfSr+rar&r(r(r)rVszEntryPoint._keycCs| ¡| ¡kSr+©rV©r'Úotherr(r(r)Ú__lt__ szEntryPoint.__lt__cCs| ¡| ¡kSr+rƒr„r(r(r)Ú__eq__szEntryPoint.__eq__cCs tdƒ‚dS)Nz!EntryPoint objects are immutable.)ÚAttributeError)r'r%r4r(r(r)Ú __setattr__szEntryPoint.__setattr__cCsd|j›d|j›d|j›d�S)NzEntryPoint(name=z, value=z, group=ú)rar&r(r(r)Ú__repr__sÿÿzEntryPoint.__repr__cCs t| ¡ƒSr+)ÚhashrVr&r(r(r)Ú__hash__szEntryPoint.__hash__)r.r/r0r1rtÚcompilerjrDÚ__annotations__r`rrerpr2rfrgrsrwrzr‚rVr†r‡r‰r‹r�r(r(r(r)r^šs2 ÿ     r^csheZdZdZdZejejde e dƒd�Z e dœ‡fdd„ Z eƒ ee d  ¡ƒ¡d d „Zd d „Z‡ZS)ÚDeprecatedLista> Allow an otherwise immutable object to implement mutability for compatibility. >>> recwarn = getfixture('recwarn') >>> dl = DeprecatedList(range(3)) >>> dl[0] = 1 >>> dl.append(3) >>> del dl[3] >>> dl.reverse() >>> dl.sort() >>> dl.extend([4]) >>> dl.pop(-1) 4 >>> dl.remove(1) >>> dl += [5] >>> dl + [6] [1, 2, 5, 6] >>> dl + (6,) [1, 2, 5, 6] >>> dl.insert(0, 0) >>> dl [0, 1, 2, 5] >>> dl == [0, 1, 2, 5] True >>> dl == (0, 1, 2, 5) True >>> len(recwarn) 1 r(zAEntryPoints list interface is deprecated. Cast to list if needed.rRrS©Ú method_namecs‡‡fdd„}ˆ|fS)Ncs| ¡ttƒˆƒ|i|¤ŽSr+)rUrnÚsuper)r'r,Úkwargs)Ú __class__r’r(r)ÚwrappedHsz7DeprecatedList._wrap_deprecated_method..wrappedr()r’r–©r•r‘r)Ú_wrap_deprecated_methodGsz&DeprecatedList._wrap_deprecated_methodzM__setitem__ __delitem__ append reverse extend pop remove __iadd__ insert sortcCs,t|tƒs| ¡t|ƒ}| t|ƒ|¡Sr+)Ú isinstanceÚtuplerUr•r„r(r(r)Ú__add__Vs zDeprecatedList.__add__cCs(t|tƒs| ¡t|ƒ}t|ƒ |¡Sr+)r™ršrUr‡r„r(r(r)r‡\s zDeprecatedList.__eq__)r.r/r0r1Ú __slots__rYrZr[r\r]r rUrDr˜ÚlocalsrdrCrlr›r‡Ú __classcell__r(r(r—r)r�s"üþÿr�cs\eZdZdZdZ‡fdd„Zdd„Zedd„ƒZed d „ƒZ e d d „ƒZ e d d„ƒZ ‡ZS)Ú EntryPointszC An immutable collection of selectable EntryPoint objects. r(cs\t|tƒr&tjdtdd�tƒ |¡Sztt|j |d�ƒƒWSt yVt |ƒ‚Yn0dS)z; Get the EntryPoint in self matching name. zGAccessing entry points by index is deprecated. Cast to tuple if needed.rRrSr$N) r™Úintr[r\r]r“rXÚnextrxÚselectÚ StopIterationÚKeyErrorr-r—r(r)rXks ü  zEntryPoints.__getitem__c s$‡fdd„|Dƒ}tdd„|DƒƒS)zv Select entry points from self that match the given parameters (typically group and/or name). c3s |]}tj|fiˆ¤ŽVqdSr+)rZ ep_matches©r7Úep©r�r(r)r9�r|z%EntryPoints.select..css|]\}}|r|VqdSr+r()r7r¦Ú predicater(r(r)r9‚r|©rŸ)r'r�Z candidatesr(r§r)r¢|szEntryPoints.selectcCsdd„|DƒS)zB Return the set of all names of all entry points. cSsh|] }|j’qSr(r$r¥r(r(r)Ú ‰r|z$EntryPoints.names..r(r&r(r(r)Únames„szEntryPoints.namescCsdd„|DƒS)z« Return the set of all groups of all entry points. For coverage while SelectableGroups is present. >>> EntryPoints().groups set() cSsh|] }|j’qSr()r_r¥r(r(r)rª”r|z%EntryPoints.groups..r(r&r(r(r)Úgroups‹s zEntryPoints.groupscs|‡fdd„| |¡DƒƒS)Nc3s|]}| ˆ¡VqdSr+)rwr¥rvr(r)r9˜r|z-EntryPoints._from_text_for..)Ú _from_text)r=r>r`r(rvr)Ú_from_text_for–szEntryPoints._from_text_forcCsdd„t |pd¡DƒS)Ncss&|]}t|jj|jj|jd�VqdS)raN)r^r4r%)r7rWr(r(r)r9œsÿz)EntryPoints._from_text..rh)r3r?)r>r(r(r)r­šs þzEntryPoints._from_text)r.r/r0r1rœrXr¢r2r«r¬rOr®rPr­ržr(r(r—r)rŸds    rŸcsveZdZdZejejdee dƒd�Z ‡fdd„Z d‡fdd „ Z ‡fd d „Z ‡fd d „Z‡fdd„Z‡fdd„Z‡ZS)Ú Deprecateda» Compatibility add-in for mapping to indicate that mapping behavior is deprecated. >>> recwarn = getfixture('recwarn') >>> class DeprecatedDict(Deprecated, dict): pass >>> dd = DeprecatedDict(foo='bar') >>> dd.get('baz', None) >>> dd['foo'] 'bar' >>> list(dd) ['foo'] >>> list(dd.keys()) ['foo'] >>> 'foo' in dd True >>> list(dd.values()) ['bar'] >>> len(recwarn) 1 z:SelectableGroups dict interface is deprecated. Use select.rRrScs| ¡tƒ |¡Sr+)rUr“rXr-r—r(r)rXÀszDeprecated.__getitem__Ncs| ¡tƒ ||¡Sr+)rUr“Úget)r'r%Údefaultr—r(r)r°ÄszDeprecated.getcs| ¡tƒ ¡Sr+)rUr“rzr&r—r(r)rzÈszDeprecated.__iter__cs| ¡tƒj|ŽSr+)rUr“Ú __contains__)r'r,r—r(r)r²ÌszDeprecated.__contains__cs| ¡tƒ ¡Sr+)rUr“Úkeysr&r—r(r)r³ÐszDeprecated.keyscs| ¡tƒ ¡Sr+)rUr“r€r&r—r(r)r€ÔszDeprecated.values)N)r.r/r0r1rYrZr[r\r]r rUrXr°rzr²r³r€ržr(r(r—r)r¯¢sü    r¯csPeZdZdZedd„ƒZe‡fdd„ƒZedd„ƒZedd „ƒZ d d „Z ‡Z S) ÚSelectableGroupszs A backward- and forward-compatible result from entry_points that fully implements the dict interface. cCs4t d¡}t||d�}t ||¡}|dd„|DƒƒS)Nr_©Úkeycss|]\}}|t|ƒfVqdSr+r©)r7r_Úepsr(r(r)r9är|z(SelectableGroups.load..)r~Ú attrgetterÚsortedÚ itertoolsÚgroupby)r=r·Zby_groupZorderedZgroupedr(r(r)rpßs   zSelectableGroups.loadcstt|ƒ ¡}ttj |¡ƒS)zH Reconstruct a list of all entrypoints from the groups. )r“r¯r€rŸrºÚchainÚ from_iterable)r'r¬r—r(r)Ú_allæszSelectableGroups._allcCs|jjSr+)r¾r¬r&r(r(r)r¬îszSelectableGroups.groupscCs|jjS)zR for coverage: >>> SelectableGroups().names set() )r¾r«r&r(r(r)r«òszSelectableGroups.namescKs|s|S|jjfi|¤ŽSr+)r¾r¢)r'r�r(r(r)r¢ûszSelectableGroups.select) r.r/r0r1rOrpr2r¾r¬r«r¢ržr(r(r—r)r´Ùs   r´c@s*eZdZdZd dd„Zdd„Zdd„Zd S) Ú PackagePathz"A reference to a path in a packageúutf-8cCs<| ¡j|d��}| ¡WdƒS1s.0YdS)N©Úencoding©ÚlocateÚopenr;)r'rÂÚstreamr(r(r)Ú read_textszPackagePath.read_textcCs:| ¡ d¡�}| ¡WdƒS1s,0YdS)NÚrbrÃ)r'rÆr(r(r)Ú read_binaryszPackagePath.read_binarycCs |j |¡S)z'Return a path-like object for this path)r`Ú locate_filer&r(r(r)rÄ szPackagePath.locateN)rÀ)r.r/r0r1rÇrÉrÄr(r(r(r)r¿s r¿c@seZdZdd„Zdd„ZdS)ÚFileHashcCs| d¡\|_}|_dS)Nú=)Ú partitionÚmoder4)r'ÚspecÚ_r(r(r)reszFileHash.__init__cCsd|j›d|j›d�S)Nz)rÎr4r&r(r(r)r‹szFileHash.__repr__N)r.r/r0rer‹r(r(r(r)rËsrËc@söeZdZdZejdd„ƒZejdd„ƒZee dœdd„ƒZ ed d „ƒZ e d d „ƒZ e d d„ƒZeejdœdd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZedd„ƒZdd„Zdd„Zed d!„ƒZd"d#„Zd$d%„Zed&d'„ƒZe d(d)„ƒZd*S)+rzA Python distribution package.cCsdS)z¶Attempt to load metadata file given by the name. :param filename: The name of the file in the distribution info. :return: The text if found, otherwise None. Nr(©r'Úfilenamer(r(r)rÇszDistribution.read_textcCsdS)z[ Given a path to a file in this distribution, return a path to it. Nr(©r'Úpathr(r(r)rÊ$szDistribution.locate_filer$cCs>|s tdƒ‚zt|j|d�ƒWSty8t|ƒ‚Yn0dS)a®Return the Distribution for the given package name. :param name: The name of the distribution package to search for. :return: The Distribution instance (or subclass thereof) for the named package, if found. :raises PackageNotFoundError: When the named package's distribution metadata cannot be found. :raises ValueError: When an invalid value is supplied for name. z A distribution name is required.r$N)Ú ValueErrorr¡Údiscoverr£r)r=r%r(r(r)Ú from_name+s  zDistribution.from_namec sN| dd¡‰ˆr|rtdƒ‚ˆp.tjfi|¤Ž‰tj ‡fdd„| ¡Dƒ¡S)aReturn an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing a context. :context: A ``DistributionFinder.Context`` object. :return: Iterable of Distribution objects for all packages. ÚcontextNz cannot accept context and kwargsc3s|]}|ˆƒVqdSr+r()r7Zresolver©rÙr(r)r9Ksz(Distribution.discover..)ÚpoprÖrÚContextrºr¼r½Ú_discover_resolvers)r=r”r(rÚr)r×=s ÿzDistribution.discovercCstt |¡ƒS)z°Return a Distribution for the indicated metadata path :param path: a string or path-like object :return: a concrete Distribution instance for the path )ÚPathDistributionÚpathlibÚPath©rÕr(r(r)ÚatOszDistribution.atcCsdd„tjDƒ}td|ƒS)z#Search the meta_path for resolvers.css|]}t|ddƒVqdS)Úfind_distributionsNr{)r7Úfinderr(r(r)r9[sz3Distribution._discover_resolvers..N)ÚsysÚ meta_pathrB)Zdeclaredr(r(r)rÝXsÿz Distribution._discover_resolvers©ÚreturncCs.| d¡p| d¡p| d¡}t t |¡¡S)z°Return the parsed metadata for this Distribution. The returned object will have keys that name the various bits of metadata. See PEP 566 for details. ZMETADATAzPKG-INFOrh)rÇrZMessageÚemailZmessage_from_string©r'r>r(r(r)r `s  ÿúzDistribution.metadatacCs |jdS)z8Return the 'Name' metadata for the distribution package.ÚName©r r&r(r(r)r%qszDistribution.namecCs t |j¡S)z(Return a normalized version of the name.)ÚPreparedÚ normalizer%r&r(r(r)Ú_normalized_namevszDistribution._normalized_namecCs |jdS)z;Return the 'Version' metadata for the distribution package.ZVersionrìr&r(r(r)r#{szDistribution.versioncCst | d¡|¡S)Nzentry_points.txt)rŸr®rÇr&r(r(r)r€szDistribution.entry_pointscs2d‡fdd„ ‰t‡fdd„ƒ}|ˆ ¡p.ˆ ¡ƒS)aBFiles in this distribution. :return: List of PackagePath for this distribution or None Result is `None` if the metadata file that enumerates files (i.e. RECORD for dist-info or SOURCES.txt for egg-info) is missing. Result may be empty if the metadata exists but is empty. Ncs6t|ƒ}|rt|ƒnd|_|r&t|ƒnd|_ˆ|_|Sr+)r¿rËrŒr Úsizer`)r%rŒZsize_strÚresultr&r(r)Ú make_file�s z%Distribution.files..make_filecsttˆt |¡ƒƒSr+)ÚlistrÚcsvÚreader)rI)ròr(r)Ú make_files—sz&Distribution.files..make_files)NN)r Ú_read_files_distinfoÚ_read_files_egginfo)r'rör()ròr'r)r„s zDistribution.filescCs| d¡}|o| ¡S)z* Read the lines of RECORD ZRECORD)rÇrFrêr(r(r)r÷�s z!Distribution._read_files_distinfocCs| d¡}|otdj| ¡ƒS)z` SOURCES.txt might contain literal commas, so wrap each line in quotes. z SOURCES.txtz"{}")rÇrCÚformatrFrêr(r(r)rø¤s z Distribution._read_files_egginfocCs| ¡p| ¡}|ot|ƒS)z6Generated requirements specified for this Distribution)Ú_read_dist_info_reqsÚ_read_egg_info_reqsró)r'Zreqsr(r(r)r"¬szDistribution.requirescCs |j d¡S)Nz Requires-Dist)r Zget_allr&r(r(r)rú²sz!Distribution._read_dist_info_reqscCs| d¡}t|jƒ|ƒS)Nz requires.txt)rÇr Ú_deps_from_requires_text)r'Úsourcer(r(r)rûµs z Distribution._read_egg_info_reqscCs| t |¡¡Sr+)Ú%_convert_egg_info_reqs_to_simple_reqsr3r;)r=rýr(r(r)rü¹sz%Distribution._deps_from_requires_textc#sJdd„‰‡fdd„}dd„}|D]$}||jƒ}|j|||jƒVq dS)aÄ Historically, setuptools would solicit and store 'extra' requirements, including those with environment markers, in separate sections. More modern tools expect each dependency to be defined separately, with any relevant extras and environment markers attached directly to that requirement. This method converts the former to the latter. See _test_deps_from_requires_text for an example. cSs|od|›d�S)Nz extra == "ú"r(r$r(r(r)Úmake_conditionÉszJDistribution._convert_egg_info_reqs_to_simple_reqs..make_conditioncsX|pd}| d¡\}}}|r,|r,d|›d�}ttd|ˆ|ƒgƒƒ}|rTdd |¡SdS)Nrhú:ú(rŠz; z and )rÍrórBÚjoin)r8ZextraÚsepZmarkersZ conditions©rr(r)Ú quoted_markerÌs  zIDistribution._convert_egg_info_reqs_to_simple_reqs..quoted_markercSs dd|vS)z� PEP 508 requires a space between the url_spec and the quoted_marker. Ref python/importlib_metadata#357. ú ú@r()Zreqr(r(r)Ú url_req_spaceÔszIDistribution._convert_egg_info_reqs_to_simple_reqs..url_req_spaceN)r4r%)Zsectionsrr r8Úspacer(rr)rþ½s   z2Distribution._convert_egg_info_reqs_to_simple_reqsN)r.r/r0r1ÚabcÚabstractmethodrÇrÊrOrDrØr×rPrârÝr2rrr r%rïr#rrr÷rør"rúrûrürþr(r(r(r)rsF            rc@s2eZdZdZGdd„dƒZejeƒfdd„ƒZdS)rzJ A MetaPathFinder capable of discovering installed distributions. c@s(eZdZdZdZdd„Zedd„ƒZdS)zDistributionFinder.Contextaw Keyword arguments presented by the caller to ``distributions()`` or ``Distribution.discover()`` to narrow the scope of a search for distributions in all DistributionFinders. Each DistributionFinder may expect any parameters and should attempt to honor the canonical parameters defined below when appropriate. NcKst|ƒ |¡dSr+rb)r'r”r(r(r)reøsz#DistributionFinder.Context.__init__cCst|ƒ dtj¡S)zü The sequence of directory path that a distribution finder should search. Typically refers to Python installed package paths such as "site-packages" directories and defaults to ``sys.path``. rÕ)rcr°rårÕr&r(r(r)rÕûs zDistributionFinder.Context.path)r.r/r0r1r%rer2rÕr(r(r(r)rÜæs  rÜcCsdS)zÝ Find distributions. Return an iterable of all Distribution instances capable of loading the metadata for packages matching the ``context``, a DistributionFinder.Context instance. Nr()r'rÙr(r(r)rãsz%DistributionFinder.find_distributionsN)r.r/r0r1rÜr r rãr(r(r(r)rás rcsheZdZdZe ¡‡fdd„ƒZdd„Zdd„Zdd „Z d d „Z d d „Z e dd„ƒZ edd„ƒZ‡ZS)ÚFastPathzs Micro-optimized class for searching a path for children. >>> FastPath('').children() ['...'] cs tƒ |¡Sr+)r“Ú__new__)r=Úrootr—r(r)rszFastPath.__new__cCs ||_dSr+)r)r'rr(r(r)reszFastPath.__init__cCst |j|¡Sr+)rßràr)r'Úchildr(r(r)Újoinpath!szFastPath.joinpathcCslttƒ� t |jpd¡WdƒS1s.0Yttƒ�| ¡WdƒS1s^0YgS)Nri)rÚ ExceptionÚosÚlistdirrÚ zip_childrenr&r(r(r)Úchildren$s  . &zFastPath.childrencCs2t |j¡}|j ¡}|j|_t dd„|Dƒ¡S)Ncss |]}| tjd¡dVqdS)rrN)rlÚ posixpathr)r7rr(r(r)r90r|z(FastPath.zip_children..)ÚzippràrZnamelistrÚdictÚfromkeys)r'Zzip_pathr«r(r(r)r+s  zFastPath.zip_childrencCs| |j¡ |¡Sr+)ÚlookupÚmtimeÚsearchr-r(r(r)r2szFastPath.searchcCsDttƒ�t |j¡jWdƒS1s,0Y|j ¡dSr+)rÚOSErrorrÚstatrÚst_mtimerÚ cache_clearr&r(r(r)r5s ,zFastPath.mtimecCst|ƒSr+)ÚLookup)r'rr(r(r)r;szFastPath.lookup)r.r/r0r1rYÚ lru_cacherrerrrrr2rr rržr(r(r—r)r s r c@s"eZdZedœdd„Zdd„ZdS)r"rác Csætj |j¡ ¡}| d¡}ttƒ|_ttƒ|_ |  ¡D]”}| ¡}| d¡rˆ|  d¡d  d¡d}t  |¡}|j| | |¡¡q8|r8|dkr8|  d¡d  d¡d}t  |¡}|j | | |¡¡q8|j ¡|j  ¡dS)Nz.egg©z .dist-infoz .egg-inforirú-zegg-info)rrÕÚbasenamerÚlowerrHrróÚinfosÚeggsrÚ rpartitionrÍrírîÚappendrÚlegacy_normalizeZfreeze) r'rÕÚbaseZ base_is_eggrZlowr%Ú normalizedÚlegacy_normalizedr(r(r)reAs          zLookup.__init__cCsP|r|j|jntj |j ¡¡}|r2|j|jntj |j ¡¡}t ||¡Sr+)r(r.rºr¼r½r€r)r/)r'Úpreparedr(r)r(r(r)rVsÿýÿýz Lookup.searchN)r.r/r0r rerr(r(r(r)r"@sr"c@s@eZdZdZdZdZdd„Zedd„ƒZedd„ƒZ d d „Z dS) rízE A prepared search for metadata on a possibly-named package. NcCs.||_|durdS| |¡|_| |¡|_dSr+)r%rîr.r,r/r-r(r(r)rels  zPrepared.__init__cCst dd|¡ ¡ dd¡S)zC PEP 503 normalization plus dashes as underscores. z[-_.]+r%rÐ)rtÚsubr'Úreplacer$r(r(r)rîsszPrepared.normalizecCs| ¡ dd¡S)z| Normalize the package name as found in the convention in older packaging tools versions and specs. r%rÐ)r'r2r$r(r(r)r,zszPrepared.legacy_normalizecCs t|jƒSr+)Úboolr%r&r(r(r)Ú__bool__‚szPrepared.__bool__) r.r/r0r1r.r/rerPrîr,r4r(r(r(r)ríds  ríc@s4eZdZdZe ¡fdd„Zedd„ƒZdd„Z dS) ÚMetadataPathFinderzÒA degenerate finder for distribution packages on the file system. This finder supplies only a find_distributions() method for versions of Python that do not have a PathFinder find_distributions(). cCs| |j|j¡}tt|ƒS)a  Find distributions. Return an iterable of all Distribution instances capable of loading the metadata for packages matching ``context.name`` (or all names if ``None`` indicated) along the paths in the list of directories ``context.path``. )Ú _search_pathsr%rÕrCrÞ)r'rÙÚfoundr(r(r)rãŽs z%MetadataPathFinder.find_distributionscs(t|ƒ‰tj ‡fdd„tt|ƒDƒ¡S)z1Find metadata directories in paths heuristically.c3s|]}| ˆ¡VqdSr+)r)r7rÕ©r0r(r)r9žsz3MetadataPathFinder._search_paths..)rírºr¼r½rCr )r=r%Úpathsr(r8r)r6šsÿz MetadataPathFinder._search_pathscCstj ¡dSr+)r rr!)r=r(r(r)Úinvalidate_caches¢sz$MetadataPathFinder.invalidate_cachesN) r.r/r0r1rrÜrãrOr6r:r(r(r(r)r5†s   r5csTeZdZedœdd„Zdd„Zejje_dd„Ze ‡fdd „ƒZ e d d „ƒZ ‡Z S) rÞrácCs ||_dS)zfConstruct a distribution. :param path: SimplePath indicating the metadata directory. N)Ú_pathrÔr(r(r)re§szPathDistribution.__init__cCsHttttttƒ�$|j |¡jdd�WdƒS1s:0YdS)NrÀrÁ) rÚFileNotFoundErrorÚIsADirectoryErrorr¤ÚNotADirectoryErrorÚPermissionErrorr;rrÇrÒr(r(r)rÇ®sûzPathDistribution.read_textcCs |jj|Sr+)r;ÚparentrÔr(r(r)rʺszPathDistribution.locate_filecs.tj t|jƒ¡}ttjƒ| |¡ƒp,t ƒj S)zz Performance optimization: where possible, resolve the normalized name from the file system path. ) rrÕr&rDr;r rírîÚ_name_from_stemr“rï)r'Ústemr—r(r)rï½sþz!PathDistribution._normalized_namecCs0tj |¡\}}|dvrdS| d¡\}}}|S)a7 >>> PathDistribution._name_from_stem('foo-3.0.egg-info') 'foo' >>> PathDistribution._name_from_stem('CherryPy-3.0.dist-info') 'CherryPy' >>> PathDistribution._name_from_stem('face.egg-info') 'face' >>> PathDistribution._name_from_stem('foo.bar') r$Nr%)rrÕÚsplitextrÍ)rBrÓÚextr%rÚrestr(r(r)rAÉs z PathDistribution._name_from_stem)r.r/r0rrerÇrr1rÊr2rïrPrAržr(r(r—r)rÞ¦s  rÞcCs t |¡S)zÎGet the ``Distribution`` instance for the named package. :param distribution_name: The name of the distribution package as a string. :return: A ``Distribution`` instance (or subclass thereof). )rrØ©Zdistribution_namer(r(r)rÛsrcKstjfi|¤ŽS)z|Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances. )rr×)r”r(r(r)räsrrçcCs t |¡jS)z¹Get the metadata for the named package. :param distribution_name: The name of the distribution package to query. :return: A PackageMetadata containing the parsed metadata. )rrØr rFr(r(r)r ìsr cCs t|ƒjS)zìGet the version string for the named package. :param distribution_name: The name of the distribution package to query. :return: The version string for the package as defined in the package's "Version" metadata key. )rr#rFr(r(r)r#õsr#rµcKs2tj dd„ttƒƒDƒ¡}t |¡jfi|¤ŽS)a‹Return EntryPoint objects for all installed packages. Pass selection parameters (group or name) to filter the result to entry points matching those properties (see EntryPoints.select()). For compatibility, returns ``SelectableGroups`` object unless selection parameters are supplied. In the future, this function will return ``EntryPoints`` instead of ``SelectableGroups`` even when no selection parameters are supplied. For maximum future compatibility, pass selection parameters or invoke ``.select`` with parameters on the result. :return: EntryPoints or SelectableGroups for all installed packages. css|] }|jVqdSr+)r)r7r`r(r(r)r9szentry_points..)rºr¼r½Ú_uniquerr´rpr¢)r�r·r(r(r)rs ÿrcCs t|ƒjS)z·Return a list of files for the named package. :param distribution_name: The name of the distribution package to query. :return: List of files composing the distribution. )rrrFr(r(r)rsrcCs t|ƒjS)z¡ Return a list of requirements for the named package. :return: An iterator of requirements, suitable for packaging.requirement.Requirement. )rr"rFr(r(r)r"(sr"cCsHt t¡}tƒD].}t|ƒp"t|ƒD]}|| |jd¡q$qt|ƒS)zï Return a mapping of top-level packages to their distributions. >>> import collections.abc >>> pkgs = packages_distributions() >>> all(isinstance(dist, collections.abc.Sequence) for dist in pkgs.values()) True rë) Ú collectionsÚ defaultdictrórÚ_top_level_declaredÚ_top_level_inferredr+r r)Z pkg_to_distr`Úpkgr(r(r)r!2s  r!cCs| d¡p d ¡S)Nz top_level.txtrh)rÇrlrvr(r(r)rJCsrJcCsdd„t|jƒDƒS)NcSs:h|]2}|jdkrt|jƒdkr*|jdn | d¡j’qS)z.pyrrrh)ÚsuffixÚlenÚpartsÚ with_suffixr%)r7Úfr(r(r)rªHs þz&_top_level_inferred..)r rrvr(r(r)rKGsþrK)Rrrtr rôrårrérßr~rLr[rYrºrrHrhrrrÚ _collectionsrrZ_compatrr r Ú _functoolsr r Ú _itertoolsr rrrÚ contextlibrÚ importlibrÚ importlib.abcrrÚtypingrrrrÚ__all__ÚModuleNotFoundErrorrr3rQr^rór�rŸr¯rr´Ú PurePosixPathr¿rËrrr r"rír5rÞrrr r#rZZnormalized_namerGrrr"rDr!rJrKr(r(r(r)Úsx     AF>7(I0/$"5   þ