2{Yc@sddlZddlmZddlZddlZddlZddlZddlZyddlZWne k rddl ZnXddl Z ddl m Z ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,dd l-m.Z.m/Z/dd l0m1Z1m2Z2ej3e4Z5ej6d Z7ej6d ej8Z9ej6d Z:dZ;e<dZ=defdYZ>de?fdYZ@de@fdYZAde@fdYZBde?fdYZCde@fdYZDde@fdYZEde@fdYZFd e@fd!YZGd"e@fd#YZHeHeFeDd$d%d&d'd(ZIeIjJZJej6d)ZKd*e?fd+YZLdS(,iN(tBytesIOi(tDistlibException(turljointurlparset urlunparset url2pathnamet pathname2urltqueuetquotetunescapet string_typest build_openertHTTPRedirectHandlertRequestt HTTPErrortURLError(t DistributiontDistributionPatht make_dist(tMetadata(tcached_propertytparse_credentialst ensure_slashtsplit_filenametget_project_datatparse_requirementtparse_name_and_versiont ServerProxy(t get_schemetUnsupportedVersionError(tWheelt is_compatibles^(\w+)=([a-f0-9]+)s;\s*charset\s*=\s*(.*)\s*$stext/html|application/x(ht)?mlshttp://python.org/pypicCs1|dkrt}nt|dd}|jS(s Return all distribution names known by an index. :param url: The URL of the index. :return: A list of all known distribution names. ttimeoutg@N(tNonet DEFAULT_INDEXRt list_packages(turltclient((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytget_all_distribution_names)s  tRedirectHandlercBs%eZdZdZeZZZRS(sE A class to work around a bug in some Python 3.2.x releases. c Csd}x(dD] }||kr ||}Pq q W|dkrAdSt|}|jdkrt|j|}t|dr|j||q|||= 1.0, < 2.0, != 1.3)' :param prereleases: If ``True``, allow pre-release versions to be located. Otherwise, pre-release versions are not returned. :return: A :class:`Distribution` instance, or ``None`` if no such distribution could be located. sNot a valid requirement: %rsmatcher: %s (%s)s%s did not match %rs%skipping pre-release version %s of %sserror matching %s with %riR8ssorted list: %siN(R!RRRR,RDt requirementRYRZttypeR:RQRMt version_classRot is_prereleasetappendRvRwRytsortedR8textras( R1Rt prereleasesRPtrR,RDtversionstslisttvclstk((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytlocate7s>        (s.tar.gzs.tar.bz2s.tars.zips.tgzs.tbz(s.eggs.exes.whl(s.pdfN(s.whl(R:R;R<tsource_extensionstbinary_extensionstexcluded_extensionsR!RrRxRERGRIRKtpropertyR,RNRORQRXR_RRRRtFalseR(((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyR@Ss*          M  tPyPIRPCLocatorcBs)eZdZdZdZdZRS(s This locator uses XML-RPC to locate distributions. It therefore cannot be used with simple mirrors (that only mirror file content). cKs8tt|j|||_t|dd|_dS(s Initialise an instance. :param url: The URL to use for XML-RPC. :param kwargs: Passed to the superclass constructor. R g@N(tsuperRREtbase_urlRR%(R1R$tkwargs((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyREms cCst|jjS(sJ Return all the distribution names known to this locator. (tsetR%R#(R1((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyROxsc Csi}|jj|t}x|D]}|jj||}|jj||}td|j}|d|_|d|_|j d|_ |j dg|_ |j d|_ t |}|r"|d} | d|_|j| |_||_|||[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*))\s+)? href\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)) (\s+rel\s*=\s*(?:"(?P[^"]*)"|'(?P[^']*)'|(?P[^>\s ]*)))? s!]+)cCsM||_||_|_|jj|j}|rI|jd|_ndS(sk Initialise an instance with the Unicode page contents and the URL they came from. iN(RRR$t_basetsearchtgroup(R1RR$R}((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyREs  s[^a-z0-9$&+,/:;=?@.#%_\\|-]c Csd}t}x|jj|jD]}|jd}|dpv|dpv|dpv|dpv|dpv|d}|d p|d p|d }t|j|}t|}|jj d |}|j ||fq(Wt |d ddt }|S(s Return the URLs of all the links on a page together with information about their "rel" attribute, for determining which ones to treat as downloads and which ones to queue for further scraping. cSs@t|\}}}}}}t||t||||fS(sTidy up an URL.(RRR(R$R,RSRVRzR{R|((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytcleansR*trel1trel2trel3trel4trel5trel6R[R\turl3cSsdt|jdS(Ns%%%2xi(tordR(R}((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytsR8cSs|dS(Ni((RW((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRstreverse( Rt_hreftfinditerRt groupdictRRR t _clean_retsubtaddRRe(R1RRPRoRtrelR$((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytlinkss   (R:R;R<tretcompiletItStXRRRERRR(((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRs tSimpleScrapingLocatorcBseZdZiejd6dd6dd6ZdddZdZd Z d Z e j d e j Zd Zd ZdZdZdZe j dZdZRS(s A locator which scrapes HTML pages to locate downloads for a distribution. This runs multiple threads to do the I/O; performance is at least as good as pip's PackageFinder, which works in an analogous fashion. tdeflatecCstjdttjS(Ntfileobj(tgziptGzipFileRRR(tb((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRsRcCs|S(N((R((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRstnonei cKstt|j|t||_||_i|_t|_t j |_ t|_ t |_||_tj|_tj|_dS(s Initialise an instance. :param url: The root URL to use for scraping. :param timeout: The timeout, in seconds, to be applied to requests. This defaults to ``None`` (no timeout specified). :param num_workers: The number of worker threads you want to do I/O, This defaults to 10. :param kwargs: Passed to the superclass. N(RRRERRR t _page_cacheRt_seenRtQueuet _to_fetcht _bad_hostsRtskip_externalst num_workerst threadingtRLockt_lockt_gplock(R1R$R RR((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyREs       cCscg|_xSt|jD]B}tjd|j}|jt|j|jj |qWdS(s Threads are created only when get_project is called, and terminate before it returns. They are there primarily to parallelise I/O (i.e. fetching web pages). ttargetN( t_threadstrangeRRtThreadt_fetcht setDaemonRetstartR(R1tiRW((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyt_prepare_threadss    cCsOx!|jD]}|jjdq Wx|jD]}|jq.Wg|_dS(su Tell all the threads to terminate (by sending a sentinel value) and wait for them to do so. N(RRtputR!Rs(R1RW((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyt _wait_threads,s c Csi}|j||_||_t|jdt|}|jj|jj|j z1t j d||j j ||j jWd|jX|`WdQX|S(Ns%s/s Queueing %s(RRPRaRRRRRFRRRYRZRRRsR(R1RMRPR$((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRN9s        s<\b(linux-(i\d86|x86_64|arm\w+)|win(32|-amd64)|macosx-?\d+)\bcCs|jj|S(sD Does an URL refer to a platform-specific download? (tplatform_dependentR(R1R$((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyt_is_platform_dependentNscCsp|j|rd}n|j||j}tjd|||rl|j|j|j|WdQXn|S(s% See if an URL is a suitable download for a project. If it is, register information in the result dictionary (for _get_project) about the specific version it's for. Note that the return value isn't actually used other than as a boolean value. sprocess_download: %s -> %sN( RR!RRaRYRZRRRP(R1R$R((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyt_process_downloadTs   c Cst|\}}}}}}|j|j|j|jrGt}n|jrl|j|j rlt}n|j|jst}ny|d krt}nd|d krt}nO|j |rt}n7|j ddd} | j d krt}nt }t jd |||||S( s Determine whether a link URL from a referring page and with a particular "rel" attribute should be queued for scraping. thomepagetdownloadthttpRRtftpt:iit localhosts#should_queue: %s (%s) from %s -> %s(RR(RshttpsR(RRqRRRRRRmRRtsplitRdReRYRZ( R1tlinktreferrerRR,RSRVRbRPthost((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyt _should_queuehs*           cCsxtr|jj}z|r|j|}|dkrBwnx|jD]y\}}||jkrL|jj||j| r|j |||rt j d|||jj |qqLqLWnWd|jj X|sPqqWdS(s Get a URL to fetch from the work queue, get the HTML page, examine its links for download candidates and candidates for further scraping. This is a handy method to run in a thread. sQueueing %s from %sN(ReRRtget_pageR!RRRRRRYRZRt task_done(R1R$tpageRR((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyRs"  !cCst|\}}}}}}|dkrZtjjt|rZtt|d}n||jkr|j|}tj d||nK|j ddd}d}||j krtj d||n t |did d 6}zy7tj d ||jj|d |j} tj d || j} | jdd} tj| r| j} | j} | jd}|r|j|}|| } nd}tj| }|r|jd}ny| j|} Wn tk r| jd} nXt| | }||j| ]*>([^<]+)[\w-]+)\s*\(\s*(==\s*)?(?P[^)]+)\)$tDependencyFindercBsVeZdZddZdZdZdZdZdZ de dZ RS( s0 Locate dependencies for distributions. cCs(|p t|_t|jj|_dS(sf Initialise an instance, using the specified locator to locate distributions. N(tdefault_locatorRRR,(R1R((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyREscCstjd||j}||j|<||j||jf= 1.0) while C requires (B >= 1.1). For successful replacement, ``provider`` must meet all the requirements which ``other`` fulfills. :param provider: The provider we are trying to replace with. :param other: The provider we're trying to replace. :param problems: If False is returned, this will contain what problems prevented replacement. This is currently a tuple of the literal string 'cantreplace', ``provider``, ``other`` and the set of requirements that ``provider`` couldn't fulfill. :return: True if we can replace ``other`` with ``provider``, else False. t cantreplace( treqtsRRBRoRkRRR@R;R=Re( R1RCtothertproblemstrlistt unmatchedR?RDRP((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyttry_to_replaces        # c Csi|_i|_i|_i|_t|p0g}d|krk|jd|tdddgO}nt|tr|}}tj d|nK|j j |d|}}|dkrt d|ntj d|t|_t}t|g}t|g}x|r|j}|j} | |jkrO|j|n/|j| } | |kr~|j|| |n|j|jB} |j} t} ||krxAdD]6}d |}||kr| t|d |O} qqWn| | B| B}x|D]}|j|}|s+tj d||j j |d|}|dkrv| rv|j j |dt}n|dkrtj d||jd|fq+|j|j}}||f|jkr|j|n|j||| kr+||kr+|j|tj d|jq+nxw|D]o}|j} | |jkrr|jj|tj|q2|j| } | |kr2|j|| |q2q2WqWqWt|jj}x<|D]4}||k|_|jrtj d|jqqWtj d|||fS(s Find a distribution and all distributions it depends on. :param requirement: The requirement specifying the distribution to find, or a Distribution instance. :param meta_extras: A list of meta extras such as :test:, :build: and so on. :param prereleases: If ``True``, allow pre-release versions to be returned - otherwise, don't return prereleases unless they're all that's available. Return a set of :class:`Distribution` instances and a set of problems. The distributions returned should be such that they have the :attr:`required` attribute set to ``True`` if they were from the ``requirement`` passed to ``find()``, and they have the :attr:`build_time_dependency` attribute set to ``True`` unless they are post-installation dependencies of the ``requirement``. The problems should be a tuple consisting of the string ``'unsatisfied'`` and the requirement which couldn't be satisfied by any distribution known to the locator. s:*:s:test:s:build:s:dev:spassed %s as requirementRsUnable to locate %rs located %sttesttbuildtdevs:%s:s %s_requiressNo providers found for %rsCannot satisfy %rt unsatisfiedsAdding %s to install_distss#%s is a build-time dependency only.sfind done for %sN(RLsbuildRN(R:R8R7RFRR>R*RRYRZRRR!RRet requestedRR8R=RKt run_requirest meta_requirestbuild_requirestgetattrRDRRktname_and_versionR;tvaluestbuild_time_dependency(R1Rt meta_extrasRRtodistRHttodot install_distsRMRGtireqtstsreqtstereqtsR8Rt all_reqtsRt providersRCtnRR<R8((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytfind>s                      !       "  "   N( R:R;R<R!RER=R@RBRDRKRRb(((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pyR5s      '(MRtioRRtloggingRRTRRt ImportErrortdummy_threadingRR*RtcompatRRRRRRRR R R R R/R RRtdatabaseRRRRRtutilRRRRRRRRRkRRRRRt getLoggerR:RYRRnRR R R"R!R&R'tobjectR@RRRRRR!R)R.R6RtNAME_VERSION_RER5(((sM/opt/alt/python33/lib/python3.3/site-packages/pip/_vendor/distlib/locators.pytsV        ^: +*:A%N