a lj'j@s:ddlZddlZddlZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZddlmZmZddlmZddlmZmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%dd l&m'Z'dd l(m)Z)dd l*m+Z+m,Z,dd l-m.Z.dd l/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7ddl8m9Z9ddl:m;Z;ddlm?Z?ddl@mAZAddlBmCZCddlDmEZEmFZFmGZGmHZHddlImJZJmKZKmLZLmMZMmNZNmOZOmPZPddlQmRZRmSZSddlTmUZUmVZVmWZWmXZXerddlmYZYGdddeYZZe[e\Z]edZ^ee.e^fZ_Gd d!d!e Z`Gd"d#d#ZadS)$N) TYPE_CHECKINGDict FrozenSetIterableIteratorListMapping NamedTupleOptionalSequenceSetTupleTypeVarcast)InvalidRequirement) SpecifierSet)NormalizedNamecanonicalize_name)ResolutionImpossible) CacheEntry WheelCache)DistributionNotFoundInstallationErrorInstallationSubprocessErrorMetadataInconsistentUnsupportedPythonVersionUnsupportedWheel) PackageFinder) get_scheme)BaseDistributionget_default_environment)Link)Wheel)RequirementPreparer)install_req_from_link_and_ireq)InstallRequirementcheck_invalid_constraint_type)InstallRequirementProvider) get_supported)Hashes) dist_location)get_requirement)running_under_virtualenv) CandidateCandidateVersion Constraint Requirement)AlreadyInstalledCandidate BaseCandidateEditableCandidateExtrasCandidate LinkCandidateRequiresPythonCandidateas_base_candidate)FoundCandidatesIndexCandidateInfo)ExplicitRequirementRequiresPythonRequirementSpecifierRequirementUnsatisfiableRequirement)Protocolc@seZdZUeed<eed<dS) ConflictCause requirementparentN)__name__ __module__ __qualname__r<__annotations__r.rGrGO/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.pyr@Ks r@Cc@s:eZdZUeeed<eeefed<eee fed<dS)CollectedRootRequirements requirements constraintsuser_requestedN) rCrDrErr1rFrstrr0intrGrGrGrHrJVs  rJc @s*eZdZdAeeeeeeeeeee e dfdd ddZ e edddZ edd d d Zeeeed d dZeeeeedddZeeeeeeeeeedddZeeeeeee e edddZ!e e"eee#edddZ$ee%ee#edddZ&ee'ee e"fe'ee#efe%ee eddd Z(ee eee"d!d"d#Z)e*ee+d$d%d&Z,ee-d'd(d)Z.dBeeee eee"d+d,d-Z/eee"d.d/d0Z0eeeee1d1d2d3Z2eeed'd4d5Z3ed6e4d7d8d9Z5e"eee6d:d;d<Z7d=e8ee%fe9d>d?d@Z:dS)CFactoryN.) finderpreparermake_install_req wheel_cache use_user_siteforce_reinstallignore_installedignore_requires_pythonpy_version_inforeturnc Cs||_||_||_t| |_||_||_||_||_i|_ i|_ i|_ i|_ i|_ |svt} dd| jddD|_ni|_dS)NcSsi|] }|j|qSrG)canonical_name).0distrGrGrH |sz$Factory.__init__..F)Z local_only)_finderrR _wheel_cacher7_python_candidate_make_install_req_from_spec_use_user_site_force_reinstall_ignore_requires_python_build_failures_link_candidate_cache_editable_candidate_cache_installed_candidate_cache_extras_candidate_cacher Ziter_installed_distributions_installed_dists) selfrQrRrSrTrUrVrWrXrYenvrGrGrH__init__]s(   zFactory.__init__rZcCs|jSN)rdrlrGrGrHrVszFactory.force_reinstall)linkrZcCsB|js dSt|j}||jjr*dS|jd}t|dS)Nz+ is not a supported wheel on this platform.)Zis_wheelr"filenameZ supportedr_Z target_pythonZget_tagsr)rlrrZwheelmsgrGrGrH"_fail_if_link_is_unsupported_wheels  z*Factory._fail_if_link_is_unsupported_wheel)baseextrasrZcCsFt||f}z|j|}Wn&ty@t||}||j|<Yn0|Srp)idrjKeyErrorr5)rlrvrwZ cache_key candidaterGrGrH_make_extras_candidates   zFactory._make_extras_candidate)r]rwtemplaterZcCsRz|j|j}Wn,ty<t|||d}||j|j<Yn0|sF|S|||S)N)factory)rir[ryr2r{)rlr]rwr|rvrGrGrH_make_candidate_from_dists z!Factory._make_candidate_from_dist)rrrwr|nameversionrZc Cs||jvrdS|jr||jvr~zt|||||d|j|<WnBttfy|}z&td||||j|<WYd}~dSd}~00|j|}nx||jvrzt |||||d|j|<WnDttfy}z&td||||j|<WYd}~dSd}~00|j|}|s |S| ||S)N)r}rrzDiscarding %s. %s) rfZeditablerhr4rrloggerZwarningrgr6r{)rlrrrwr|rrervrGrGrH_make_candidate_from_linksD       z!Factory._make_candidate_from_link)ireqs specifierhashesprefers_installedincompatible_idsrZc s|sdS|djsJdtjjt|D]<}|jsFJd|jjM|jddMt|jOq4ttdfdd }t t dfd d }t |||S) NrGrz)Candidates found on index must be PEP 508F)Ztrust_internetrocsfjr dSzj}Wnty,YdS0j|jddsBdSj|d}t|vrbdS|S)z6Get the candidate for the currently-installed version.NT)Z prereleases)r]rwr|)rdrkrycontainsrr~rx)Zinstalled_distrz)rwrrrlrr|rGrH_get_installed_candidates   z@Factory._iter_found_candidates.._get_installed_candidatec 3sxjjd}t|}tdd|D}t|D]:}|sJ|jjrJq8tj j |j|j d}|j |fVq8dS)N) project_namerrcss|]}|jjVqdSrp)rr is_yanked)r\icanrGrGrH zUFactory._iter_found_candidates..iter_index_candidate_infos..)rrrwr|rr) r_Zfind_best_candidatelistZiter_applicableallreversedrrr functoolspartialrr)resultZicansZ all_yankedrfunc)rwrrrlrr|rGrHiter_index_candidate_infoss&   zBFactory._iter_found_candidates..iter_index_candidate_infos) reqrr frozensetrrrwr r.rr:r9) rlrrrrrireqrrrG)rwrrrrlrr|rH_iter_found_candidatess&    zFactory._iter_found_candidates)base_requirementsrwrZccsJ|D]@}|\}}|durqt|}|dus6Jd|||VqdS)a8Produce explicit candidates from the base given an extra-ed package. :param base_requirements: Requirements known to the resolver. The requirements are guaranteed to not have extras. :param extras: The extras to inject into the explicit requirements' candidates. Nzno extras here)get_candidate_lookupr8r{)rlrrwrZ lookup_cand_Z base_candrGrGrH#_iter_explicit_candidates_from_base1s  z+Factory._iter_explicit_candidates_from_base) identifier constraintr|rZccsD|jD]8}|||j|tt||t|dd}|r|VqdS)zProduce explicit candidates from constraints. This creates "fake" InstallRequirement objects that are basically clones of what "should" be the template, but with original_link set to link. Nrwr|rr)Zlinksrurrr$r)rlrrr|rrrzrGrGrH!_iter_candidates_from_constraintsGs  z)Factory._iter_candidates_from_constraints)rrKincompatibilitiesrrrZc st}g}D]4}|\} } | dur4|| | dur|| qtt:t} ||  | j dt | j Wdn1s0Y|rz||j|ddWntyYdS0dd| dD|s||jj|Sfdd|DS)NrGr)r|cSsh|] }t|qSrG)rxr\crGrGrH rz*Factory.find_candidates..c3sB|]:tvrrtfddDrVqdS)c3s|]}|VqdSrp)is_satisfied_by)r\rrrGrHrrz4Factory.find_candidates...N)rxrr)r\rrZ incompat_idsrKrrHrs   z*Factory.find_candidates..)setraddappend contextlibsuppressrr+updatergetrrrwrrrrr) rlrrKrrrZexplicit_candidatesrrcandrZparsed_requirementrGrrHfind_candidates^sN       "  zFactory.find_candidates)rrequested_extrasrZcCs||s td|j|jdS|js.t|S||j|j|jt |j ||jr\t |jnddd}|dur|js|j |jt t |jS||S)Nz6Ignoring %s: markers '%s' don't match your environmentr) match_markersrinforZmarkersrrr=rurrrwrrfr>make_requirement_from_candidate)rlrrrrGrGrH"_make_requirement_from_install_reqs,   z*Factory._make_requirement_from_install_req) root_ireqsrZcCstgii}t|D]\}}|jrt|}|r6t||s@q|jsNJdt|j}||jvrv|j||M<qt ||j|<q|j |dd}|durq|j r|j|j vr||j |j<|j|q|S)NzConstraint must be namedrG)r)rJ enumeraterr&rrrrrLr0Z from_ireqrZ user_suppliedrMrKr)rlrZ collectedirZproblemrrrGrGrHcollect_root_requirementss.    z!Factory.collect_root_requirements)rzrZcCst|Srp)r;)rlrzrGrGrHrsz'Factory.make_requirement_from_candidaterG)r comes_fromrrZcCs|||}|||Srp)rbr)rlrrrrrGrGrHmake_requirement_from_specs z"Factory.make_requirement_from_spec)rrZcCs"|jr dSt|sdSt||jSrp)rerNr<ra)rlrrGrGrH make_requires_python_requirements z(Factory.make_requires_python_requirement)rrrrZcCs*|jdus|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)rrZ package_nameZsupported_tags)r`rRZrequire_hashesZget_cache_entryr()rlrrrrGrGrHget_wheel_cache_entrys zFactory.get_wheel_cache_entrycCs|j|j}|durdSt|jtdtjdjtdtjdj fvrHdS|j sR|S|j r\|St r|j rd|jd|j}t|dS)N)prefixzNWill not install to the user site because it will lack sys.path precedence to z in )rkrrr*Z_distrsys base_prefixZpurelibZplatlibrcZ in_usersiter,Zin_site_packagesZraw_namelocationr)rlrzr]messagerGrGrHget_dist_to_uninstalls* zFactory.get_dist_to_uninstallr@)causesrZcCs|s Jd|jj}t|dkrVt|djj}d|djjd|d|}t|Sd|d}|D]0}|j }t|jj}|d |d |d 7}qft|S) Nz,Requires-Python error reported with no causer-rzPackage z requires a different Python: z not in z%Packages require a different Python. z not in: z (required by )) rarlenrNrArrBrrformat_for_error)rlrrrrcausepackagerGrGrH_report_requires_python_error1s"     z%Factory._report_requires_python_error)rrBrZcCs|durt|}n|d|jd}|j|j}ddtdd|DD}td|d|pbd t|d kr|t d t d |S) Nz (from rcSsg|] }t|qSrG)rN)r\vrGrGrH Prz?Factory._report_single_requirement_conflict..cSsh|] }|jqSrG)rrrGrGrHrPrz>Factory._report_single_requirement_conflict..zNCould not find a version that satisfies the requirement %s (from versions: %s), Znonezrequirements.txtzHINT: You are attempting to install a package literally named "requirements.txt" (which cannot exist). Consider using the '-r' flag to install the packages listed in requirements.txtz#No matching distribution found for ) rNrr_Zfind_all_candidatesrsortedrcriticaljoinrr)rlrrBZreq_dispZcandsZversionsrGrGrH#_report_single_requirement_conflictGs   z+Factory._report_single_requirement_conflictz,ResolutionImpossible[Requirement, Candidate])rrLrZcs|jsJdfdd|jD}|r6td|St|jdkrh|jd\}}|j|vrh||Stttddd }ttd d d }t }|jD],\}}|dur| } n||} | | q|r|t |} nd } d | } t| d} t } |jD]^\}}|j|vr | |j| d} |rH| |jd|jd} n| d} | | } q| D]"} || j}| d| |7} qd| ddddd} t| tdS)Nz)Installation error reported with no causecs*g|]"}t|jtr|jjs|qSrG) isinstancerAr<rra)r\rrqrGrHrls z2Factory.get_installation_error..zSequence[ConflictCause]r-r)partsrZcSs2t|dkr|dSd|ddd|dS)Nr-rrz and )rr)rrGrGrH text_joins z1Factory.get_installation_error..text_join)rBrZcSsF|}|r|js$|jd|jSt|jtr.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% The user requested (constraint) 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)rrrrrrrrNr.rrrrformatrrrrrr)rlrrLZrequires_python_causesrrBrrZtriggersZtriggerrrtZrelevant_constraintskeyspecrGrqrHget_installation_errorbsr           zFactory.get_installation_error)N)rG);rCrDrErr#r'r rboolr rOrnpropertyrVr!rur3rrNr5r{rr%r.r~rr/rr rr)r rrr1rrr0rrrrrrJrr;rrrrrrrrrrrrrrGrGrGrHrP\s  &    5 V   G !     $   rP)brrZloggingrtypingrrrrrrrr r r r r rrZ"pip._vendor.packaging.requirementsrZ pip._vendor.packaging.specifiersrZpip._vendor.packaging.utilsrrZpip._vendor.resolvelibrZpip._internal.cacherrZpip._internal.exceptionsrrrrrrZ"pip._internal.index.package_finderrZpip._internal.locationsrZpip._internal.metadatarr Zpip._internal.models.linkr!Zpip._internal.models.wheelr"Z pip._internal.operations.preparer#Zpip._internal.req.constructorsr$Zpip._internal.req.req_installr%r&Zpip._internal.resolution.baser'Z&pip._internal.utils.compatibility_tagsr(Zpip._internal.utils.hashesr)Zpip._internal.utils.miscr*Zpip._internal.utils.packagingr+Zpip._internal.utils.virtualenvr,rvr.r/r0r1Z candidatesr2r3r4r5r6r7r8Zfound_candidatesr9r:rKr;r<r=r>r?r@Z getLoggerrCrrIZCacherJrPrGrGrGrHsH@                $