U v_A@sddlZddlmZddlmZmZmZmZddlm Z ddl m Z ddl m Z ddlmZddlmZmZmZdd lmZdd lmZd d lmZd d lmZmZmZmZmZd dl m!Z!d dl"m#Z#m$Z$m%Z%erddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddlm?Z?ddl@mAZAddlBmCZCd dlmDZDmEZEd dlmFZFe0dZGe(e?eGfZHe(e4eDfZIeJeKZLGdddeMZNdS)N)canonicalize_name)DistributionNotFoundInstallationErrorUnsupportedPythonVersionUnsupportedWheel)Wheel)InstallRequirement) get_supported)Hashes)dist_in_site_packagesdist_in_usersiteget_installed_distributions)MYPY_CHECK_RUNNING)running_under_virtualenv) Constraint)AlreadyInstalledCandidateEditableCandidateExtrasCandidate LinkCandidateRequiresPythonCandidate)FoundCandidates)ExplicitRequirementRequiresPythonRequirementSpecifierRequirement) FrozenSetDictIterableIteratorListOptionalSequenceSetTupleTypeVar) SpecifierSet) _BaseVersion) Distribution)ResolutionImpossible) CacheEntry WheelCache) PackageFinder)Link)RequirementPreparer)InstallRequirementProvider) Candidate Requirement) BaseCandidateCc@seZdZd ddZeddZddZd d Zd d Zd dZ ddZ ddZ d!ddZ ddZ ddZddZddZddZdS)"FactoryNFc Csl||_||_||_t| |_||_||_||_||_| |_ i|_ i|_ |sbddt ddD|_ ni|_ dS)NcSsi|]}t|j|qS)r project_name).0distr4r4/builddir/build/BUILDROOT/alt-python38-pip-20.2.4-1.el7.x86_64/opt/alt/python38/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/factory.py gsz$Factory.__init__..F) local_only)_finderpreparer _wheel_cacher_python_candidate_make_install_req_from_spec_use_user_site_force_reinstall_ignore_requires_pythonZuse_lazy_wheel_link_candidate_cache_editable_candidate_cacher _installed_dists) selffinderr<make_install_req wheel_cache use_user_siteforce_reinstallignore_installedignore_requires_pythonpy_version_info lazy_wheelr4r4r8__init__Ks   zFactory.__init__cCs|jSN)rA)rFr4r4r8rKnszFactory.force_reinstallcCs t|||d}|rt||S|S)N)factory)rr)rFr7extrastemplatebaser4r4r8_make_candidate_from_distss z!Factory._make_candidate_from_distcCsr|jr4||jkr(t|||||d|j|<|j|}n,||jkrVt|||||d|j|<|j|}|rnt||S|S)N)rRnameversion)editablerDrrCrr)rFlinkrSrTrWrXrUr4r4r8_make_candidate_from_links,        z!Factory._make_candidate_from_linkc s|sdS|dtjjt|D].}|jjM|jddMt|jOq&d}jsjkrj}j |j ddrj |d}fdd }t |||S) Nr4rF)trust_internetT) prereleases)r7rSrTc3sFjjd}tt|D]}j|j|jdVq"dS)N)r5 specifierhashes)rZrSrTrWrX)r;find_best_candidatereversedlistiter_applicabler[rZrX)resultZicanrSr_rWrFr^rTr4r8iter_index_candidatessz=Factory._iter_found_candidates..iter_index_candidates) rreqrW frozensetr^r_rSrArEcontainsrXrVr) rFireqsr^r_prefers_installedireqZinstalled_candidateZinstalled_distrfr4rer8_iter_found_candidatess0   zFactory._iter_found_candidatesc st}g}D]4}|\}}|dk r0|||dk r||q|s\|||j|j|S|rx|j} t d | fdd|DS)NzhCould not satisfy constraints for {!r}: installation from path or url cannot be constrained to a versionc3s(|] tfddDrVqdS)c3s|]}|VqdSrQ)Zis_satisfied_by)r6rgcr4r8 sz4Factory.find_candidates...N)all)r6 requirementsrnr8rpsz*Factory.find_candidates..) setZget_candidate_lookupaddappendrmr^r_poprWrformat) rFrs constraintrkZexplicit_candidatesrjrgcandrlrWr4rrr8find_candidatess2     zFactory.find_candidatescCs||s td|j|jdS|js.t|S|jjrht|jj }| |j j shd|j }t||j|jt|j||jrt|jnddd}||S)Nz6Ignoring %s: markers '%s' don't match your environmentz-{} is not a supported wheel on this platform.)rSrTrWrX) match_markersloggerinforWmarkersrZris_wheelrfilename supportedr; target_pythonget_tagsrxrr[rhrSrmake_requirement_from_candidate)rFrlrequested_extraswheelmsgrzr4r4r8!make_requirement_from_install_reqs0  z)Factory.make_requirement_from_install_reqcCst|SrQ)r)rF candidater4r4r8rsz'Factory.make_requirement_from_candidater4cCs|||}|||SrQ)r?r)rFr^ comes_fromrrlr4r4r8make_requirement_from_specs z"Factory.make_requirement_from_speccCs|js|dkrdSt||jSrQ)rBrr>)rFr^r4r4r8 make_requires_python_requirement$sz(Factory.make_requires_python_requirementcCs*|jdks|jjrdS|jj||tdS)aLook up the link in the wheel cache. 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 nondeterministic contents due to file modification times. N)rZ package_namesupported_tags)r=r<require_hashesget_cache_entryr )rFrZrWr4r4r8get_wheel_cache_entry*s zFactory.get_wheel_cache_entrycCsV|j|j}|dkrdS|js$|St|r0|StrRt|rRtd|j |j dS)NzVWill not install to the user site because it will lack sys.path precedence to {} in {}) rEgetrWr@r rr rrxr5location)rFrr7r4r4r8get_dist_to_uninstall<szFactory.get_dist_to_uninstallcCs(d}|j|j|jjt|jd}t|S)NzOPackage {package!r} requires a different Python: {version} not in {specifier!r})packagerXr^)rxrWr>rXstrr^r)rF requirementrTZmessage_formatmessager4r4r8_report_requires_python_errorZsz%Factory._report_requires_python_errorc Cs~|jstd|jD]$}t|jtr||j|jSqt|jdkr|jd\}}|dkrht|}nd ||j }t d|t d |Sdd}d d }d d }g} |jD],\}}|dkr|} n||} | | q| r|| } nd } d | } t | d} |jD]B\}}| d} |r<| d |j |j} n| d} | |} q| ddddd} t | t dS)Nz)Installation error reported with no causerrz {} (from {})z:Could not find a version that satisfies the requirement %sz%No matching distribution found for {}cSs2t|dkr|dSd|ddd|dS)Nrrz, z and )lenjoin)partsr4r4r8 text_joins z1Factory.get_installation_error..text_joincSsd|j|jSNz{} {})rxrWrX)rzr4r4r8 readable_formsz5Factory.get_installation_error..readable_formcSsD|}|r|js"d|j|jSt|jtr:t|jjSt|jSr)Zget_install_requirementrrxrWrX isinstancerr)parentrlr4r4r8describe_triggers    z8Factory.get_installation_error..describe_triggerzthe requested packageszOCannot install {} because these package versions have conflicting dependencies.z The conflict is caused by:z z{} {} depends on zThe user requested z zTo fix this you could try to: z91. loosen the range of package versions you've specified z92. remove package versions to allow pip attempt to solve zthe dependency conflict znResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies)ZcausesAssertionErrorrrrrrrrrxrWr}criticalrZformat_for_errorrvrXr~) rFecausergrZreq_disprrrZtriggersZtriggerr~rr4r4r8get_installation_errorkst          zFactory.get_installation_error)NF)r4)__name__ __module__ __qualname__rPpropertyrKrVr[rmr{rrrrrrrrr4r4r4r8r3Js$  #  <& r3)OloggingZpip._vendor.packaging.utilsrpip._internal.exceptionsrrrrpip._internal.models.wheelrZpip._internal.req.req_installr&pip._internal.utils.compatibility_tagsr pip._internal.utils.hashesr pip._internal.utils.miscr r r pip._internal.utils.typingrpip._internal.utils.virtualenvrrUr candidatesrrrrrZfound_candidatesrrsrrrtypingrrrrrr r!r"r#r$Z pip._vendor.packaging.specifiersr%pip._vendor.packaging.versionr&Zpip._vendor.pkg_resourcesr'Zpip._vendor.resolvelibr(pip._internal.cacher)r*"pip._internal.index.package_finderr+pip._internal.models.linkr, pip._internal.operations.preparer-pip._internal.resolution.baser.r/r0r1r2CacheZVersionCandidates getLoggerrr}objectr3r4r4r4r8s>         0