U n aD@s^dZddlZddlZddlmZddlmZddlmZddl m Z m Z m Z m Z mZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZdd lmZer6ddlm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddlm1Z1e e2e!e0fZ3e4e5Z6dddZ7GdddeZ8dS)ayDependency 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) N) defaultdict)chain) specifiers)BestVersionAlreadyInstalledDistributionNotFound HashError HashErrorsUnsupportedPythonVersion)RequirementSet) BaseResolver) get_supported) indent_log)dist_in_usersitenormalize_version_info)check_requires_pythonget_requires_python)MYPY_CHECK_RUNNING) DefaultDictListOptionalSetTuple) pkg_resources) WheelCache)AbstractDistribution) PackageFinder)RequirementPreparer)InstallRequirement)InstallRequirementProviderFc Cst|}zt||d}Wn:tjk rR}ztd|j|WYdSd}~XYnX|r\dSdtt |}|rt d|j||dSt d |j||dS)a Check whether the given Python version is compatible with a distribution's "Requires-Python" value. :param version_info: A 3-tuple of ints representing the Python major-minor-micro version to check. :param ignore_requires_python: Whether to ignore the "Requires-Python" value if the given Python version isn't compatible. :raises UnsupportedPythonVersion: When the given Python version isn't compatible. ) version_infoz-Package %r has an invalid Requires-Python: %sN.zBIgnoring failed Requires-Python check for package %r: %s not in %rz8Package {!r} requires a different Python: {} not in {!r}) rrrInvalidSpecifierloggerwarning project_namejoinmapstrdebugr format)distrignore_requires_pythonrequires_python is_compatibleexcversionr0iC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\resolution\legacy\resolver.py_check_dist_requires_python:s> r2csleZdZdZdddhZdfdd Zdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ZS)ResolverzResolves which packages need to be installed/uninstalled to perform the requested operation without breaking the requirements of any package. eageronly-if-neededto-satisfy-onlyNc stt|| |jkst| dkr4tjdd} nt| } | |_||_ ||_ ||_ | |_ | |_ ||_||_||_||_||_tt|_dS)N)superr3__init___allowed_strategiesAssertionErrorsysrr_py_version_infopreparerfinder wheel_cacheupgrade_strategyforce_reinstallignore_dependenciesignore_installedr+ use_user_site_make_install_reqrlist_discovered_dependencies) selfr>r?r@make_install_reqrErCrDr+rBrApy_version_info __class__r0r1r9qs$zResolver.__init__c Cst|d}|D]}||qg}t}t||D]N}z||||Wq2tk r~}z||_||W5d}~XYq2Xq2|r||S)aResolve 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. )check_supported_wheelsN) r add_requirementrrextend _resolve_onerreqappend)rI root_reqsrNrequirement_setrRdiscovered_reqs hash_errorsr.r0r0r1resolves  zResolver.resolvecCs4|jdkrdS|jdkrdS|jdks*t|jSdS)Nr6Fr4Tr5)rAr; is_directrIrRr0r0r1_is_upgrade_alloweds   zResolver._is_upgrade_allowedcCs |jrt|jrd|_d|_dS)z4 Set a requirement to be installed. TN)rEr satisfied_byshould_reinstallrZr0r0r1_set_req_to_reinstallszResolver._set_req_to_reinstallcCs|jr dS||j|js dS|jr4||dS||sP|jdkrLdSdS|jsz|j j |ddWn(t k rYdSt k rYnX||dS)aCheck 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. Nr5z#already satisfied, skipping upgradezalready satisfiedT)upgradezalready up-to-date) rDcheck_if_existsrEr\rBr^r[rAlinkr?find_requirementrr)rIreq_to_installr0r0r1_check_skip_installeds*     zResolver._check_skip_installedcCs||}|jdkr$|j|||_|jdks6|jjr:dS|jj|j|jt d}|dk rt d|j|j|j kr|j rd|_|j|_dS)afEnsure that if a link can be found for this, that it is found. Note that req.link may still be None - if the requirement is already installed and not needed to be upgraded based on the return value of _is_upgrade_allowed(). If preparer.require_hashes is True, don't use the wheel cache, because cached wheels, always built locally, have different hashes than the files downloaded from the index server and thus throw false hash mismatches. Furthermore, cached wheels at present have undeterministic contents due to file modification times. N)ra package_namesupported_tagszUsing cached wheel link: %sT)r[rar?rbr@r>require_hashesget_cache_entrynamer r"r( original_link persistentoriginal_link_is_in_wheel_cache)rIrRr_ cache_entryr0r0r1_populate_links  zResolver._populate_linkcCs|jr|j|S|jdks t||}|jr>|j||S|||j|}|j sf| |j |jr|j dkp|j p|j p|jjdk}|r||n td||S)zzTakes a InstallRequirement and returns a single AbstractDist representing a prepared variant of the same. Nr6filezprepare_editable_requirementr\r;rdprepare_installed_requirementrnprepare_linked_requirementrDr`rErArBraschemer^r"info)rIrR skip_reason abstract_dist should_modifyr0r0r1_get_abstract_dist_for&s8        zResolver._get_abstract_dist_forc s&js jrgSd_}|}t|jjdgfdd}tj s|j snt j ddj sjrtddjttjt|j}|D]}td ||qtt|jtj@}||D]} || |d qjsjsd_W5QRXS) zxPrepare a single requirements file. :return: A list of additional InstallRequirements to also install. T)rr+csPt|}j}j|||d\}}|rB|rBj|||dS)N)parent_req_nameextras_requested)rFr'rirOrHrSrP)subreqr{sub_install_reqrz to_scan_again add_to_parent more_reqsrcrUrIr0r1add_reqws  z&Resolver._resolve_one..add_reqN)rzz!Installing extra requirements: %r,z"%s does not provide the extra '%s')r{) constraintpreparedryget_pkg_resources_distributionr2r=r+r has_requirementrirYr;rOrCextrasr"r(r%sortedsetr#requiresrpr\successfully_downloaded) rIrUrcrwr*rmissing_requestedmissingavailable_requestedr|r0rr1rQXsT     zResolver._resolve_onecs8gtfdd|jD] }|q&S)zCreate 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. csN|js|krdS|jrdS|j|jD] }|q2|dS)N)r\raddrHrirS)rRdeporder ordered_reqsschedulerIr0r1rs  z1Resolver.get_installation_order..schedule)r requirementsvalues)rIreq_set install_reqr0rr1get_installation_orders   zResolver.get_installation_order)N)__name__ __module__ __qualname____doc__r:r9rXr[r^rdrnryrQr __classcell__r0r0rLr1r3js ($  52Yr3)F)9rloggingr< collectionsr itertoolsrZpip._vendor.packagingrpip._internal.exceptionsrrrrr Zpip._internal.req.req_setr pip._internal.resolution.baser &pip._internal.utils.compatibility_tagsr pip._internal.utils.loggingr pip._internal.utils.miscrrpip._internal.utils.packagingrrpip._internal.utils.typingrtypingrrrrr pip._vendorrpip._internal.cacherpip._internal.distributionsr"pip._internal.index.package_finderr pip._internal.operations.preparerZpip._internal.req.req_installrrr'ZDiscoveredDependencies getLoggerrr"r2r3r0r0r0r1s6                 0