ResdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z mZddlmZddlmZmZddlmZmZmZmZdd lmZmZmZmZmZmZm Z gd Z!ej"e#Z$d Z%d Z&d eddde%dfZ'dZ(Gdde)Z*Gdde)Z+Gdde)Z,Gdde,Z-Gdde-Z.Gdde-Z/e.Z0e/Z1Gdd e)Z2d&d"Z3d#Z4d$Z5d%Z6dS)'zPEP 376 implementation.)unicode_literalsN)DistlibException resources)StringIO) get_schemeUnsupportedVersionError)MetadataMETADATA_FILENAMEWHEEL_METADATA_FILENAMELEGACY_METADATA_FILENAME)parse_requirementcached_propertyparse_name_and_version read_exports write_exports CSVReader CSVWriter) DistributionBaseInstalledDistributionInstalledDistributionEggInfoDistributionDistributionPathzpydist-exports.jsonzpydist-commands.json INSTALLERRECORD REQUESTED RESOURCESSHAREDz .dist-infoc$eZdZdZdZdZdZdS)_CachezL A simple cache mapping names and .dist-info paths to distributions c0i|_i|_d|_dS)zZ Initialise an instance. There is normally one for each DistributionPath. FN)namepath generatedselfs /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/distlib/database.py__init__z_Cache.__init__1s  cx|j|jd|_dS)zC Clear the cache, setting it to its initial state. FN)r"clearr#r$r%s r'r+z _Cache.clear9s3  r)c|j|jvrD||j|j<|j|jg|dSdS)z` Add a distribution to the cache. :param dist: The distribution to add. N)r#r" setdefaultkeyappendr&dists r'addz _Cache.addAsW 9DI % %#'DIdi I 2 . . 5 5d ; ; ; ; ; & %r)N)__name__ __module__ __qualname____doc__r(r+r2r)r'r r -sK<<<<r+r?r%s r' clear_cachezDistributionPath.clear_cacheks2  r)c#Kt}|jD]}tj|}||d}|r|js9t |j}|D]}||}|r |j|vr$|jr|trtttg}|D]0}tj||} || } | rn1tj| 5} t%| d} dddn #1swxYwYt&d|j||jt-|j| |V2|jrf|drQt&d|j||jt1|j|VdS)zD Yield .dist-info and/or .egg(-info) distributions. NlegacyfileobjschemezFound %s)metadataenv) .egg-info.egg)setr#rfinder_for_pathfind is_containersortedr<endswith DISTINFO_EXTr r r posixpathjoin contextlibclosing as_streamr loggerdebugr2new_dist_classr=old_dist_class) r&seenr#finderrrsetentrypossible_filenamesmetadata_filename metadata_pathpydiststreamrRs r'_yield_distributionsz%DistributionPath._yield_distributionsssuuI" 7" 7D.t44F~ BA AN !+&&D 7 7KK&&AFdNN%7%..*F*F7*;*A*B*D&.@!!)(1u>O(P(P !']!;!;!"!E"!#+F,<,<,>,>??M6#+F8#L#L#LMMMMMMMMMMMMMMMLLQV444HHQV$$$((-13333333&75>>;B,C,C7LLQV444HHQV$$$(666665 7" 7" 7sD99D= D= cR|jj }|jo |jj }|s|r|D]L}t |t r|j|2|j|M|r d|j_|rd|j_dSdSdS)zk Scan the path for distributions and populate the cache with those that are found. TN)r>r$r=r?rp isinstancerr2)r&gen_distgen_eggr1s r'_generate_cachez DistributionPath._generate_caches {,,#EDO,E(E  1w 11133 . .d$9::.KOOD))))O''---- -(, % 1,0))) 1 1 1 1r)cl|dd}d||gtzS)ao The *name* and *version* parameters are converted into their filename-escaped form, i.e. any ``'-'`` characters are replaced with ``'_'`` other than the one in ``'dist-info'`` and the one separating the name from the version number. :parameter name: is converted to a standard distribution name by replacing any runs of non- alphanumeric characters with a single ``'-'``. :type name: string :parameter version: is converted to a standard version string. Spaces become dots, and all other non-alphanumeric characters (except dots) become dashes, with runs of multiple dashes condensed to a single dash. :type version: string :returns: directory name :rtype: string-_)replacer^r\)clsr"versions r'distinfo_dirnamez!DistributionPath.distinfo_dirnames2&||C%%xxw((<77r)c# K|js|D]}|VdS||jjD]}|V|jr%|jjD]}|VdSdS)a5 Provides an iterator that looks for distributions and returns :class:`InstalledDistribution` or :class:`EggInfoDistribution` instances for each one of them. :rtype: iterator of :class:`InstalledDistribution` and :class:`EggInfoDistribution` instances N)r@rprur>r#valuesr=r?r0s r'get_distributionsz"DistributionPath.get_distributionss" 1133       " " " (//11      O07799DJJJJ  r)c^d}|}|js'|D]}|j|kr|}nnh|||jjvr|jj|d}n-|jr&||jjvr|jj|d}|S)a= Looks for a named distribution on the path. This function only returns the first result found, as no more than one value is expected. If nothing is found, ``None`` is returned. :rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution` or ``None`` Nr) lowerr@rpr.rur>r"r=r?)r&r"resultr1s r'get_distributionz!DistributionPath.get_distributionszz||" 71133  8t##!FE$  " " "t{''')$/2" 7tt/C'C'C-d3A6 r)c#Kd}|E |j|d|d}n##t$rtd|d|wxYw|D]|}t |dst d|.|j}|D]D}t|\}}| ||kr|Vn##||kr| |r|VnE}dS)a Iterates over all distributions to find which distributions provide *name*. If a *version* is provided, it will be used to filter the results. This function only returns the first result found, since no more than one values are expected. If the directory is not found, returns ``None``. :parameter version: a version specifier that indicates the version required, conforming to the format in ``PEP-345`` :type name: string :type version: string N ()zinvalid name or version: , provideszNo "provides": %s) rAmatcher ValueErrorrrhasattrrbrcrrmatch) r&r"r{rr1providedpp_namep_vers r'provides_distributionz&DistributionPath.provides_distributionsB   7,..DDD'''/JKK 7 7 7&&'+ttWW(6777 7**,, " "D4,, " 0$7777=! " "A$:1$=$=MFE!T>>"&JJJ!E*"T>>gmmE.B.B>"&JJJ!E# " "s ) A c~||}|td|z||S)z5 Return the path to a resource file. Nzno distribution named %r found)r LookupErrorget_resource_path)r&r" relative_pathr1s r' get_file_pathzDistributionPath.get_file_path!sD$$T** <>EFF F%%m444r)c#K|D]A}|j}||vr4||}|||vr ||V&|D]}|VBdS)z Return all of the exported entries in a particular category. :param category: The category to search for entries. :param name: If specified, only entries with that name are returned. N)rexportsr~)r&categoryr"r1rhdvs r'get_exported_entriesz%DistributionPath.get_exported_entries*s**,, D A1}}hK#qyyg XXZZ   r))NFrD)r3r4r5r6r(rFrIproperty cache_enabledrKrpru classmethodr|rrrrrr7r)r'rrKs----(###$$$H/1CDDM   *7*7*7X111&88[8*,4'"'"'"'"R555      r)rceZdZdZdZ dZ dZedZeZ edZ edZ dZ edZ ed Zed Zed Zed Zd ZdZdZdZdS)rz A base class for distributions, whether installed or from indexes. Either way, it must have some metadata, so that's all that's needed for construction. Fc||_|j|_|j|_|j|_d|_d|_d|_d|_t|_ i|_ dS)z Initialise an instance. :param metadata: The instance of :class:`Metadata` describing this distribution. N) rRr"rr.r{locatordigestextrascontextrV download_urlsdigests)r&rRs r'r(zDistribution.__init__Osd ! M 9??$$'      UU r)c|jjS)zH The source archive download URL for this distribution. )rR source_urlr%s r'rzDistribution.source_url`s }''r)c&|jd|jdS)zX A utility property which displays the name and version in parentheses. rrr"r{r%s r'name_and_versionzDistribution.name_and_versionis !IIIt|||44r)ct|jj}|jd|jd}||vr|||S)z A set of distribution names and versions provided by this distribution. :return: A set of "name (version)" strings. rr)rRrr"r{r/)r&plistss r'rzDistribution.providespsA  &DLLL 1 E>> LLOOO r)c|j}td|t ||}t |||j|jS)Nz%Getting requirements from metadata %r)rrS) rRrbrctodictgetattrrVget_requirementsrr)r&req_attrmdreqtss r'_get_requirementszDistribution._get_requirements|si ] DnnT**GGG  +{  A2155MFE~~  u--*     s$AABB C"" C/.C/cV|jr d|jz}nd}d|jd|jd|dS)zC Return a textual representation of this instance, z [%s]rMz)rr"r{)r&suffixs r'__repr__zDistribution.__repr__s? ? t.FFF-1YYY fffMMr)ct|t|urd}n0|j|jko|j|jko|j|jk}|S)a< See if this distribution is the same as another. :param other: The distribution to compare with. To be equal to one another. distributions must have the same type, name, version and source_url. :return: True if it is the same, else False. F)typer"r{r)r&otherrs r'__eq__zDistribution.__eq__s] ;;d4jj ( (FFi5:-:lem3:o)99  r)c~t|jt|jzt|jzS)zH Compute hash in a way which matches the equality test. )hashr"r{rr%s r'__hash__zDistribution.__hash__s0DIdl!3!33d4?6K6KKKr)N)r3r4r5r6build_time_dependency requestedr(rr download_urlrrrrrrrrrrrrr7r)r'rr=sw " I5"((X( L 55X5   X :::66X677X788X877X766X6   DNNN LLLLLr)rc0eZdZdZdZdfd ZddZxZS)rz] This is the base class for installed distributions (whether PEP 376 or legacy). Ncttt||||_||_dS)a Initialise an instance. :param metadata: An instance of :class:`Metadata` which describes the distribution. This will normally have been initialised from a metadata file in the ``path``. :param path: The path of the ``.dist-info`` or ``.egg-info`` directory for the distribution. :param env: This is normally the :class:`DistributionPath` instance where this distribution was found. N)superrr(r# dist_path)r&rRr#rS __class__s r'r(z"BaseInstalledDistribution.__init__s6 '..77AAA r)c.||j}|tj}d}ntt|}d|jz}||}t j|dd}||S)a Get the hash of some data, using a particular hash algorithm, if specified. :param data: The data to be hashed. :type data: bytes :param hasher: The name of a hash implementation, supported by hashlib, or ``None``. Examples of valid values are ``'sha1'``, ``'sha224'``, ``'sha384'``, '``sha256'``, ``'md5'`` and ``'sha512'``. If no hasher is specified, the ``hasher`` attribute of the :class:`InstalledDistribution` instance is used. If the hasher is determined to be ``None``, MD5 is used as the hashing algorithm. :returns: The hash of the data. If a hasher was explicitly specified, the returned hash will be prefixed with the specified hasher followed by '='. :rtype: str NrMz%s==ascii) hasherhashlibmd5rrbase64urlsafe_b64encoderstripdecode)r&datarprefixrs r'get_hashz"BaseInstalledDistribution.get_hashs& >[F >[FFFWf--FT[(F$$&&)&1188>>EEgNN((r)rD)r3r4r5r6rr(r __classcell__rs@r'rrsb F      ))))))))r)rceZdZdZdZdfd ZdZdZdZe dZ d Z d Z d Z d ZddZdZe dZddZdZdZdZdZejZxZS)ra  Created with the *path* of the ``.dist-info`` directory provided to the constructor. It reads the metadata contained in ``pydist.json`` when it is instantiated., or uses a passed in Metadata instance (useful for when dry-run mode is being used). sha256Ncxg|_tj|x|_}|t d|z|r-|jr&||jjvr|jj|j}n|| t}|| t}|| t}|t dtd|tj|5}t!|d}dddn #1swxYwYt#t$|||||r!|jr|j|| d}|du|_t,j|d}t,j|rjt3|d5}|d } dddn #1swxYwY| |_dSdS) Nzfinder unavailable for %szno z found in rNrOr top_level.txtrbutf-8)modulesrrWrgrr@r>r#rRrXr r r r_r`rar rrr(r2rosr^existsopenreadr splitlines) r&r#rRrSrgrhrorfrrs r'r(zInstalledDistribution.__init__s (8>>> f >84?@@ @  E3% E$#*/*A*Azt,5HH   -..AyKK 788yKK 899y j8I8I8I8<">???#AKKMM22 Ef#F8DDD E E E E E E E E E E E E E E E #T**33HdCHHH  !3% ! JNN4 KK $ $$ W\\$ 0 0 7>>!   -a 0!vvxxw// 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0??,,DLLL - -s$=DD"D (HHHc8d|jd|jd|jdS)Nzz6InstalledDistribution._get_records..Ss@@@t@@@r)N)get_distinfo_resourcer_r`rarrangelenr/) r&resultsrhro record_readerrowmissingr#checksumsizes r' _get_recordsz"InstalledDistribution._get_recordsDsX  & &x 0 0   . . ;&&))) ;]);;C@@U3s88Q-?-?@@@G+.=(D(DNND(D#9:::: ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s6CAB* C*B. .C1B. 2CCCcji}|t}|r|}|S)a Return the information exported by this distribution. :return: A dictionary of exports, mapping an export category to a dict of :class:`ExportEntry` instances describing the individual export entries, and keyed by name. )r EXPORTS_FILENAMEr)r&rrhs r'rzInstalledDistribution.exports[s;  & &'7 8 8  )&&((F r)ci}|t}|rMtj|5}t |}dddn #1swxYwY|S)z Read exports data from a file in .ini format. :return: A dictionary of exports, mapping an export category to a list of :class:`ExportEntry` instances describing the individual export entries. N)r rr_r`rar)r&rrhros r'rz"InstalledDistribution.read_exportsis  & &'7 8 8  .#AKKMM22 .f%f-- . . . . . . . . . . . . . . . sA!!A%(A%c|t}t|d5}t||ddddS#1swxYwYdS)a Write a dictionary of exports to a file in .ini format. :param exports: A dictionary of exports, mapping an export category to a list of :class:`ExportEntry` instances describing the individual export entries. wN)get_distinfo_filerrr)r&rrfrs r'rz#InstalledDistribution.write_exportsxs # #$4 5 5 "c]] &a '1 % % % & & & & & & & & & & & & & & & & & &sA  A A cr|d}tj|5}t |5}|D]'\}}||kr|ccdddcdddS( dddn #1swxYwYdddn #1swxYwYt d|z)aW NOTE: This API may change in the future. Return the absolute path to a resource file with the given relative path. :param relative_path: The path, relative to .dist-info, of the resource of interest. :return: The absolute path where the resource is to be found. rrNz3no resource file with relative path %r is installed)r r_r`rarKeyError)r&rrhroresources_readerrelative destinations r'rz'InstalledDistribution.get_resource_paths  & &{ 3 3   . . +&&))) +-=-=++)Hk=00*** + + + + + + + + + + + + + + +1+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &(5677 7sAB B B7B9 BB B B BB #B c#@K|D]}|VdS)z Iterates over the ``RECORD`` entries and returns a tuple ``(path, hash, size)`` for each line. :returns: iterator of (path, hash, size) N)r)r&rs r'list_installed_filesz*InstalledDistribution.list_installed_filess8''))  FLLLL  r)Fcrtj|d}tj|j}||}tj|d}|d}t d||rdSt|5}|D]}tj |s| drdx} } nqdtj |z} t|d5} | | } dddn #1swxYwY||s|r5||r tj||}||| | f||r tj||}||ddfdddn #1swxYwY|S)z Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any existing ``RECORD`` file is silently overwritten. prefix is used to determine when to write absolute paths. rMr creating %sNz.pycz.pyoz%dr)rr#r^dirname startswithrrbinforisdirr[getsizerrrrelpathwriterow) r&pathsrdry_runbasebase_under_prefix record_pathwriterr# hash_valuerfps r'write_installed_filesz+InstalledDistribution.write_installed_filessqfb))wty)) OOF33w||D"%%,,X66  M;///  4 { # # 3v : :7==&&>$--8H*I*I>(**J"'//$"7"77DdD))>R%)]]27799%=%= >>>>>>>>>>>>>>>??4((7->7-1__V-D-D77??466Dz4 89999%%d++ A gook4@@ OO["b1 2 2 2# 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3$s8=A1H,.(E" H,"E& &H,)E& *B6H,,H03H0cg}tj|j}|d}|D]\}}}tj|s tj||}||krMtj|s||dddftj |rttj |}|r ||kr||d||f|rd|vr| ddd}nd }t|d 5} || |} | |kr||d || fd d d n #1swxYwY|S)  Checks that the hashes and sizes of the files in ``RECORD`` are matched by the files themselves. Returns a (possibly empty) list of mismatches. Each entry in the mismatch list will be a tuple consisting of the path, 'exists', 'size' or 'hash' according to what didn't match (existence is checked first, then size, then hash), the expected value and the actual value. rrTFr=rrNrr)rr#r&rr"isabsr^rr/isfilestrr*rrrr) r& mismatchesr/r1r#r3r actual_sizerr actual_hashs r'check_installed_filesz+InstalledDistribution.check_installed_filess wty)),,X66 &*&?&?&A&A W W "D*d7==&& 0w||D$//{""7>>$'' W!!44"?@@@@%% W!"'//$"7"788  WK4//%%tVT;&GHHHH Wj((!+!1!1#q!9!9!!<!%dD))WQ&*mmAFFHHf&E&E &*44&--tVZ.UVVVWWWWWWWWWWWWWWWs8AG  G G ci}tj|jd}tj|rt j|dd5}|}dddn #1swxYwY|D]P}|dd\}}|dkr*| |g |K|||<Q|S) a A dictionary of shared locations whose keys are in the set 'prefix', 'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'. The corresponding value is the absolute path of that category for this distribution, and takes into account any paths selected by the user at installation time (e.g. via command-line arguments). In the case of the 'namespace' key, this would be a list of absolute paths for the roots of namespace packages in this distribution. The first time this property is accessed, the relevant information is read from the SHARED file in the .dist-info directory. rrhrencodingNr8r namespace) rr#r^r:codecsrrrrr-r/)r&r shared_pathrlinesliner.rHs r'shared_locationsz&InstalledDistribution.shared_locationss gll49h77 7>>+ & & ([#@@@ .A++-- . . . . . . . . . . . . . . . ( (!ZZQ// U+%%%%c2..55e<<<<"'F3KK s'BBBc:tj|jd}td||rdSg}dD]I}||}tj||r||d|J|ddD]}|d|ztj |d d 5}| d |dddn #1swxYwY|S) aa Write shared location information to the SHARED file in .dist-info. :param paths: A dictionary as described in the documentation for :meth:`shared_locations`. :param dry_run: If True, the action is logged but no file is actually written. :return: The path of the file written to. rr$N)rlibheadersscriptsrr8rCr7z namespace=%srrrA ) rr#r^rbr(r)r/getrDrwrite) r&r-r.rErFr.r#nsrs r'write_shared_locationsz,InstalledDistribution.write_shared_locationssUgll49h77  M;///  4B 5 5C:Dw}}U3Z(( 5 dd3444))K,, . .B LL", - - - - [cG < < < & GGDIIe$$ % % % & & & & & & & & & & & & & & &s)DDDc|tvrtd|d|jtj|j}|td|jz||S)N#invalid path for a dist-info file: rzUnable to get a finder for %s) DIST_FILESrr#rrWrX)r&r#rgs r'r z+InstalledDistribution.get_distinfo_resourcesw z ! !""15tyy$BCC C*4955 >"#BTY#NOO O{{4   r)c |tjdkr{|tjdd\}}||jtjdkr#t d|d|jd|jd|tvrt d |d |jtj |j|S) a Returns a path located under the ``.dist-info`` directory. Returns a string representing the path. :parameter path: a ``'/'``-separated path relative to the ``.dist-info`` directory or an absolute path; If *path* is an absolute path and doesn't start with the ``.dist-info`` directory path, a :class:`DistlibException` is raised :type path: str :rtype: str rNzdist-info file z does not belong to the rz distributionrSr) rXrseprr#rr"r{rTr^)r&r#r|s r'rz'InstalledDistribution.get_distinfo_file$s 99RV   ! !%)ZZ%7%7%< " d49??26#:#:2#>>>&&&*ddDIIIt|||EFFF z ! !""15tyy$BCC Cw||DIt,,,r)c#BKtj|j}|D]c\}}}tj|s tj||}||jr|VddS)z Iterates over the ``RECORD`` entries and returns paths for each line if the path is pointing to a file located in the ``.dist-info`` directory or one of its subdirectories. :returns: iterator of paths N)rr#r&rr9r^r')r&r/r#rrs r'list_distinfo_filesz)InstalledDistribution.list_distinfo_filesAswty))$($5$5$7$7   D(D7==&& 0w||D$//ty))    r)cLt|to|j|jkSrD)rrrr#r&rs r'rzInstalledDistribution.__eq__Qs&5"788( UZ' )r))NNF)r3r4r5r6rr(rrrrrrrrr"r5r?rHrQr rrZrobjectrrrs@r'rrs`F - - - - - -D000333.  _     & & &777(!!!!F!!!F_42!!!---: ))) HHHHHr)rcfeZdZdZdZiZd fd ZdZdZdZ dZ d Z dd Z d Z ejZxZS)raCreated with the *path* of the ``.egg-info`` directory or file provided to the constructor. It reads the metadata contained in the file itself, or if the given path happens to be a directory, the metadata is read from the file ``PKG-INFO`` under that directory.TNcd}||_||_|rD|jr=||jjvr/|jj|j}|||j|jnO||}|||j|j|r!|jr|j|tt| |||dS)NcT||_||_||_dSrD)r"rr.r{)rnrs r'set_name_and_versionz:EggInfoDistribution.__init__..set_name_and_versioncs#AFGGIIAEAIIIr)) r#rr@r?rRr"r{ _get_metadatar2rrr()r&r#rSrcrRrs r'r(zEggInfoDistribution.__init__bs       )3% )$#.2E*E*E~*409H x}h6F G G G G))$//H ! x}h6F G G G )s) )""4((( !4((11(D#FFFFFr)c4d}dfd}dx}}|drtj|rtj|d}tj|d}t |d}tj|d} tj|d }|| }nt j|} t| d  d } t | d } | d } | d d}| d}n#t$rd}YnwxYw|drtj|rktj|d} || }tj|d}tj|d }t |d}ntd|z|r| ||p|ntj|rOt|d5} |  d}dddn #1swxYwY|sg}n|}||_|S)Nc0g}|}|D]}|}|drtd|nt |}|std|u|jrtd|js||j d d|jD}||j d|d|S) zCreate a list of dependencies from a requires.txt file. *data*: the contents of a setuptools-produced requires.txt file. [z.Unexpected line: quitting requirement scan: %rz#Not recognised as a requirement: %rz4extra requirements in requires.txt are not supportedrc3 K|] }d|zV dS)z%s%sNr7)rcs r' zQEggInfoDistribution._get_metadata..parse_requires_data..s&$G$GAVaZ$G$G$G$G$G$Gr)rr) rstripr'rbrrr constraintsr/r"r^)rreqsrFrGrhconss r'parse_requires_dataz>EggInfoDistribution._get_metadata..parse_requires_datazs' DOO%%E < <zz||??3''NN#S#')))E%d++NN#H$OOO84NN$3444}<KK''''99$G$G$G$G$GGGDKKQVVVTTT :;;;;Kr)cg} tj|dd5}|}dddn #1swxYwYn#t$rYnwxYw|S)zCreate a list of dependencies from a requires.txt file. *req_path*: the path to a setuptools-produced requires.txt file. rhrN)rDrrIOError)req_pathrmr4ros r'parse_requires_pathz>EggInfoDistribution._get_metadata..parse_requires_paths D [388:B..rwwyy99D:::::::::::::::    Ks3AA AA  A A  A AArUzEGG-INFOzPKG-INFOrN)r#rQz requires.txtrzEGG-INFO/PKG-INFOutf8rOzEGG-INFO/requires.txtzEGG-INFO/top_level.txtrrTz,path must end with .egg-info or .egg, got %rr)r[rr#r)r^r zipimport zipimporterrget_datarrqradd_requirementsrrrrr)r&r#requiresrstl_pathtl_datar meta_pathrRrrzipfrPrrros @r'rdz!EggInfoDistribution._get_metadataws9   6     ! ' ==  4w}}T"" $GLLz22GLLJ77 #8DDD7<<>::',,q/::..x88!,T22"MM"566==fEEGG#GHEEE$==)@AAD"mm,DEELLWUUG224;;w3G3GHHHH$$$#HHH$ ]]; ' ' 4w}}T"" >7<<n==..x88w||D*55',,t_==T(;;;HH"$,.2$344 4  0  % %h / / / ?"rw~~g'>'>"'4((7Affhhoog66G777777777777777 +GG((**G s%>AF F)(F)9(K--K14K1c8d|jd|jd|jdS)Nz>+ & & E"7799 E E a;&&w~~d++E%%tXtU&CDDDr)c d}d}tj|jd}g}tj|r._md5s`T4  A &&((  ;w''1133 3s ;Ac4tj|jSrD)rstatst_size)r#s r'_sizez7EggInfoDistribution.list_installed_files.._sizes74==( (r)rrhrrAzNon-existent file: %sr%N) rr#r^rrDrrknormpathrbrr[r)r/)r&rrr1rrrGrs r'r"z(EggInfoDistribution.list_installed_filess 4 4 4 ) ) )gll49.CDD  7>>+ & & 5[#@@@ >A > >D::<>!,,%'>BBB::&677%$7==++> q$$q''5588&<=== > > > > > > > > > > > > > > > > MM;d3 4 4 4 s%C5E''E+.E+Fc#Ktj|jd}tj|rd}t j|dd5}|D]}|}|dkrd}|sgtjtj|j|}||jr |r|V|V ddddS#1swxYwYdSdS) a  Iterates over the ``installed-files.txt`` entries and returns paths for each line if the path is pointing to a file located in the ``.egg-info`` directory or one of its subdirectories. :parameter absolute: If *absolute* is ``True``, each returned path is transformed into a local absolute path. Otherwise the raw value from ``installed-files.txt`` is returned. :type absolute: boolean :returns: iterator of paths rTrhrrAz./FN) rr#r^rrDrrkrr')r&absoluter1skiprrGrs r'rZz'EggInfoDistribution.list_distinfo_filessQgll49.CDD 7>>+ & & +D[#@@@ +A + +D::<C>cLt|to|j|jkSrD)rrrr#r\s r'rzEggInfoDistribution.__eq__.s&5"566( UZ' )r)rDr])r3r4r5r6rrHr(rdrrr?r"rZrr^rrrs@r'rrYs// IGGGGGG*XXXt000333&$$$L++++:))) HHHHHr)rcNeZdZdZdZdZddZdZdZdd Z dd Z d Z d Z dS)DependencyGrapha Represents a dependency graph between distributions. The dependency relationships are stored in an ``adjacency_list`` that maps distributions to a list of ``(other, label)`` tuples where ``other`` is a distribution and the edge is labeled with ``label`` (i.e. the version specifier, if such was provided). Also, for more efficient traversal, for every distribution ``x``, a list of predecessors is kept in ``reverse_list[x]``. An edge from distribution ``a`` to distribution ``b`` means that ``a`` depends on ``b``. If any missing dependencies are found, they are stored in ``missing``, which is a dictionary that maps distributions to a list of requirements that were not provided by any other distributions. c0i|_i|_i|_dSrD)adjacency_list reverse_listrr%s r'r(zDependencyGraph.__init__Is  r)c.g|j|<g|j|<dS)zAdd the *distribution* to the graph. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` N)rr)r& distributions r'add_distributionz DependencyGraph.add_distributionNs$ -/L)*,,'''r)Nc|j|||f||j|vr"|j||dSdS)aAdd an edge from distribution *x* to distribution *y* with the given *label*. :type x: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type y: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type label: ``str`` or ``None`` N)rr/r)r&xylabels r'add_edgezDependencyGraph.add_edgeXsa A%%q%j111 D%a( ( (  a ' ' * * * * * ) (r)ctd|||j|g|dS)a Add a missing *requirement* for the given *distribution*. :type distribution: :class:`distutils2.database.InstalledDistribution` or :class:`distutils2.database.EggInfoDistribution` :type requirement: ``str`` z %s missing %rN)rbrcrr-r/)r&rrs r' add_missingzDependencyGraph.add_missinggsF  _lK@@@  b1188EEEEEr)c$|jd|jSrrr0s r' _repr_distzDependencyGraph._repr_distrrr)rc||g}|j|D]\}}||}||d|d}|d|zt|z|||dz}|d}||ddd|S)zPrints only a subgraphNz []z rrM)rrr/r; repr_noderextendr^)r&r1leveloutputrr suboutputsubss r'rzDependencyGraph.repr_nodeus//$''( /5 $ $LE5??5))D $(DD%%%0 MM&5.3t994 5 5 5ueai88I??4((D MM$qrr( # # # #yy   r)Tc g}|d|jD]\}}t|dkr|s|||D]W\}}|*|d|jd|jd|d1|d|jd|jdX|st|dkr|d |d |d |D]4}|d |jz|d 5|d|ddS)a9Writes a DOT output for the graph to the provided file *f*. If *skip_disconnected* is set to ``True``, then all distributions that are not dependent on any other distribution are skipped. :type f: has to support ``file``-like operations :type skip_disconnected: ``bool`` zdigraph dependencies { rN"z" -> "z " [label="z"] z" zsubgraph disconnected { zlabel = "Disconnected" zbgcolor = red z"%s"rMz} )rOritemsr r/r")r&rskip_disconnected disconnectedr1adjsrrs r'to_dotzDependencyGraph.to_dots  *+++-3355 H HJD$4yyA~~&7~##D))) $ H H u}GGG!YYY EEE;<<<<GGG 5:::FGGGG  H ! S%6%6%:%: GG/ 0 0 0 GG. / / / GG% & & &$  *+++ GGENNN r)cg}i}|jD]\}}|dd||< gt|ddD]\}}|s|||= snf|D]\}}fd|D||<tddD||t|fS)aa Perform a topological sort of the graph. :return: A tuple, the first element of which is a topologically sorted list of distributions, and the second element of which is a list of distributions that cannot be sorted because they have circular dependencies and so form a cycle. NTc&g|] \}}|v ||fSr7r7)rrrh to_removes r'r z4DependencyGraph.topological_sort..s+GGGtq!AY4F4FQF4F4F4Fr)zMoving to result: %sc2g|]}|jd|jdS)rrr)rrs r'r z4DependencyGraph.topological_sort..s)MMMaqvvvqyyy9MMMr))rrlistr/rbrcrkeys)r&ralistkrrs @r'topological_sortz DependencyGraph.topological_sortsF'--//  DAqtE!HH %IU[[]]++AAA. ! !1!$$Q'''a   H H1GGGGqGGGa LL/MM9MMM O O O MM) $ $ $ % tEJJLL))))r)cg}|jD]-\}}|||.d|S)zRepresentation of the graphrM)rrr/rr^)r&rr1rs r'rzDependencyGraph.__repr__s\-3355 0 0JD$ MM$.... / / / /yy   r)rD)r)T) r3r4r5r6r(rrrrrrrrr7r)r'rr9s   --- + + + + F F F333 ! ! ! !@***>!!!!!r)rr:cjt|}t}i}|D]{}|||jD]\}t |\}}t d|||||g||f]||D]}|j |j z|j z|j z}|D]} | | } nZ#t$rMt d| | d}| |} YnwxYw| j}d} ||vrT||D]K\}} | |} n#t$rd} YnwxYw| r||| | d} nL| s||| |S)a6Makes a dependency graph from the given distributions. :parameter dists: a list of distributions :type dists: list of :class:`distutils2.database.InstalledDistribution` and :class:`distutils2.database.EggInfoDistribution` instances :rtype: a :class:`DependencyGraph` instance zAdd to provided: %s, %s, %srrFT)rrrrrrbrcr-r/rrrrrr rrr.rrr)distsrQgraphrr1rr"r{ryrrmatchedproviderrs r' make_graphrs:  F   EHBB t$$$ B BA2155MD' LL6gt L L L   b ) ) 0 0'4 A A A A B --%(::'(*.*;< - -C / ..--* / / /L"$$$yy{{1~ ....  /;DGx)1$  %GX& ' g 6 62&&& %&tXs;;;"& -!!$,,,3 -4 Ls%CAD43D4E(( E7 6E7 cP||vrtd|jzt|}|g}|j|}|rT|}|||j|D]}||vr|||T|d|S)zRecursively generate a list of distributions from *dists* that are dependent on *dist*. :param dists: a list of distributions :param dist: a distribution, member of *dists* for which we are interested 1given distribution %r is not a member of the listr)rr"rrpopr/)rr1rdeptodorsuccs r'get_dependent_distsrs 5 -/3y 9:: : u  E &C  d #D " HHJJ 1 &q) " "D3 D!!! "GGAJJJ Jr)c0||vrtd|jzt|}g}|j|}|rZ|d}|||j|D]}||vr|||Z|S)zRecursively generate a list of distributions from *dists* that are required by *dist*. :param dists: a list of distributions :param dist: a distribution, member of *dists* for which we are interested rr)rr"rrrr/)rr1rrrrpreds r'get_required_distsrs 5 -/3y 9:: : u  E C   %D " HHJJqM 1 (+ " "D3 D!!! " Jr)c |dd}tdi|}||_||_|pd|_t |S)zO A convenience method for making a dist given just a name and version. summaryzPlaceholder for summaryr7)rr r"r{rr)r"r{kwargsrrs r' make_distr2sTjj$=>>G   F  BBGBJ55BJ   r))r:)7r6 __future__rrrDr_rloggingrr]r;rurMrrcompatrr{rr rRr r r r utilrrrrrrr__all__ getLoggerr3rbrCOMMANDS_FILENAMErTr\r^r rrrrrrdrerrrrrr7r)r'rsj ''''''   ))))))))88888888111111111111FFFFFFFFFFFFFFFFFF     8 $ $(*,h +X7  <<<<