B &`r @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZmZddlmZmZddlmZmZmZddlmZddlmZddlmZmZdd lm Z dd l!m"Z"dd l#m$Z$dd l m%Z%dd l&m'Z'm(Z(m)Z)m*Z*ddddddddddddg Z+Gddde,Z-GdddZ.Gdddee/dd Z0Gd!d"d"e1Z2Gd#d$d$e2Z3Gd%d&d&Z4Gd'd(d(e4e5Z6Gd)d*d*ej7Z8Gd+d,d,Z9Gd-ddZ:Gd.dde$Z;Gd/d0d0ZeGd5d6d6ee;Z?Gd7d8d8e:Z@d9dZAd:dZBejd;ddZEd?dZFd@dZGe(eHe'eHfd;dAdZIdS)BN) _adapters_meta)FreezableDefaultDictPair) NullFinder PyPy_reprinstall) method_cache)unique_everseen)PackageMetadata SimplePath)suppress) import_module)MetaPathFinder)starmap)ListMappingOptionalUnion DistributionDistributionFinderr PackageNotFoundError distribution distributions entry_pointsfilesmetadatapackages_distributionsrequiresversionc@s$eZdZdZddZeddZdS)rzThe package was not found.cCs d|jS)Nz"No package metadata was found for )name)selfr#L/opt/alt/python37/lib/python3.7/site-packages/importlib_metadata/__init__.py__str__6szPackageNotFoundError.__str__cCs |j\}|S)N)args)r"r!r#r#r$r!9szPackageNotFoundError.nameN)__name__ __module__ __qualname____doc__r%propertyr!r#r#r#r$r3sc@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,|]$}|jdk r|jt|jdVqdS)N)value)r!_replacerparser-).0sectionr#r#r$ ksz*Sectioned.section_pairs..)filter_)readvalid)clstextr#r#r$ section_pairshszSectioned.section_pairsNccs\t|ttj|}d}x<|D]4}|do6|d}|rH|d}q t||Vq WdS)N[]z[])filtermapstrstrip splitlines startswithendswithr)r7r3linesr!r- section_matchr#r#r$r4ps  zSectioned.readcCs|o|d S)N#)r@)liner#r#r$r5{szSectioned.valid)N) r'r(r)r*textwrapdedentlstrip_sample classmethodr8 staticmethodr4r5r#r#r#r$r,?s   r,c@sxeZdZUdZedZdZede d<ddZ e dd Z e d d Z e d d ZddZddZddZddZdS) EntryPointzAn entry point as defined by Python packaging conventions. See `the packaging docs on entry points `_ for more information. zF(?P[\w.]+)\s*(:\s*(?P[\w.]+))?\s*(?P\[.*\])?\s*$NrdistcCsD|j|j}t|d}td|dp,dd}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.) patternmatchr-rgroupr;split functoolsreducegetattr)r"rSrNattrsr#r#r$loadszEntryPoint.loadcCs|j|j}|dS)NrN)rRrSr-rT)r"rSr#r#r$rNszEntryPoint.modulecCs|j|j}|dS)NrO)rRrSr-rT)r"rSr#r#r$rOszEntryPoint.attrcCs(|j|j}ttd|dp"dS)Nz\w+extrasrP)rRrSr-listrefinditerrT)r"rSr#r#r$r[szEntryPoint.extrascCs ||_|S)N)rM)r"rMr#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|jffS)N) __class__r!r-rT)r"r#r#r$ __reduce__szEntryPoint.__reduce__c s(fdd|D}tttj||S)Nc3s|]}t|VqdS)N)rX)r0param)r"r#r$r2sz%EntryPoint.matches..)allr<operatoreqvalues)r"paramsrYr#)r"r$matchesszEntryPoint.matches)r'r(r)r*r]compilerRrMr__annotations__rZr+rNrOr[r_rergrnr#r#r#r$rLs     rLZEntryPointBasezname value groupcseZdZdZejejdeddZ fddZ fddZ fd d Z fd d Z fd dZfddZfddZfddZddZfddZfddZddZZS)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 zAEntryPoints list interface is deprecated. Cast to list if needed.) stacklevelcs|tj||S)N)_warnsuper __setitem__)r"r&kwargs)rfr#r$rvszDeprecatedList.__setitem__cs|tj||S)N)rtru __delitem__)r"r&rw)rfr#r$rxszDeprecatedList.__delitem__cs|tj||S)N)rtruappend)r"r&rw)rfr#r$ryszDeprecatedList.appendcs|tj||S)N)rtrureverse)r"r&rw)rfr#r$rzszDeprecatedList.reversecs|tj||S)N)rtruextend)r"r&rw)rfr#r$r{ szDeprecatedList.extendcs|tj||S)N)rtrupop)r"r&rw)rfr#r$r|szDeprecatedList.popcs|tj||S)N)rtruremove)r"r&rw)rfr#r$r}szDeprecatedList.removecs|tj||S)N)rtru__iadd__)r"r&rw)rfr#r$r~szDeprecatedList.__iadd__cCs,t|ts|t|}|t||S)N) isinstancetuplertrf)r"otherr#r#r$__add__s zDeprecatedList.__add__cs|tj||S)N)rtruinsert)r"r&rw)rfr#r$r!szDeprecatedList.insertcs|tj||S)N)rtrusort)r"r&rw)rfr#r$r%szDeprecatedList.sortcCs(t|ts|t|}t||S)N)rrrt__eq__)r"rr#r#r$r)s zDeprecatedList.__eq__)r'r(r)r*rVpartialr`rarbrtrvrxryrzr{r|r}r~rrrr __classcell__r#r#)rfr$rqs$          rqcsheZdZdZdZfddZddZeddZed d Z e d d Z e d dZ e ddZZS) EntryPointszC An immutable collection of selectable EntryPoint objects. r#cs\t|tr&tjdtddt|Sytt|j |dSt k rVt |YnXdS)z; Get the EntryPoint in self matching name. zGAccessing entry points by index is deprecated. Cast to tuple if needed.rr)rs)r!N) rintr`rarbru __getitem__nextrcselect StopIterationKeyError)r"r!)rfr#r$r8s  zEntryPoints.__getitem__c stfdd|DS)zv Select entry points from self that match the given parameters (typically group and/or name). c3s|]}|jfr|VqdS)N)rn)r0ep)rmr#r$r2Nsz%EntryPoints.select..)r)r"rmr#)rmr$rIszEntryPoints.selectcCstdd|DS)zB Return the set of all names of all entry points. css|] }|jVqdS)N)r!)r0rr#r#r$r2Usz$EntryPoints.names..)set)r"r#r#r$namesPszEntryPoints.namescCstdd|DS)z Return the set of all groups of all entry points. For coverage while SelectableGroups is present. >>> EntryPoints().groups set() css|] }|jVqdS)N)rT)r0rr#r#r$r2`sz%EntryPoints.groups..)r)r"r#r#r$groupsWs zEntryPoints.groupscs|fdd||DS)Nc3s|]}|VqdS)N)r_)r0r)rMr#r$r2dsz-EntryPoints._from_text_for..) _from_text)r6r7rMr#)rMr$_from_text_forbszEntryPoints._from_text_forcCstt||pdS)NrP) itertoolsrrL _parse_groups)r6r7r#r#r$rfszEntryPoints._from_textcCsddt|DS)Ncss"|]}|jj|jj|jfVqdS)N)r-r!)r0itemr#r#r$r2msz,EntryPoints._parse_groups..)r,r8)r7r#r#r$rjszEntryPoints._parse_groups)r'r(r)r* __slots__rrr+rrrJrrrKrrr#r#)rfr$r1s    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.rr)rscs|t|S)N)rtrur)r"r!)rfr#r$rszDeprecated.__getitem__Ncs|t||S)N)rtruget)r"r!default)rfr#r$rszDeprecated.getcs|tS)N)rtrure)r")rfr#r$reszDeprecated.__iter__cs|tj|S)N)rtru __contains__)r"r&)rfr#r$rszDeprecated.__contains__cs|tS)N)rtrukeys)r")rfr#r$rszDeprecated.keyscs|tS)N)rtrurl)r")rfr#r$rlszDeprecated.values)N)r'r(r)r*rVrr`rarbrtrrrerrrlrr#r#)rfr$rrs    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)NrT)keycss|]\}}|t|fVqdS)N)r)r0rTepsr#r#r$r2sz(SelectableGroups.load..)rj attrgettersortedrgroupby)r6rby_groupZorderedZgroupedr#r#r$rZs   zSelectableGroups.loadcstt|}ttj|S)zH Reconstruct a list of all entrypoints from the groups. )rurrlrrchain from_iterable)r"r)rfr#r$_allszSelectableGroups._allcCs|jjS)N)rr)r"r#r#r$rszSelectableGroups.groupscCs|jjS)zR for coverage: >>> SelectableGroups().names set() )rr)r"r#r#r$rszSelectableGroups.namescKs|s|S|jjf|S)N)rr)r"rmr#r#r$rszSelectableGroups.select) r'r(r)r*rJrZr+rrrrrr#r#)rfr$rs    rc@s*eZdZdZd ddZddZddZd S) PackagePathz"A reference to a path in a packageutf-8c Cs$|j|d }|SQRXdS)N)encoding)locateopenr4)r"rstreamr#r#r$ read_textszPackagePath.read_textc Cs"|d }|SQRXdS)Nrb)rrr4)r"rr#r#r$ read_binaryszPackagePath.read_binarycCs |j|S)z'Return a path-like object for this path)rM locate_file)r"r#r#r$rszPackagePath.locateN)r)r'r(r)r*rrrr#r#r#r$rs rc@seZdZddZddZdS)FileHashcCs|d\|_}|_dS)N=) partitionmoder-)r"spec_r#r#r$__init__szFileHash.__init__cCsd|jd|jdS)Nz)rr-)r"r#r#r$__repr__szFileHash.__repr__N)r'r(r)rrr#r#r#r$rsrc@seZdZdZejddZejddZeddZ edd Z e d d Z e d d Z ed-ddZeejdddZeddZeddZeddZeddZeddZddZd d!Zed"d#Zd$d%Zd&d'Zed(d)Ze d*d+Zd,S).rzA Python distribution package.cCsdS)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$rszDistribution.read_textcCsdS)z[ Given a path to a file in this distribution, return a path to it. Nr#)r"pathr#r#r$rszDistribution.locate_filecCsHxB|D].}|tj|d}tt|d}|dk r |Sq Wt|dS)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. )r!N)_discover_resolversrContextrrcr)r6r!resolverZdistsrMr#r#r$ from_names zDistribution.from_namec sJ|ddr|rtdp*tjf|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|]}|VqdS)Nr#)r0r)rr#r$r2sz(Distribution.discover..)r| ValueErrorrrrrrr)r6rwr#)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$atszDistribution.atcCsddtjD}td|S)z#Search the meta_path for resolvers.css|]}t|ddVqdS)find_distributionsN)rX)r0finderr#r#r$r2,sz3Distribution._discover_resolvers..N)sys meta_pathr;)declaredr#r#r$r(sz Distribution._discover_resolversrQcCs@ddlm}m}||}tj|j||d}tt| |S)Nr)buildmeta)Z source_dirsystem) Zpep517rrZ compat_systemrVrrzipprZ build_as_zip)r6rootrrrZbuilderr#r#r$_local0s zDistribution._local)returncCs.|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. METADATAzPKG-INFOrP)rrMessageemailmessage_from_string)r"r7r#r#r$r<s   zDistribution.metadatacCs |jdS)z8Return the 'Name' metadata for the distribution package.Name)r)r"r#r#r$r!MszDistribution.namecCs t|jS)z(Return a normalized version of the name.)Prepared normalizer!)r"r#r#r$_normalized_nameRszDistribution._normalized_namecCs |jdS)z;Return the 'Version' metadata for the distribution package.Version)r)r"r#r#r$r WszDistribution.versioncCst|d|S)Nzentry_points.txt)rrr)r"r#r#r$r\szDistribution.entry_pointscs6p}dfdd }|o4tt|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|}|rt|nd|_|r&t|nd|_|_|S)N)rrhashrsizerM)r!rsize_strresult)r"r#r$ make_filems z%Distribution.files..make_file)NN)_read_files_distinfo_read_files_egginfor\rcsvreader)r"Z file_linesrr#)r"r$r`s zDistribution.filescCs|d}|o|S)z* Read the lines of RECORD RECORD)rr?)r"r7r#r#r$rvs 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<formatr?)r"r7r#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"reqsr#r#r$rszDistribution.requirescCs |jdS)Nz Requires-Dist)rget_all)r"r#r#r$rsz!Distribution._read_dist_info_reqscCs|d}|o||S)Nz requires.txt)r_deps_from_requires_text)r"sourcer#r#r$rs z Distribution._read_egg_info_reqscCs|t|S)N)%_convert_egg_info_reqs_to_simple_reqsr,r4)r6rr#r#r$rsz%Distribution._deps_from_requires_textc#s8ddfdd}x|D]}|j||jVqWdS)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#)r!r#r#r$make_conditionszJDistribution._convert_egg_info_reqs_to_simple_reqs..make_conditioncsX|pd}|d\}}}|r,|r,d|d}ttd||g}|rTdd|SdS)NrP:()z; z and )rr\r;join)r1extrasepmarkers conditions)rr#r$parse_conditions  zKDistribution._convert_egg_info_reqs_to_simple_reqs..parse_conditionN)r-r!)sectionsrr1r#)rr$rs   z2Distribution._convert_egg_info_reqs_to_simple_reqsN)rQ)r'r(r)r*abcabstractmethodrrrJrrrKrrrr+rr rr!rr rrrrrrrrrr#r#r#r$rs.           c@s2eZdZdZGdddZejefddZdS)rzJ A MetaPathFinder capable of discovering installed distributions. c@s(eZdZdZdZddZeddZdS)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||dS)N)varsupdate)r"rwr#r#r$rsz#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)rrrr)r"r#r#r$rs zDistributionFinder.Context.path)r'r(r)r*r!rr+rr#r#r#r$rs rcCsdS)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$rsz%DistributionFinder.find_distributionsN)r'r(r)r*rrrrr#r#r#r$rs csheZdZdZefddZddZddZdd Z d d Z d d Z e ddZ eddZZS)FastPathzF Micro-optimized class for searching a path for children. cs t|S)N)ru__new__)r6r)rfr#r$rszFastPath.__new__cCst||_dS)N)r=r)r"rr#r#r$rszFastPath.__init__cCst|j|S)N)rrr)r"childr#r#r$joinpathszFastPath.joinpathc Cs<ttt|jpdSQRXtt |SQRXgS)NrP)r Exceptionoslistdirr zip_children)r"r#r#r$childrens   zFastPath.childrencCs2t|j}|j}|j|_tdd|DS)Ncss |]}|tjddVqdS)rrN)rU posixpathr)r0rr#r#r$r2sz(FastPath.zip_children..)rrrnamelistrdictfromkeys)r"zip_pathrr#r#r$rs  zFastPath.zip_childrencCs||j|S)N)lookupmtimesearch)r"r!r#r#r$rszFastPath.searchc Cs,ttt|jjSQRX|jdS)N)rOSErrorrstatrst_mtimer  cache_clear)r"r#r#r$rs zFastPath.mtimecCst|S)N)Lookup)r"rr#r#r$r szFastPath.lookup)r'r(r)r*rV lru_cacherrrrrrr+rr r rr#r#)rfr$rs rc@s"eZdZedddZddZdS)r)rc Cstj|j}|d}tt|_tt|_ x| D]}|}|dr| dd dd}t |}|j|||q:|r:|dkr:| dd dd}t |}|j |||q:W|j|j dS)Nz.egg)z .dist-infoz .egg-inforQr-zegg-info)rrbasenamerlowerrArr\infoseggsr rpartitionrrrryrlegacy_normalizefreeze) r"rbase base_is_eggrlowr! normalizedlegacy_normalizedr#r#r$rs         zLookup.__init__cCsP|r|j|jntj|j}|r2|j|jntj|j}t||S)N)rr!rrrrlrr")r"preparedrrr#r#r$r#s z Lookup.searchN)r'r(r)rrrr#r#r#r$r src@s@eZdZdZdZdZddZeddZeddZ d d Z dS) rzE A prepared search for metadata on a possibly-named package. NcCs.||_|dkrdS|||_|||_dS)N)r!rr!rr")r"r!r#r#r$r9s  zPrepared.__init__cCstdd|ddS)zC PEP 503 normalization plus dashes as underscores. z[-_.]+rr)r]subrreplace)r!r#r#r$r@szPrepared.normalizecCs|ddS)z| Normalize the package name as found in the convention in older packaging tools versions and specs. rr)rr%)r!r#r#r$rGszPrepared.legacy_normalizecCs t|jS)N)boolr!)r"r#r#r$__bool__OszPrepared.__bool__) r'r(r)r*r!r"rrKrrr'r#r#r#r$r1s  rc@s4eZdZdZefddZeddZddZ dS) MetadataPathFinderzA 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!rr<r)r"rfoundr#r#r$r[s z%MetadataPathFinder.find_distributionscs(t|tjfddtt|DS)z1Find metadata directories in paths heuristically.c3s|]}|VqdS)N)r)r0r)r#r#r$r2lsz3MetadataPathFinder._search_paths..)rrrrr<r)r6r!pathsr#)r#r$r)gsz MetadataPathFinder._search_pathscCstjdS)N)rrr)r6r#r#r$invalidate_cachesosz$MetadataPathFinder.invalidate_cachesN) r'r(r)r*rrrrJr)r,r#r#r#r$r(Ss r(csPeZdZedddZddZejje_ddZe fdd Z d d Z Z S) r)rcCs ||_dS)zfConstruct a distribution. :param path: SimplePath indicating the metadata directory. N)_path)r"rr#r#r$rtszPathDistribution.__init__c Cs0tttttt|j|jddSQRXdS)Nzutf-8)r) rFileNotFoundErrorIsADirectoryErrorrNotADirectoryErrorPermissionErrorr-rr)r"rr#r#r$r{szPathDistribution.read_textcCs |jj|S)N)r-parent)r"rr#r#r$rszPathDistribution.locate_filecs$tjt|j}||p"tjS)zz Performance optimization: where possible, resolve the normalized name from the file system path. )rrrr=r-_name_from_stemrur)r"stem)rfr#r$rsz!PathDistribution._normalized_namecCs0tj|\}}|dkrdS|d\}}}|S)N)z .dist-infoz .egg-infor)rrsplitextr)r"r4r!extrrestr#r#r$r3s z PathDistribution._name_from_stem) r'r(r)r rrrr*rr+rr3rr#r#)rfr$rss   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). )rr)distribution_namer#r#r$rscKs tjf|S)z|Get all ``Distribution`` instances in the current environment. :return: An iterable of ``Distribution`` instances. )rr)rwr#r#r$rs)rcCs 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. )rrr)r8r#r#r$rscCs 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. )rr )r8r#r#r$r scKsFtd}tjt|d}tjdd|tD}t |j f|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. r)rcss|] }|jVqdS)N)r)r0rMr#r#r$r2szentry_points..) rjrrVrr rrrrrrZr)rmZ norm_nameuniquerr#r#r$rs  cCs t|jS)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. )rr)r8r#r#r$rscCs t|jS)z Return a list of requirements for the named package. :return: An iterator of requirements, suitable for packaging.requirement.Requirement. )rr)r8r#r#r$rscCsRtt}x>tD]4}x.|dp$dD]}|||jdq*WqWt|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.txtrPr) collections defaultdictr\rrrUryrr ) pkg_to_distrMpkgr#r#r$rs  )Jrr]rrrrrrrjrFr`rVrrr:rPrr _collectionsrr_compatrrr _functoolsr _itertoolsr r r contextlibr importlibr importlib.abcrrtypingrrrr__all__ModuleNotFoundErrorrr, namedtuplerLr\rqrrr r PurePosixPathrrrrrrrr(rrrrr rrrr=rr#r#r#r$s       A S]A7(I0,$"  (