MRe_m@s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z yddl m Z mZWn(ek rddlm Z mZYnXyeWn"ek r ddlmZYnXy$eddZddlmZWn:ek rleZdd lmZddd d ZYnXdd lmZy&dd lmZmZm Z dZ!Wnek rdZ!YnXddlm"Z#ddl$m%Z%m&Z&ej'ddfkoej(j)dkrddl*j+Z,ndZ,yddl-Z-Wnek rGYnXdddZ.iZ/ddZ0ddZ1ddZ2ddZ3dd Z4d!d"Z5d#d$Z6d%dZ7Z8d&d'Z9d(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdlgEZ:GdmdCdCe;Z<GdndDdDe<Z=GdodEdEe<Z>GdpdFdFe<Z?iZ@ejAddZBdZCdqZDdrZEdZFdr ZGdsdhZHdtd*ZIgdudvZJdwdxZKdydzZLejMd{ZNejMd|ZOeLZPd}dMZQd~d)ZReRZSdd+ZTdd,ZUddd-ZVdd.ZWGdd[d[ZXGdd\d\eXZYGdd>d>eZZ[Gdd=d=eZZ\e\Z]GddGdGe^Z_Gdd?d?Z`dd<ZaddJZbddKZcddPZdddQZeidgd6dgd6dddgd6gd6gd6gd6Zfiddd6ddd6ddd6ddd6ddd6ddd6ddd6ZgddZhddZiddZjddRZkdiddSZlddZmdenkremZlnGddbdbZoeHeZeoGddcdceoZpGdddddepZqeHerdeqe,dk r*eHe,jseqnGdd`d`eoZtetZuddZvGddedeepZweHejxewGdd]d]etZyGdd^d^eqZzGdd_d_ewZ{e0ddiddfZ|ddd9Z}dddZ~e|ejxe~dddZe|eZedddZe|e jee,dk rae|e,jene0ddie0ddiddgZddZdd6ZdddiZddZee jeeejxee,dk ree,jenddZeeZeddUZiddZddZddNZejMdjZejMdjZejMdjZejMdjZejMdjZejMdjZejMdjZejMdjZejMdejejBjZejMdejZidd6dd6dd6dd6dd6jZddZddIZGddBdBeZZddZGdd@d@eZZGdddeZied6ed6ed6ZddZddHZddZGddAdAZidd6dd6dd6dd6dd6dd6ZddZddZddTZddOZd d Ze`Zd d Zeene0d d7e[yddlmZWnek r YnXyejeWne=k rj e[gZx0ejeee\D]Zejeq Wx0ejD]%ZeejkrL ejenq' Wejejdd(sr )StringIO)BytesIOcCsY|dkrt}n|dkr-|}nttt|j|d||dS)Nexec)globalsr compileopenread)fnglobslocsrrr execfile-s     r)utime)mkdirrenameunlinkTF)r)isdirsplitZcpythonicCs^tstdnt|\}}|rZ|rZt| rZt|t||ndS)Nz*"os.mkdir" not supported on this platform.) WRITE_SUPPORTIOErrorrr_bypass_ensure_directoryr)namemodedirnamefilenamerrr rKs  rcKs>t}x.|jD] \}}|||<|t|Distribution doesn't have an "extra feature" of the given nameN)rrrrrrrr ris r>cCs|t|z10.3z10.4Fr)r@rAdarwinVersionStringrrF)providedrequiredreqMacprovMac provDarwindversion macosversionrrr rps*$"*cCsNtjdj}|d}|j||dIs the named metadata a directory? (like ``os.path.isdir()``)Nr)r rrr metadata_isdirusz IMetadataProvider.metadata_isdircCsdS)z?List of metadata names in the directory (like ``os.listdir()``)Nr)r rrr metadata_listdirxsz"IMetadataProvider.metadata_listdircCsdS)z=Execute the named script in the supplied namespace dictionaryNr)r namespacerrr rL{szIMetadataProvider.run_scriptN) rrrrrrrrrLrrrr r~gs      c@s^eZdZdZddZddZddZdd Zd d Zd d Z dS)rz3An object that provides access to package resourcescCsdS)zdReturn a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``Nr)manager resource_namerrr get_resource_filenamesz'IResourceProvider.get_resource_filenamecCsdS)ziReturn a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``Nr)rrrrr get_resource_streamsz%IResourceProvider.get_resource_streamcCsdS)zmReturn a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``Nr)rrrrr get_resource_stringsz%IResourceProvider.get_resource_stringcCsdS)z,Does the package contain the named resource?Nr)rrrr has_resourceszIResourceProvider.has_resourcecCsdS)z>Is the named resource a directory? (like ``os.path.isdir()``)Nr)rrrr rXsz IResourceProvider.resource_isdircCsdS)z?List of resource names in the directory (like ``os.listdir()``)Nr)rrrr rVsz"IResourceProvider.resource_listdirN) rrrrrrrrrXrVrrrr rs      c@seZdZdZdddZddZddZd d Zdd d Zd dZ ddZ ddddZ ddddZ dddddZ ddZddZddZddZd d!ZdS)"razDA collection of active distributions on sys.path (or a similar list)NcCs^g|_i|_i|_g|_|dkr<tj}nx|D]}|j|qCWdS)z?Create working set from list of path entries (default=sys.path)N)entries entry_keysby_key callbacksrBr add_entry)rrentryrrr __init__s       zWorkingSet.__init__cCsT|jj|g|jj|x*t|dD]}|j||dq3WdS)aAdd a path item to ``.entries``, finding any distributions on it ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than once, and the ``.entries`` of the ``sys.path`` WorkingSet should always equal ``sys.path``.) TFN)r setdefaultrrr\add)rrrrrr rs zWorkingSet.add_entrycCs|jj|j|kS)z9True if `dist` is the active distribution for its project)rrr6)rrrrr __contains__szWorkingSet.__contains__cCsG|jj|j}|dk r?||kr?t||n|SdS)aFind a distribution matching requirement `req` If there is an active distribution for the requested project, this returns it as long as it meets the version requirement specified by `req`. But, if there is an active distribution for the project and it does *not* meet the `req` requirement, ``VersionConflict`` is raised. If there is no active distribution for the requested project, ``None`` is returned. N)rrr6rg)rreqrrrr rs zWorkingSet.findccsgx`|D]X}|j|}|dkrGx4|jD] }|Vq5Wq||kr||VqqWdS)aYield entry point objects from `group` matching `name` If `name` is None, yields all entry points in `group` from all distributions in the working set, otherwise only ones matching both `group` and `name` are yielded (in distribution order). N)rPvalues)rrFr rreprrr rRs    zWorkingSet.iter_entry_pointscCsQtjdj}|d}|j||d<|j|dj||dS)z?Locate distribution for `requires` and run `script_name` scriptrrrN)rBrrr4rKrL)rrequiresrrr rrr rLs    zWorkingSet.run_scriptccspi}xc|jD]X}||jkr+qnx:|j|D]+}||kr9d||<|j|Vq9q9WqWdS)zYield distributions for non-duplicate projects in the working set The yield order is the order in which the items' path entries were added to the working set. rN)rrr)rseenitemr6rrr __iter__s  zWorkingSet.__iter__TcCs|r|j|j|n|dkr4|j}n|jj|g}|jj|jg}|j|jkrwdS||j|j<|j|kr|j|jn|j|kr|j|jn|j|dS)aAdd `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set. If it's added, any callbacks registered with the ``subscribe()`` method will be called. N) insert_onrlocationrrr6rr _added_new)rrrinsertkeyskeys2rrr rs   zWorkingSet.addc CsVt|ddd}i}i}g}x$|rQ|jd}||krUq.n|j|j}|dkr|jj|j}|dkr|dkrt|j}n|j|||}||j<|dkrt|qn|j |n||krt ||n|j |j |j dddd||gSYnX||jkrw|j|}|j|.)rCrr)attrrCrrr rgbs   rgcCsDtjdkrdStjjdr)dSdtjkr<dSdSdS)Ncli IronPythonjavaJythonZ__pypy__PyPyCPython)rBrCrbuiltin_module_namesrrrr rjisrjcCsEidd6dd6}d|_d|_|j|j|j|_|S)z Given a SyntaxError from a marker evaluation, normalize the error message: - Remove indications of filename and line number. - Replace platform-specific error messages with standard error messages. zinvalid syntaxzunexpected EOF while parsingzparenthesis is never closedN)r#linenorrG)excsubsrrr normalize_exceptionss   rvc Cs;yt|Wn&tk r6ttjdSYnXdS)zHValidate text as a PEP 426 environment marker; return exception or FalserF)rv SyntaxErrorrvrBr )textrrr rus  csfsddlmmddlddlddlfdd}fdd}fdd }fd d }ji|j6|j6|j6|j 6d d d6dd d6j d6j d6t dr|j s z5evaluate_marker..and_test..rr>) functoolsreduceand_rangelen)r~)r}operator)r~r and_testsz!evaluate_marker..and_testcs;tjjfddtdtdDS)Ncs g|]}|qSrr)r{r|)r}r~rr rs z1evaluate_marker..test..rr>)rror_rr)r~)r}r)r~r testszevaluate_marker..testcsa|dd}|jkrQ|ddjkrCtdn|dStddS)Nrrr>zEmpty parenthesesz5Language feature not supported in environment markers)LPARRPARrw)r~t)r}tokenrr atoms zevaluate_marker..atomc st|dkr!tdn|dd}|d}|dkrt|ddkr|dkrtd}q}d }qny|}Wn(tk rtt|d YnX||d|dS) Nrz5Chained comparison not allowed in environment markersr>rrrnotznot inzis notz, operator not allowed in environment markers)rrwrr)r~compcop)ry_opsevaluaterr comparisons     z#evaluate_marker..comparisoncSs ||kS)Nr)xyrrr r sz!evaluate_marker..znot incSs ||kS)Nr)rrrrr r sinz==z!=or_testc s{x t|dkr"|d}qWy|d}Wn9tk rptdtdj|dYnX||S)Nr>rrz)Comparison or logical expression expectedz7Language feature not supported in environment markers: )rrrwsym_name)r~op)rsymbolrr r}s   z"evaluate_marker..interpretc sx t|dkr"|d}qW|d}|d}|kr}yt|}Wn"tk rutd|YnX|S|kr|d}|dddks|jds|jdsd|krtd n|dd Std dS) Nr>rrzUnknown name %rz'"z"""z'''\z1Only plain strings allowed in environment markersz5Language feature not supported in environment markersr)r_marker_valuesrrwr)r~kindr rs)ryrzrr rs$      4  z!evaluate_marker..evaluater)rryrzrrr5rrrreqnerrparserexprtotuple)rxr`rrrrrr)ryrzrrr}rrrr rvs$     % c Csddl}|j}x9|jD]+}|jdd}|j|||cCsdS)Nrr)rrrrr r scCsgS)Nr)rrrrr r sNcCsdS)Nr)rrrr rszEmptyProvider.__init__) rrrrrrrrrrrrrr rs   c Cst}tj|}zYxR|jD]D}|jdtj}|j|||<||dk s(tq(WWd|j X|S)af This builds a similar dictionary to the zipimport directory caches. However instead of tuples, ZipInfo objects are stored. The translation of the tuple is as follows: * [0] - zipinfo.filename on stock pythons this needs "/" --> os.sep on pypy it is the same (one reason why distribute did work in some cases on pypy and win32). * [1] - zipinfo.compress_type * [2] - zipinfo.compress_size * [3] - zipinfo.file_size * [4] - len(utf-8 encoding of filename) if zipinfo & 0x800 len(ascii encoding of filename) otherwise * [5] - (zipinfo.date_time[0] - 1980) << 9 | zipinfo.date_time[1] << 5 | zipinfo.date_time[2] * [6] - (zipinfo.date_time[3] - 1980) << 11 | zipinfo.date_time[4] << 5 | (zipinfo.date_time[5] // 2) * [7] - zipinfo.CRC rN) r zipfileZipFilenamelistrrsepgetinfoAssertionErrorr)rzipinfozfilezitemzpathrrr build_zipmanifests  rc@seZdZdZdZddZddZddZd d Ze d d Z d dZ ddZ ddZ ddZddZddZddZddZddZdS)rz"Resource support for zips and eggsNcCs?tj||t|jj|_|jjtj|_dS)N) rrrrarchiverrrzip_pre)rrrrr rszZipProvider.__init__cCsF|j|jr)|t|jdStd||jfdS)Nz%s is not a subpath of %s)rrrr)rfspathrrr _zipinfo_nameszZipProvider._zipinfo_namecCsj|j|}|j|jtjrM|t|jddjtjStd||jfdS)Nrz%s is not a subpath of %s)rrrrrrrr)rzip_pathrrrr _partss  'zZipProvider._partscCs|jstdn|j|}|j}dj|j||kr~x*|D]}|j||j|qXWn|j||S)Nz5resource_filename() only supported for .egg, not .zipr)rr_resource_to_zip_get_eager_resourcesrDr_extract_resource _eager_to_zip)rrrreagersr rrr rs     z!ZipProvider.get_resource_filenamecCs/|j}|jd}tj|}||fS)Nrrr)rrr) file_size date_timetimemktime)zip_statsizer timestamprrr _get_date_and_sizes  zZipProvider._get_date_and_sizec Cs||jkr^x9|j|D]'}|j|tjj||}q#Wtjj|S|j|j|\}}tst dny)|j |j |j |}|j ||r|Stddtjj|\}} tj||jj|tj|t| ||f|j| |yt| |Wnmtjk rtjj|r|j ||r|Stjdkrt|t| ||SnYnXWntjk r|jYnX|S)Nz>"os.rename" and "os.unlink" are not supported on this platformz .$extractdirr=)_indexrrrrDr"rrrrr<rr _is_current_mkstempwriterrrrrKrerrorisfiler rr6) rrrr lastrr real_pathoutftmpnamrrr rs@$    zZipProvider._extract_resourcec Cs|j|j|\}}tjj|s2dStj|}|j|ks_|j|krcdS|jj |}t |d}|j }|j ||kS)zK Return True if the file_path is current for this zip_path Fr) rrrrrr@st_sizest_mtimerrrrr) r file_pathrrrr@ zip_contentsf file_contentsrrr r&s  zZipProvider._is_currentcCsa|jdkrZg}x6dD].}|j|r|j|j|qqW||_n|jS)Nnative_libs.txteager_resources.txt)rr)rrrr)rrr rrr r7s  z ZipProvider._get_eager_resourcesc Csy |jSWntk ri}x|jD]y}|jtj}x^|rtjj|dd}||kr||j|dPqF|jg||=?|==|!=)\s*((\w|[-.])+)z\s*,z\s*\[z\s*\]z \w+(\.\w+)*$zL(?P[^-]+)( -(?P[^-]+) (-py(?P[^-]+) (-(?P.+))? )? )?z(\d+ | [a-z]+ | \.| -)cprepreviewzfinal-r]rc@devccs{xotj|D]^}t||}| s|dkr>qn|dddkre|jdVqd|VqWdVdS)Nr=r 0123456789r*z*final) component_rerrzfill)rpartrrr _parse_version_partss rBcCsg}xt|jD]}|jdr|dkrdx'|r`|ddkr`|jq=Wnx'|r|ddkr|jqgWn|j|qWt|S)aConvert a version string to a chronologically-sortable key This is a rough cross between distutils' StrictVersion and LooseVersion; if you give it versions that would work with StrictVersion, then it behaves the same; otherwise it acts like a slightly-smarter LooseVersion. It is *possible* to create pathological version coding schemes that will fool this parser, but they should be very rare in practice. The returned value will be a tuple of strings. Numeric portions of the version are padded to 8 digits so they will compare numerically, but without relying on how numbers compare relative to strings. Dots are dropped, but dashes are retained. Trailing zeros between alpha segments or dashes are suppressed, so that e.g. "2.4.0" is considered the same as "2.4". Alphanumeric parts are lower-cased. The algorithm assumes that strings like "-" and any alpha string that alphabetically follows "final" represents a "patch level". So, "2.4-1" is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is considered newer than "2.4-1", which in turn is newer than "2.4". Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that come before "final" alphabetically) are assumed to be pre-release versions, so that the version "2.4" is considered newer than "2.4a1". Finally, to handle miscellaneous cases, the strings "pre", "preview", and "rc" are treated as if they were "c", i.e. as though they were release candidates, and therefore are not as new as a version string that does not contain them, and "dev" is replaced with an '@' so that it sorts lower than than any other pre-release tag. r>z*finalrz*final-00000000rr)rBr"rrrtuple)rrrArrr rls c@seZdZdZffdddZddZddZd ddd d Zddd d ZdddZ e e Z dddZ e e Z dddZ e e Z dS)rez3Object representing an advertised importable objectNcCsnt|std|n||_||_t||_tjddj|j |_ ||_ dS)NzInvalid module namezx[%s],) MODULErGr module_namerDattrsrdrrDrr)rr rGrHrrrrr rs   "zEntryPoint.__init__cCsfd|j|jf}|jr<|ddj|j7}n|jrb|ddj|j7}n|S)Nz%s = %s:r=z [%s]rE)r rGrHrDr)rrrrr __str__s   zEntryPoint.__str__cCsdt|S)NzEntryPoint.parse(%r))r)rrrr rszEntryPoint.__repr__Tc Cs|r|j||nt|jttdg}xO|jD]D}yt||}WqDtk rtd||fYqDXqDW|S)Nrz%r has no %r attribute)rKrrGrrHrrr)rrKrrrrkrrr loads! zEntryPoint.loadcCs]|jr%|j r%td|ntttjtj|jj|j||dS)Nz&Can't require() without a distribution) rrrirrrZrrr)rrrrrr rKs zEntryPoint.requirecCsyf}}|jdd\}}d|krz|jdd\}}tjd|}|jrntn|j}nd|kr|jdd\}}t|jstn|jjd}nWn!tk rtd|Yn#X||j|j|||SdS) aParse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1,extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional =r[zx[rIr=z9EntryPoint must be in 'name=module:attrs [extras]' formatN) rrdrspecsrGrrFrr)clssrcrrHrr valuerrrr rs&        zEntryPoint.parsecCst|std|ni}xZt|D]L}|j||}|j|krptd||jn|||js  rZc @seZdZdZdZddddededdZdddZe eZe dd Z d d Z d d Z ddZddZddZddZddZddZe eZddZe eZddZe eZddZe eZfd d!Zd"d#Zdd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zdd.d/Ze eZd0d1Zd2d3Z dd4d5Z!d6d7Z"dd8d9Z#d:d;Z$d<d=Z%d>d?Z&d@dAZ'e e'Z'dS)Brcz5Wrap an actual or potential sys.path entry w/metadatazPKG-INFONcCsjt|p d|_|dk r3t||_n||_||_||_||_|p`t|_ dS)NUnknown) rmrrn_versionrrCrrr _provider)rrrrrrrCrrrr rKs     zDistribution.__init__c Ksdgd\}}}}tjj|\}} | jtkrt|} | r|| jdddd\}}}}nt| j}n|||d|d|d|d ||S) Nrr verpyverrHrrrrC)rrsplitextr"_distributionImplEGG_NAMErF) rOrrrr'rrrrCextrArrr rXs !zDistribution.from_locationcCs7t|df|j|jt|j|j|jfS)Nparsed_version)rrr6rZrrrC)rrrr r js  zDistribution.cCs t|jS)N)hashhashcmp)rrrr __hash__sszDistribution.__hash__cCs|j|jkS)N)rf)rr)rrr __lt__tszDistribution.__lt__cCs|j|jkS)N)rf)rr)rrr __le__vszDistribution.__le__cCs|j|jkS)N)rf)rr)rrr __gt__xszDistribution.__gt__cCs|j|jkS)N)rf)rr)rrr __ge__zszDistribution.__ge__cCs&t||jsdS|j|jkS)NF)rrrf)rr)rrr __eq__|szDistribution.__eq__cCs ||k S)Nr)rr)rrr __ne__szDistribution.__ne__c Cs>y |jSWn,tk r9|jj|_}|SYnXdS)N)_keyrrr")rr6rrr r6s   zDistribution.keyc Cs>y |jSWn,tk r9t|j|_}|SYnXdS)N)_parsed_versionrrlr)rpvrrr rds   zDistribution.parsed_versionc Csy |jSWntk rxq|j|jD]G}|jjdr.t|jdddj|_|jSq.Wt d|j|YnXdS)Nzversion:rIrz(Missing 'Version:' header and/or %s file) r\r _get_metadataPKG_INFOr"rrnrrrG)rrrrr rs  % zDistribution.versionc Csy |jSWntk rigd6}|_xdD]}xt|j|D]\}}|rd|kr|jdd\}}t|rg}qt|sg}qnt|pd}n|j|gj t |qRWq6W|SYnXdS)N requires.txt depends.txtrIr)rsrt) _Distribution__dep_maprrrrqrrurvrsrrrk)rdmr r`reqsmarkerrrr _dep_maps    "     'zDistribution._dep_mapc Cs|j}g}|j|jdfxT|D]L}y|j|t|Wq/tk rztd||fYq/Xq/W|S)z@List of Requirements needed for this distro if `extras` are usedNz%s has no such extra feature %r)ryrrrsrri)rrrvdepsrcrrr rs   zDistribution.requiresccs5|j|r1x|j|D] }|VqWndS)N)rr)rr rrrr rqszDistribution._get_metadatacCsd|dkrtj}n|j||tjkr`t|jttt|jdndS)z>Ensure distribution is importable on `path` (default=sys.path)Nznamespace_packages.txt) rBrrrrrrrYrq)rrrrr activates    zDistribution.activatecCsOdt|jt|j|jp'tf}|jrK|d|j7}n|S)z@Return what this distribution's standard .egg filename should bez %s-%s-py%sr])rtrrrr.rC)rr#rrr rs  zDistribution.egg_namecCs(|jrd||jfSt|SdS)Nz%s (%s))rr)rrrr rs zDistribution.__repr__c CsNyt|dd}Wntk r0d}YnX|p:d}d|j|fS)Nrz[unknown version]z%s %s)rrGr)rrrrr rJs   zDistribution.__str__cCs.|jdrt|nt|j|S)zADelegate all unrecognized public attributes to .metadata providerr)rrrr])rrkrrr __getattr__szDistribution.__getattr__cKs(|jt|tjj|||S)N)rrrrr)rOr#rr'rrr r szDistribution.from_filenamecCstjd|j|jfS)z?Return a ``Requirement`` that matches this distribution exactlyz%s==%s)rdrrr)rrrr r szDistribution.as_requirementcCsD|j||}|dkr:td||ffn|jS)z=Return the `name` entry point of `group` or raise ImportErrorNzEntry point %r not found)rQrrK)rrFr rrrr rO s zDistribution.load_entry_pointc Csdy |j}Wn4tk rCtj|jd|}|_YnX|dk r`|j|iS|S)z=Return the entry point map for `group`, or the full entry mapzentry_points.txtN)_ep_maprrerWrqr)rrFep_maprrr rP s  ! zDistribution.get_entry_mapcCs|j|j|S)z.r)rrrrr" enumeraterryrBcheck_version_conflictrrindexrG) rrlocnlocbdirnpathrrnprrr r s6       zDistribution.insert_oncCs|jdkrdStj|jd}t|j}x|jdD]}|tjksJ||ksJ|tkr}qJn|dkrqJnt tj|dd}|rt|j |sJ|j |jrqJnt d|||jfqJWdS) N setuptoolsznamespace_packages.txtz top_level.txt pkg_resourcessiterzIModule %s was already imported from %s, but %s is being added to sys.path)z pkg_resourcesz setuptoolszsite) r6r r rqrxrrBrrrr issue_warning)rnsprmodnamerrrr r@ s"  z#Distribution.check_version_conflictc Cs<y |jWn*tk r7tdt|dSYnXdS)NzUnbuilt egg for FT)rrGrr)rrrr r&U s    zDistribution.has_versioncKsMx*d D]"}|j|t||dqW|jd|j|j|S) z@Copy this distribution, substituting in any changed keyword argsrrrrCrrNr)z project_namezversionz py_versionzplatformzlocationz precedence)rrr]r)rr'rkrrr clone] s   zDistribution.clonecCsdd|jDS)NcSsg|]}|r|qSrr)r{deprrr ri s z'Distribution.extras..)ry)rrrr rh szDistribution.extras)(rrrrrrr.ryrrrXpropertyrfrgrhrirjrkrlrmr6rdrryrrqr{rrrJr|r r rOrPrQrrr&rrrrrr rcGsV                           '   c@sgeZdZdZdZejdZeddZ eddZ dd Z d d Z d S) DistInfoDistributionzGWrap an actual or potential sys.path entry w/metadata, .dist-info styleMETADATAz([\(,])\s*(\d.*?)\s*([,\)])c Cs\y |jSWnJtk rWddlm}|j|j|j|_|jSYnXdS)zParse and cache metadatar)ParserN) _pkg_infor email.parserrparsestrrrr)rrrrr _parsed_pkg_infor s   !z%DistInfoDistribution._parsed_pkg_infoc Cs:y |jSWn(tk r5|j|_|jSYnXdS)N)_DistInfoDistribution__dep_mapr_compute_dependencies)rrrr ry| s   zDistInfoDistribution._dep_mapcCsy|jdddg}|dj}|dj}tj|jd|}|jddjdd}||fS)zConvert 'Foobar (1); baz' to ('Foobar ==1', 'baz') Split environment marker, add == prefix to version specifiers as necessary, and remove parenthesis. ;rrrz\1==\2\3())rrr^r_EQEQr)r requires_distrdistversmarkrrr _preparse_requirement s z*DistInfoDistribution._preparse_requirementc sddlm}igd6}|_gxc|jjdpBgD]I}|j|\}}tt|}|||_j |qCWfdd}t |d}|dj |xR|jjdpgD]8} t | j } tt || ||| .reqs_for_extrazProvides-Extra)rrrrget_allrrrkrr frozensetrrsrr) rcompile_markerrvrrrrYrcommonr`r)rwr r s$z*DistInfoDistribution._compute_dependenciesN) rrrrrrr^rrrrryrrrrrr rm s   rz.eggz .egg-infoz .dist-infoc Os|d}t}y-x&tj|j|kr:|d7}qWWntk rPYnXddlm}|d|d||dS)Nrr)rE stacklevel)rrBrrrGrDrE)r;r'levelr(rErrr r s  rc#stt|fdd}xD]}t|}|sUtd|n|jd}|j}g}t||}|r|j}|tt||d d\}}}n|tt ||d d\}}}dd |D}t |||Vq+Wd S) zYield ``Requirement`` objects for each specification in `strs` `strs` must be an instance of ``basestring``, or a (possibly-nested) iterable thereof. csLg}x|||st||rayt}d}Wqatk r]tdYqaXn|||}|std|d|d||dn|j|j||j}t||}|r|j}q |||s td|d||dq q W|||}|r?|j}n|||fS)Nrz+\ must not appear on the last nonblank linez Expected z inatzExpected ',' or end-of-list in)CONTINUEr StopIterationrGrrFendCOMMA)ITEM TERMINATORrrgroups item_namer$rA)rRrr scan_list s0   * #z%parse_requirements..scan_listzMissing distribution specrz 'extra' namer>z version speccSs(g|]\}}|t|fqSr)rn)r{rr)rrr r s z&parse_requirements..N)r)rr>) iterrqDISTROrGrFrOBRACKETCBRACKETVERSIONLINE_ENDrd)r5rrrArrrrNr)rRr rk s"!    $$cCsAdd|D}|jdd|D|ddd.cSsg|]\}}|qSrr)r{hcdrrr r s rr)r)r$tmprrr r# s r#c@speZdZddZddZddZddZd d Zd d Zd dZ e e Z dS)rdcCs|t||_}||j|_|_dd|D}|jdd|D|_|ttt ||_ |_ |jtdd|Dt |j f|_ t|j |_dS)z>DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!cSs2g|](\}}t|t|||fqSr)rl state_machine)r{rr.rrr r s z(Requirement.__init__..cSs(g|]\}}}}||fqSrr)r{rYtransrr^rrr r s cSs(g|]\}}}}||fqSrr)r{rYrrr^rrr r s N)rm unsafe_namer"rr6rrNrDrrsrrrhashCmpre_Requirement__hash)rrrNrrrrr r s "zRequirement.__init__cCsXdjdd|jD}dj|j}|rDd|}nd|j||fS)NrEcSsg|]}dj|qS)r)rD)r{rrrr r s z'Requirement.__str__..z[%s]z%s%s%s)rDrNrr)rrNrrrr rJ s  zRequirement.__str__cCst|to|j|jkS)N)rrdr)rr)rrr rl szRequirement.__eq__c Cst|tr=|j|jkr%dS|jr[|j}q[nt|tr[t|}nd}dd}x|jD]{\}}}}||||}|dkrdS|dkrdS|dkrd}qw|dks|dkrwd}qwqwW|dkr d}n|S) NFcSs||k||kS)Nr)abrrr r $ sz*Requirement.__contains__..FTT+r])rrcr6rrdrrl) rrrcomparerYrrr^actionrrr r s,        zRequirement.__contains__cCs|jS)N)r)rrrr rg1 szRequirement.__hash__cCsdt|S)NzRequirement.parse(%r))r)rrrr r4 szRequirement.__repr__cCsWtt|}|rDt|dkr2|dStd|ntd|dS)NrrzExpected only one requirementzNo requirements found)rrkrrG)rrwrrr r7 s zRequirement.parseN) rrrrrJrlrrgrrrMrrrr rd s        z--TzT+Fz>=zT..z==zF++z!=cCs@t|ts9Gddd|t}|jddS|jS)z&Get an mro for a type or classic classc@seZdZdS)z_get_mro..clsN)rrrrrrr rOO s rOrN)rtypeobject__mro__)rOrrr _get_mroL srcCsAx:tt|dt|D]}||kr||SqWdS)z2Return an adapter factory for `ob` from `registry`rN)rrr)registryr7rrrr rS s% rcCs8tjj|}tjj|s4tj|ndS)z1Ensure that the parent directory of `path` existsN)rrr"rmakedirs)rr"rrr rwZ sccsd}g}xt|D]|}|jdr|jdrv|sI|rW||fVn|ddj}g}qtd|q|j|qW||fVdS)arSplit a string or iterable thereof into (section,content) pairs Each ``section`` is a stripped version of the section header ("[section]") and each ``content`` is a list of stripped lines excluding blank lines and comment-only lines. If there are any such lines before the first section header, they're returned in a first ``section`` of ``None``. NrM]rzInvalid section headingr)rqrrrrGr)rsectioncontentrrrr rr` s  c OsDddlm}tj}ztt_|||SWd|t_XdS)Nr)mkstemp)tempfilerrros_open)r;r'rold_openrrr ry s   rcCs@x9ttD]+}|jds tt|||s                  '                               1     )           Z  c    !   (           , )n '?   > <