o ?Ogw@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZddlmZddlmZmZddlmZmZddlmZddlmZmZdd lmZdd lmZdd l m!Z!dd l m"Z"dd l#m$Z$m%Z%m&Z&m'Z'gdZ(Gddde)Z*GdddZ+Gddde,ddZ-Gddde.Z/Gddde/Z0GdddZ1Gddde1e2Z3Gdd d ej4Z5Gd!d"d"Z6Gd#d$d$Z7Gd%d&d&e!Z8Gd'd(d(Z9Gd)d*d*Z:Gd+d,d,Z;Gd-d.d.e8Zd3d4Z?d5ejfd6d7Z@d8d9ZAd5e'e0e3ffd:d;ZBdd?ZDd5e%eEe$eEffd@dAZFdS)BN) _adapters_meta)PackageMetadata)FreezableDefaultDictPair) method_cache pass_none)unique_everseen)r SimplePath)suppress) import_module)MetaPathFinder)starmap)ListMappingOptionalUnion) DistributionDistributionFinderrPackageNotFoundError distribution distributions entry_pointsfilesmetadatapackages_distributionsrequiresversionc@s$eZdZdZddZeddZdS)rzThe package was not found.cCs d|jS)Nz"No package metadata was found for nameselfr#B/opt/alt/python310/lib64/python3.10/importlib/metadata/__init__.py__str__2 zPackageNotFoundError.__str__cCs |j\}|SN)argsr"r r#r#r$r 5szPackageNotFoundError.nameN)__name__ __module__ __qualname____doc__r%propertyr r#r#r#r$r/s rc@sDeZdZdZedZeddZ e d ddZ e dd Z dS) Sectioneda A simple entry point config parser for performance >>> 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||jdDS)Ncss.|]}|jdur|jt|jdVqdS)N)value)r _replacerparser0).0sectionr#r#r$ fs z*Sectioned.section_pairs..)filter_)readvalidclstextr#r#r$ section_pairsdszSectioned.section_pairsNccsZt|ttj|}d}|D]}|do|d}|r$|d}qt||VqdS)N[]z[])filtermapstrstrip splitlines startswithendswithr)r;r6linesr r0Z section_matchr#r#r$r7ls zSectioned.readcCs|o|d S)N#)rD)liner#r#r$r8wzSectioned.validr') r*r+r,r-textwrapdedentlstripZ_sample classmethodr< staticmethodr7r8r#r#r#r$r/;s    r/c@szeZdZUdZedZ dZede d<ddZ e dd Z e d d Z e d d ZddZddZddZddZdS) EntryPointaAn 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*)?$NrdistcCsD|j|j}t|d}td|dpdd}tt ||S)zLoad the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object. moduleNattr.) patternmatchr0r groupr?split functoolsreducegetattr)r"rVrQattrsr#r#r$loadszEntryPoint.loadcC|j|j}|dS)NrQrUrVr0rWr"rVr#r#r$rQ zEntryPoint.modulecCr^)NrRr_r`r#r#r$rRrazEntryPoint.attrcCs$|j|j}td|dpdS)Nz\w+extrasrS)rUrVr0refindallrWr`r#r#r$rbszEntryPoint.extrascCs ||_|Sr'rP)r"rPr#r#r$_forszEntryPoint._forcCsd}t|tt|j|fS)zP Supply iter so one may construct dicts of EntryPoints by name. zJConstruction of dict of EntryPoints is deprecated in favor of EntryPoints.)warningswarnDeprecationWarningiterr )r"msgr#r#r$__iter__s zEntryPoint.__iter__cCs|j|j|j|jffSr') __class__r r0rWr!r#r#r$ __reduce__szEntryPoint.__reduce__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'r[)r3Zparamr!r#r$r5z%EntryPoint.matches..)allr@operatoreqvalues)r"paramsr\r#r!r$matchesszEntryPoint.matches)r*r+r,r-rccompilerUrPr__annotations__r]r.rQrRrbrfrlrnrvr#r#r#r$rO|s$     rOZEntryPointBasezname value groupcseZdZdZdZejejde ddZ fddZ fdd Z fd d Z fd d ZfddZfddZfddZfddZddZfddZfddZddZZS)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. stacklevelc|tj|i|Sr')_warnsuper __setitem__r"r(kwargsrmr#r$rzDeprecatedList.__setitem__cr}r')r~r __delitem__rrr#r$rrzDeprecatedList.__delitem__cr}r')r~rappendrrr#r$rrzDeprecatedList.appendcr}r')r~rreverserrr#r$r rzDeprecatedList.reversecr}r')r~rextendrrr#r$r$rzDeprecatedList.extendcr}r')r~rpoprrr#r$r(rzDeprecatedList.popcr}r')r~rremoverrr#r$r,rzDeprecatedList.removecr}r')r~r__iadd__rrr#r$r0rzDeprecatedList.__iadd__cCs,t|ts |t|}|t||Sr') isinstancetupler~rmr"otherr#r#r$__add__4s zDeprecatedList.__add__cr}r')r~rinsertrrr#r$r:rzDeprecatedList.insertcr}r')r~rsortrrr#r$r>rzDeprecatedList.sortcCs(t|ts |t|}t||Sr')rrr~__eq__rr#r#r$rBs zDeprecatedList.__eq__)r*r+r,r- __slots__rYpartialrgrhrir~rrrrrrrrrrrr __classcell__r#r#rr$rys*          rycsheZdZdZdZfddZddZeddZed d Z e d d Z e d dZ e ddZZS) EntryPointszC An immutable collection of selectable EntryPoint objects. r#csTt|trtjdtddt|Sz tt|j |dWSt y)t |w)z; Get the EntryPoint in self matching name. zGAccessing entry points by index is deprecated. Cast to tuple if needed.rzr{r) rintrgrhrir __getitem__nextrjselect StopIterationKeyErrorr)rr#r$rQs   zEntryPoints.__getitem__c stfdd|DS)zv Select entry points from self that match the given parameters (typically group and/or name). c3s$|] }|jdir|VqdSNr#)rvr3Zeprur#r$r5gs"z%EntryPoints.select..rr"rur#rr$rbszEntryPoints.selectcCtdd|DS)zB Return the set of all names of all entry points. cs|]}|jVqdSr'rrr#r#r$r5nz$EntryPoints.names..setr!r#r#r$namesiszEntryPoints.namescCr)z Return the set of all groups of all entry points. For coverage while SelectableGroups is present. >>> EntryPoints().groups set() csrr')rWrr#r#r$r5yrz%EntryPoints.groups..rr!r#r#r$groupsp zEntryPoints.groupscs|fdd||DS)Nc3|]}|VqdSr')rfrrer#r$r5}rpz-EntryPoints._from_text_for..) _from_text)r:r;rPr#rer$_from_text_for{szEntryPoints._from_text_forcCstt||pdS)NrS) itertoolsrrO _parse_groupsr9r#r#r$rszEntryPoints._from_textcCsddt|DS)Ncss$|] }|jj|jj|jfVqdSr'r0r )r3itemr#r#r$r5s  z,EntryPoints._parse_groups..)r/r<)r;r#r#r$rszEntryPoints._parse_groups)r*r+r,r-rrrr.rrrMrrrNrrr#r#rr$rJs     rcsreZdZdZejejdeddZ fddZ dfdd Z fd d Z fd d Z fddZfddZZS) 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.rzr{cs|t|Sr')r~rrr)rr#r$r zDeprecated.__getitem__Ncs|t||Sr')r~rget)r"r defaultrr#r$rszDeprecated.getc|tSr')r~rrlr!rr#r$rl zDeprecated.__iter__cs|tj|Sr')r~r __contains__)r"r(rr#r$rrzDeprecated.__contains__crr')r~rkeysr!rr#r$rrzDeprecated.keyscrr')r~rrtr!rr#r$rtrzDeprecated.valuesr')r*r+r,r-rYrrgrhrir~rrrlrrrtrr#r#rr$rs    rcsPeZdZdZeddZefddZeddZedd Z d d Z Z S) SelectableGroupszs A backward- and forward-compatible result from entry_points that fully implements the dict interface. cCs4td}t||d}t||}|dd|DS)NrWkeycss |] \}}|t|fVqdSr'r)r3rWepsr#r#r$r5sz(SelectableGroups.load..)rr attrgettersortedrgroupby)r:rZby_groupZorderedZgroupedr#r#r$r]s   zSelectableGroups.loadcstt|}ttj|S)zH Reconstruct a list of all entrypoints from the groups. )rrrtrrchain from_iterable)r"rrr#r$_allszSelectableGroups._allcC|jjSr')rrr!r#r#r$rzSelectableGroups.groupscCr)zR for coverage: >>> SelectableGroups().names set() )rrr!r#r#r$rszSelectableGroups.namescKs|s|S|jjdi|Sr)rrrr#r#r$rszSelectableGroups.select) r*r+r,r-rMr]r.rrrrrr#r#rr$rs   rc@s*eZdZdZd ddZddZddZd S) PackagePathz"A reference to a path in a packageutf-8cCs<|j|d }|WdS1swYdS)Nencodinglocateopenr7)r"rstreamr#r#r$ read_texts$zPackagePath.read_textcCs:|d }|WdS1swYdS)Nrbr)r"rr#r#r$ read_binarys$zPackagePath.read_binarycCs |j|S)z'Return a path-like object for this path)rP locate_filer!r#r#r$r zPackagePath.locateN)r)r*r+r,r-rrrr#r#r#r$rs   rc@seZdZddZddZdS)FileHashcCs|d\|_}|_dS)N=) partitionmoder0)r"spec_r#r#r$__init__szFileHash.__init__cCsd|jd|jdS)Nz)rr0r!r#r#r$__repr__szFileHash.__repr__N)r*r+r,rrr#r#r#r$rs rc@seZdZdZejddZejddZeddZ edd Z e d d Z e d d Z ed-ddZedejfddZeddZeddZeddZeddZeddZddZd d!Zed"d#Zd$d%Zd&d'Zed(d)Ze d*d+Zd,S).rzA Python distribution package.cCdS)zAttempt 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$rzDistribution.read_textcCr)z[ Given a path to a file in this distribution, return a path to it. Nr#r"pathr#r#r$r rzDistribution.locate_filecCsD|D]}|tj|d}tt|d}|dur|Sqt|)afReturn 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. rN)_discover_resolversrContextrrjr)r:r resolverZdistsrPr#r#r$ from_names zDistribution.from_namec sN|ddr|rtdptjdi|tjfdd|DS)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#)r3rrr#r$r54s z(Distribution.discover..r#)r ValueErrorrrrrrr)r:rr#rr$discover&s zDistribution.discovercCstt|S)zReturn a Distribution for the indicated metadata path :param path: a string or path-like object :return: a concrete Distribution instance for the path )PathDistributionpathlibPath)rr#r#r$at8szDistribution.atcCsddtjD}td|S)z#Search the meta_path for resolvers.css|] }t|ddVqdS)find_distributionsNro)r3finderr#r#r$r5Ds  z3Distribution._discover_resolvers..N)sys meta_pathr?)Zdeclaredr#r#r$rAs z Distribution._discover_resolversrTcCs@ddlm}m}||}tj|j||d}tt| |S)Nr)buildmeta)Z source_dirsystem) Zpep517rrZ compat_systemrYrrzipfilerZ build_as_zip)r:rootrrrZbuilderr#r#r$_localIs zDistribution._localreturncCs.|dp|dp|d}tt|S)zReturn 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-INFOrS)rrZMessageemailZmessage_from_stringr"r;r#r#r$rUs zDistribution.metadatacC |jdS)z8Return the 'Name' metadata for the distribution package.Namerr!r#r#r$r f zDistribution.namecCs t|jS)z(Return a normalized version of the name.)Prepared normalizer r!r#r#r$_normalized_nameks zDistribution._normalized_namecCr)z;Return the 'Version' metadata for the distribution package.ZVersionrr!r#r#r$rprzDistribution.versioncCst|d|S)Nzentry_points.txt)rrrr!r#r#r$ruszDistribution.entry_pointscs6p}dfdd }|ott|t|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|}|r t|nd|_|rt|nd|_|_|Sr')rrhashrsizerP)r rZsize_strresultr!r#r$ make_files z%Distribution.files..make_file)NN)_read_files_distinfo_read_files_egginfolistrcsvreader)r"Z file_linesrr#r!r$rys zDistribution.filescCs|d}|o |S)z* Read the lines of RECORD ZRECORD)rrCrr#r#r$rs  z!Distribution._read_files_distinfocCs|d}|otdj|S)z` SOURCES.txt might contain literal commas, so wrap each line in quotes. z SOURCES.txtz"{}")rr@formatrCrr#r#r$rs z Distribution._read_files_egginfocCs|p|}|o t|S)z6Generated requirements specified for this Distribution)_read_dist_info_reqs_read_egg_info_reqsr)r"Zreqsr#r#r$rs zDistribution.requirescCs |jdS)Nz Requires-Dist)rZget_allr!r#r#r$r r&z!Distribution._read_dist_info_reqscCs |d}|dur dS||S)Nz requires.txt)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_reqsr/r7)r:rr#r#r$rrIz%Distribution._deps_from_requires_textc#sLddfdd}dd}|D]}||j}|j|||jVqdS)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|dS)Nz extra == ""r#rr#r#r$make_conditionszJDistribution._convert_egg_info_reqs_to_simple_reqs..make_conditioncsX|pd}|d\}}}|r|rd|d}ttd||g}|r*dd|SdS)NrS:()z; z and )rrr?join)r4ZextrasepZmarkersZ conditionsrr#r$ quoted_markers  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 zIDistribution._convert_egg_info_reqs_to_simple_reqs..url_req_spaceNr)Zsectionsrrr4Zspacer#rr$rs  z2Distribution._convert_egg_info_reqs_to_simple_reqsN)rT)r*r+r,r-abcabstractmethodrrrMrrrNrrrr.rrrr rrrrrrrr r rrr#r#r#r$rsL               rc@s2eZdZdZGdddZejefddZdS)rzJ A MetaPathFinder capable of discovering installed distributions. c@s*eZdZdZdZ ddZeddZdS)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')varsupdate)r"rr#r#r$rz#DistributionFinder.Context.__init__cCst|dtjS)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)r rrrr!r#r#r$rrzDistributionFinder.Context.path)r*r+r,r-r rr.rr#r#r#r$rs rcCr)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"rr#r#r$rrz%DistributionFinder.find_distributionsN)r*r+r,r-rrrrr#r#r#r$rs  rcsheZdZdZefddZddZddZdd Z d d Z d d Z e ddZ eddZZS)FastPathzF Micro-optimized class for searching a path for children. cs t|Sr')r__new__)r:rrr#r$r$ rzFastPath.__new__cCs ||_dSr')r)r"rr#r#r$r  zFastPath.__init__cCst|j|Sr')rrr)r"childr#r#r$joinpathzFastPath.joinpathcCslttt|jp dWdS1swYtt |WdS1s/wYgS)NrT)r Exceptionoslistdirr zip_childrenr!r#r#r$childrens   zFastPath.childrencCs2t|j}|j}|j|_tdd|DS)Ncss"|] }|tjddVqdS)rrN)rX posixpathr)r3r&r#r#r$r5s z(FastPath.zip_children..)rrrZnamelistr'dictfromkeys)r"Zzip_pathrr#r#r$r,s  zFastPath.zip_childrencCs||j|Sr')lookupmtimesearchr)r#r#r$r3!r"zFastPath.searchcCsDttt|jjWdS1swY|jdSr')r OSErrorr*statrst_mtimer1 cache_clearr!r#r#r$r2$s   zFastPath.mtimecCst|Sr')Lookup)r"r2r#r#r$r1*rzFastPath.lookup)r*r+r,r-rY lru_cacher$rr'r-r,r3r.r2rr1rr#r#rr$r#s r#c@s"eZdZdefddZddZdS)r8rc Cstj|j}|d}tt|_tt|_ | D]J}|}|drD| dd dd}t |}|j|||q|rf|dkrf| dd dd}t |}|j |||q|j|j dS)Nz.eggz .dist-infoz .egg-inforTr-zegg-info)r*rbasenamerlowerrErrinfoseggsr- rpartitionrrrrr'legacy_normalizeZfreeze) r"rbaseZ base_is_eggr&Zlowr normalizedlegacy_normalizedr#r#r$r0s"         zLookup.__init__cCsP|r|j|jntj|j}|r|j|jntj|j}t||Sr')r>rCrrrrtr?rD)r"preparedr>r?r#r#r$r3Es z Lookup.searchN)r*r+r,r#rr3r#r#r#r$r8/s r8c@s@eZdZdZdZdZddZeddZeddZ d d Z dS) rzE A prepared search for metadata on a possibly-named package. NcCs.||_|dur dS|||_|||_dSr')r rrCrArDr)r#r#r$r[s  zPrepared.__init__cCstdd|ddS)zC PEP 503 normalization plus dashes as underscores. z[-_.]+r;r)rcsubr=replacerr#r#r$rbszPrepared.normalizecCs|ddS)z| Normalize the package name as found in the convention in older packaging tools versions and specs. r;r)r=rGrr#r#r$rAiszPrepared.legacy_normalizecCs t|jSr')boolr r!r#r#r$__bool__qr%zPrepared.__bool__) r*r+r,r-rCrDrrNrrArIr#r#r#r$rSs   rc@s4eZdZeefddZeddZddZdS)MetadataPathFindercCs||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 rr@r)r:rfoundr#r#r$rvs z%MetadataPathFinder.find_distributionscs(t|tjfddtt|DS)z1Find metadata directories in paths heuristically.c3rr')r3)r3rrEr#r$r5s  z3MetadataPathFinder._search_paths..)rrrrr@r#)r:r pathsr#rMr$rKsz MetadataPathFinder._search_pathscCstjdSr')r#r$r7)r:r#r#r$invalidate_cachesr(z$MetadataPathFinder.invalidate_cachesN) r*r+r,rMrrrrKrOr#r#r#r$rJus   rJcsTeZdZdefddZddZejje_ddZe fdd Z e d d Z Z S) rrcCs ||_dS)zfConstruct a distribution. :param path: SimplePath indicating the metadata directory. N)_pathrr#r#r$rs zPathDistribution.__init__cCsHtttttt|j|jddWdS1swYdS)Nrr) r FileNotFoundErrorIsADirectoryErrorrNotADirectoryErrorPermissionErrorrPr'rrr#r#r$rs$zPathDistribution.read_textcCs |jj|Sr')rPparentrr#r#r$rr&zPathDistribution.locate_filecs.tjt|j}ttj||pt j S)zz Performance optimization: where possible, resolve the normalized name from the file system path. ) r*rr<rArPr rr_name_from_stemrr)r"stemrr#r$rsz!PathDistribution._normalized_namecCs0tj|\}}|dvrdS|d\}}}|S)z >>> 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' r:Nr;)r*rsplitextr)rWrZextr rrestr#r#r$rVs  z PathDistribution._name_from_stem)r*r+r,r rrrr-rr.rrNrVrr#r#rr$rs  rcCs t|S)zGet 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). )rrZdistribution_namer#r#r$r rcKstjdi|S)z|Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances. Nr#)rr)rr#r#r$rsrrcCs t|jS)zGet the metadata for the named package. :param distribution_name: The name of the distribution package to query. :return: A PackageMetadata containing the parsed metadata. )rrrrZr#r#r$rrrcC t|jS)zGet 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. )rrrZr#r#r$r rcKsJtd}tjt|d}tjdd|tD}t |j di|S)aReturn 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. rrcsrr')r)r3rPr#r#r$r5s zentry_points..Nr#) rrrrYrr rrrrrr]r)ruZ norm_nameuniquerr#r#r$rs  rcCr\)zReturn 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. )rrrZr#r#r$rr[rcCr\)z Return a list of requirements for the named package. :return: An iterator of requirements, suitable for packaging.requirement.Requirement. )rrrZr#r#r$r r]rcCsJtt}tD]}|dpdD] }|||jdqqt|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 z top_level.txtrSr) collections defaultdictrrrrXrrr/)Z pkg_to_distrPZpkgr#r#r$rs r)Gr*rcrr rrrrrrrJrgrYrr.r_rSrrr _collectionsrr _functoolsrr _itertoolsr r contextlibr importlibr Z importlib.abcrrtypingrrrr__all__ModuleNotFoundErrorrr/ namedtuplerOrryrrr/rZ PurePosixPathrrrrr#r8rrJrrrrrrrrrArr#r#r#r$sl       A o_A7(R0,$"4