ó â\e[c@sÉdZddlZddlmZddlmZddlmZmZm Z m Z m Z ddl m Z ddlmZddlmZmZdd lmZejeƒZd efd „ƒYZdS( syDependency Resolution The dependency resolution in pip is performed as follows: for top-level requirements: a. only one spec allowed per project, regardless of conflicts or not. otherwise a "double requirement" exception is raised b. they override sub-dependency requirements. for sub-dependencies a. "first found, wins" (where the order is breadth first) iÿÿÿÿN(t defaultdict(tchain(tBestVersionAlreadyInstalledtDistributionNotFoundt HashErrort HashErrorstUnsupportedPythonVersion(tInstallRequirement(t indent_log(tdist_in_usersitet ensure_dir(tcheck_dist_requires_pythontResolvercBseeZdZdddhZd„Zd„Zd„Zd„Zd„Zd „Z d „Z d „Z RS( s–Resolves which packages need to be installed/uninstalled to perform the requested operation without breaking the requirements of any package. teagersonly-if-neededsto-satisfy-onlyc Cs§tt|ƒjƒ| |jks(t‚||_||_||_||_d|_ | |_ | |_ | |_ ||_||_||_||_ttƒ|_dS(N(tsuperR t__init__t_allowed_strategiestAssertionErrortpreparertfindertsessiont wheel_cachetNonetrequire_hashestupgrade_strategytforce_reinstalltisolatedtignore_dependenciestignore_installedtignore_requires_pythont use_user_siteRtlistt_discovered_dependencies( tselfRRRRRRRRRRR((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyR$s            cCs|jjrt|jjƒn|jt|jjƒƒ}|jpWtd„|Dƒƒ|_|j j ƒ}|r‚t j |ƒng}t ƒ}x`t||ƒD]O}y|j|j||ƒƒWq¡tk rï}||_|j|ƒq¡Xq¡W|r|‚ndS(s±Resolve what operations need to be done As a side-effect of this method, the packages (and their dependencies) are downloaded, unpacked and prepared for installation. This preparation is done by ``pip.operations.prepare``. Once PyPI has static dependency metadata available, it would be possible to move the preparation to become a step separated from dependency resolution. css|]}|jVqdS(N(thas_hash_options(t.0treq((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pys UsN(Rtwheel_download_dirR tunnamed_requirementsRt requirementstvaluesRtanyRtget_formatted_locationstloggertinfoRRtextendt _resolve_oneRR$tappend(R!trequirement_sett root_reqst locationstdiscovered_reqst hash_errorsR$texc((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pytresolve>s(    cCsF|jdkrtS|jdkr&tS|jdks;t‚|jSdS(Nsto-satisfy-onlyR sonly-if-needed(RtFalsetTrueRt is_direct(R!R$((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyt_is_upgrade_allowedos cCs5|j st|jƒr(|j|_nd|_dS(s4 Set a requirement to be installed. N(RR t satisfied_bytconflicts_withR(R!R$((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyt_set_req_to_reinstallxscCsÆ|jr dS|j|jƒ|js*dS|jrD|j|ƒdS|j|ƒsj|jdkrfdSdS|j sµy|j j |dt ƒWqµt k r¡dStk r±qµXn|j|ƒdS(sCheck if req_to_install should be skipped. This will check if the req is installed, and whether we should upgrade or reinstall it, taking into account all the relevant user options. After calling this req_to_install will only have satisfied_by set to None if the req_to_install is to be upgraded/reinstalled etc. Any other value will be a dist recording the current thing installed that satisfies the requirement. Note that for vcs urls and the like we can't assess skipping in this routine - we simply identify that we need to pull the thing down, then later on it is pulled down and introspected to assess upgrade/ reinstalls etc. :return: A text reason for why it was skipped, or None. sonly-if-neededs#already satisfied, skipping upgradesalready satisfiedtupgradesalready up-to-dateN(RRtcheck_if_existsRR;RR=R:RtlinkRtfind_requirementR8RR(R!treq_to_install((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyt_check_skip_installedƒs*        cCsG|jdk stdƒ‚|jrF|jj||j|j|jƒS|jdks[t‚|j |ƒ}|jrŒ|jj ||j|ƒS|j |ƒ}|jj ||j |j||jƒ}|jsÞ|j|jƒn|jrC|jdkp|jp|jp|jjdk}|r0|j|ƒqCtjd|ƒn|S(szTakes a InstallRequirement and returns a single AbstractDist representing a prepared variant of the same. s9require_hashes should have been set in Resolver.resolve()sto-satisfy-onlytfiles<Requirement already satisfied (use --upgrade to upgrade): %sN(RRRteditableRtprepare_editable_requirementRRR;RCtprepare_installed_requirementR:tprepare_linked_requirementRRR?RRR@tschemeR=R+R,(R!R$t skip_reasontupgrade_allowedt abstract_distt should_modify((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyt_get_abstract_dist_for·s6           c sçˆjsˆjrgStˆ_ˆjjˆƒˆjˆƒ}|jˆjƒ}yt|ƒWn6t k r–}ˆj rt j |j dƒq—‚nXg‰‡‡‡‡fd†}tƒ#ˆjˆjƒsðtˆ_ˆjˆddƒnˆjs¶ˆjr!t jddjˆjƒƒnttˆjƒt|jƒƒ}x!|D]}t j d||ƒqJWtt|jƒtˆjƒ@ƒ} x*|j| ƒD]} || d| ƒq™Wnˆj r݈j r݈jjˆƒnWdQXˆS( sxPrepare a single requirements file. :return: A list of additional InstallRequirements to also install. icsˆtjt|ƒˆdˆjdˆjƒ}ˆj}ˆj|d|d|ƒ\}}|rw|rwˆj|j|ƒnˆj |ƒdS(NRRtparent_req_nametextras_requested( Rtfrom_reqtstrRRtnametadd_requirementR R/R-(tsubreqRPtsub_install_reqROt to_scan_againt add_to_parent(t more_reqsRBR0R!(s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pytadd_reqs       ROs!Installing extra requirements: %rt,s"%s does not provide the extra '%s'RPN(t constrainttpreparedR8treqs_to_cleanupR/RNtdistRR RRR+twarningtargsRthas_requirementRSR9RTRRtextrastdebugtjointsortedtsettrequiresRER;tsuccessfully_downloaded( R!R0RBRLR_terrRZtmissing_requestedtmissingtavailable_requestedRU((RYRBR0R!s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyR.ðsJ       csOg‰tƒ‰‡‡‡‡fd†‰x!|jjƒD]}ˆ|ƒq7WˆS(säCreate the installation order. The installation order is topological - requirements are installed before the requiring thing. We break cycles at an arbitrary point, and make no other guarantees. csi|js|ˆkrdS|jr&dSˆj|ƒx"ˆj|jD]}ˆ|ƒqDWˆj|ƒdS(N(R;R\taddR RSR/(R$tdep(tordert ordered_reqstscheduleR!(s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyRrUs  (RgR'R((R!treq_sett install_req((RpRqRrR!s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pytget_installation_orderHs   ( t__name__t __module__t__doc__RRR6R:R=RCRNR.Ru(((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyR s  1 4 9 X(Rxtloggingt collectionsRt itertoolsRtpip._internal.exceptionsRRRRRtpip._internal.req.req_installRtpip._internal.utils.loggingRtpip._internal.utils.miscR R tpip._internal.utils.packagingR t getLoggerRvR+tobjectR (((s4/tmp/pip-install-0xiv62/pip/pip/_internal/resolve.pyt s (