a lj"G@sddlZddlZddlmZmZmZmZmZmZm Z m Z ddl m Z m Z ddlmZddlmZmZddlmZddlmZmZddlmZdd lmZmZdd lmZdd lm Z d d l!m"Z"m#Z#m$Z$m%Z%erd dl&m'Z'e(e)Z*e dZ+e e dZ,e"ee+dddZ-eeedddZ.eeedddZ/eeedddZ0Gddde"Z1Gddde1Z2Gd d!d!e1Z3Gd"d#d#e"Z4Gd$d%d%e"Z5Gd&d'd'e"Z6dS)(N) TYPE_CHECKINGAny FrozenSetIterableOptionalTupleUnioncast)NormalizedNamecanonicalize_name)Version) HashErrorMetadataInconsistent)BaseDistribution)Linklinks_equivalent)Wheel)install_req_from_editableinstall_req_from_line)InstallRequirement)normalize_version_info) CandidateCandidateVersion Requirement format_name)Factory)AlreadyInstalledCandidateEditableCandidate LinkCandidatez) candidatereturncCstttf}t||r|SdS)z%The runtime version of BaseCandidate.N)rrr isinstance)r Zbase_candidate_classesr#R/usr/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.pyas_base_candidate$s r%)linktemplater!c CsZ|jrt|j}n|j}t||j|j|j|j|jt |j |j |j dd}|j |_ ||_|S)Ninstall_optionsglobal_optionsZhashes user_supplied comes_from use_pep517isolated constraintoptions)reqstrurlrr,r-r.r/r0dictr)r* hash_options original_linkr&)r&r'lineireqr#r#r$make_install_req_from_link0s&  r:c Cs6t|j|j|j|j|j|j|jt|j |j |j ddS)Nr()r,r-r.r/r0permit_editable_wheelsr1) rr4r,r-r.r/r0r;r5r)r*r6)r&r'r#r#r$make_install_req_from_editableJsr<)distr'r!c Csddlm}|jrt|j}n.|jr:|jd|jj}n|jd|j}t||j |j |j |j |j t|j|j|jdd}t||j|_|S)Nr) Distributionz @ z==r(r+)Z$pip._internal.metadata.pkg_resourcesr>r2r3r&canonical_namer4versionrr,r-r.r/r0r5r)r*r6r Z_distZ satisfied_by)r=r'Z_Distr8r9r#r#r$_make_install_req_from_dist^s*   rAc @s,eZdZUdZeed<dZd)eeede e e e ddddZ e d d d Ze d d d Zed ddZeedddZee ed ddZee d ddZee d ddZee d ddZe d ddZed ddZeddd d!Zed d"d#Zeee ed$d%d&Z e ed d'd(Z!dS)*"_InstallRequirementBackedCandidateaA candidate backed by an ``InstallRequirement``. This represents a package request with the target not being already in the environment, and needs to be fetched and installed. The backing ``InstallRequirement`` is responsible for most of the leg work; this class exposes appropriate information to the resolver. :param link: The link passed to the ``InstallRequirement``. The backing ``InstallRequirement`` will use this link to fetch the distribution. :param source_link: The link this candidate "originates" from. This is different from ``link`` when the link is found in the wheel cache. ``link`` would point to the wheel cache, while this points to the found remote link (e.g. from pypi.org). r=FNr)r& source_linkr9factorynamer@r!cCs2||_||_||_||_||_||_||_dSN)_link _source_link_factory_ireq_name_version_preparer=)selfr&rCr9rDrEr@r#r#r$__init__s z+_InstallRequirementBackedCandidate.__init__r!cCs|jd|jS)N rEr@rNr#r#r$__str__sz*_InstallRequirementBackedCandidate.__str__cCsdj|jjt|jdS)Nz{class_name}({link!r})) class_namer&)format __class____name__r3rGrSr#r#r$__repr__sz+_InstallRequirementBackedCandidate.__repr__cCst|j|jfSrF)hashrWrGrSr#r#r$__hash__sz+_InstallRequirementBackedCandidate.__hash__otherr!cCst||jrt|j|jSdSNF)r"rWrrGrNr]r#r#r$__eq__s z)_InstallRequirementBackedCandidate.__eq__cCs|jSrF)rHrSr#r#r$rCsz._InstallRequirementBackedCandidate.source_linkcCs|jdur|jj|_|jS):The normalised name of the project the candidate refers toN)rKr=r?rSr#r#r$ project_names  z/_InstallRequirementBackedCandidate.project_namecCs|jSrFrbrSr#r#r$rEsz'_InstallRequirementBackedCandidate.namecCs|jdur|jj|_|jSrF)rLr=r@rSr#r#r$r@s  z*_InstallRequirementBackedCandidate.versioncCs$d|j|j|jjr|jjn|jS)Nz{} {} (from {}))rVrEr@rGis_fileZ file_pathrSr#r#r$format_for_errors z3_InstallRequirementBackedCandidate.format_for_errorcCs tddS)NzOverride in subclass)NotImplementedErrorrSr#r#r$_prepare_distributionsz8_InstallRequirementBackedCandidate._prepare_distribution)r=r!cCs`|jdur*|j|jkr*t|jd|j|j|jdur\|j|jkr\t|jdt|jt|jdS)z:Check for consistency of project name and version of dist.NrEr@)rKr?rrJrLr@r3)rNr=r#r#r$_check_metadata_consistencysz>_InstallRequirementBackedCandidate._check_metadata_consistencyc CsJz |}Wn.ty:}z|j|_WYd}~n d}~00|||SrF)rgr rJr2rh)rNr=er#r#r$rMs  z+_InstallRequirementBackedCandidate._prepare with_requiresr!ccsH|r|jnd}|D]}|jt||jVq|j|jjVdSNr#)r=iter_dependenciesrImake_requirement_from_specr3rJZ make_requires_python_requirementZrequires_python)rNrkZrequiresrr#r#r$rmsz4_InstallRequirementBackedCandidate.iter_dependenciescCs|jSrF)rJrSr#r#r$get_install_requirementsz:_InstallRequirementBackedCandidate.get_install_requirement)NN)"rX __module__ __qualname____doc__r__annotations__ is_installedrrrr rrOr3rTrYintr[rboolr`propertyrCrbrEr@rergrhrMrrrmrpr#r#r#r$rBzs@   rBcsHeZdZdZd eedeeeeddfdd Z e ddd Z Z S) rFNrr&r'rDrEr@r!c s|}|||}|dur,td|j|j}t||}|jjrn|jjsnt|jj} t | j } |durnt | j } |dur|j r|j|jurd|_tj||||||ddS)NzUsing cached wheel link: %sTr&rCr9rDrEr@)Zget_wheel_cache_entryloggerdebugr&r:Zis_wheelrdrfilenamer rEr r@Z persistentr7Zoriginal_link_is_in_wheel_cachesuperrO) rNr&r'rDrEr@rCZ cache_entryr9ZwheelZ wheel_nameZ wheel_versionrWr#r$rOs4      zLinkCandidate.__init__rPcCs|jj}|j|jddS)NT)Zparallel_builds)rIpreparerZprepare_linked_requirementrJ)rNrr#r#r$rg"sz#LinkCandidate._prepare_distribution)NN rXrqrr is_editablerrrr rrOrrg __classcell__r#r#rr$rs*rcsHeZdZdZd eedeeeeddfdd Z e ddd Z Z S) rTNrrycs"tj||t|||||ddS)Nrz)r~rOr<)rNr&r'rDrEr@rr#r$rO*szEditableCandidate.__init__rPcCs|jj|jSrF)rIrZprepare_editable_requirementrJrSr#r#r$rg;sz'EditableCandidate._prepare_distribution)NNrr#r#rr$r'src@seZdZdZdZeedddddZeddd Z edd d Z e dd d Z e edddZeedddZeedddZeedddZeedddZedddZeeeedddZeedddZdS) rTNr)r=r'rDr!cCs0||_t|||_||_d}|j|j|dS)Nzalready satisfied)r=rArJrIrZprepare_installed_requirement)rNr=r'rDZ skip_reasonr#r#r$rOCs  z"AlreadyInstalledCandidate.__init__rPcCs t|jSrF)r3r=rSr#r#r$rTTsz!AlreadyInstalledCandidate.__str__cCsdj|jj|jdS)Nz{class_name}({distribution!r}))rUZ distribution)rVrWrXr=rSr#r#r$rYWsz"AlreadyInstalledCandidate.__repr__cCst|j|j|jfSrF)rZrWrEr@rSr#r#r$r[]sz"AlreadyInstalledCandidate.__hash__r\cCs(t||jr$|j|jko"|j|jkSdSr^)r"rWrEr@r_r#r#r$r``s z AlreadyInstalledCandidate.__eq__cCs|jjSrF)r=r?rSr#r#r$rbesz&AlreadyInstalledCandidate.project_namecCs|jSrFrcrSr#r#r$rEiszAlreadyInstalledCandidate.namecCs|jjSrF)r=r@rSr#r#r$r@msz!AlreadyInstalledCandidate.versioncCs|jjSrF)r=ZeditablerSr#r#r$rqsz%AlreadyInstalledCandidate.is_editablecCs|jd|jdS)NrQz (Installed)rRrSr#r#r$reusz*AlreadyInstalledCandidate.format_for_errorrjccs2|sdS|jD]}|jt||jVqdSrF)r=rmrIrnr3rJ)rNrkror#r#r$rmxsz+AlreadyInstalledCandidate.iter_dependenciescCsdSrFr#rSr#r#r$rp~sz1AlreadyInstalledCandidate.get_install_requirement)rXrqrrrurCrrrOr3rTrYrvr[rrwr`rxr rbrErr@rrerrrrmrpr#r#r#r$r?s, rc@seZdZdZeeeddddZedddZedd d Z e dd d Z e e d ddZeedddZeedddZeedddZedddZee dddZee dddZeeedddZe eeeddd Zeedd!d"ZdS)#ExtrasCandidateaA candidate that has 'extras', indicating additional dependencies. Requirements can be for a project with dependencies, something like foo[extra]. The extras don't affect the project/version being installed directly, but indicate that we need additional dependencies. We model that by having an artificial ExtrasCandidate that wraps the "base" candidate. The ExtrasCandidate differs from the base in the following ways: 1. It has a unique name, of the form foo[extra]. This causes the resolver to treat it as a separate node in the dependency graph. 2. When we're getting the candidate's dependencies, a) We specify that we want the extra dependencies as well. b) We add a dependency on the base candidate. See below for why this is needed. 3. We return None for the underlying InstallRequirement, as the base candidate will provide it, and we don't want to end up with duplicates. The dependency on the base candidate is needed so that the resolver can't decide that it should recommend foo[extra1] version 1.0 and foo[extra2] version 2.0. Having those candidates depend on foo=1.0 and foo=2.0 respectively forces the resolver to recognise that this is a conflict. N)baseextrasr!cCs||_||_dSrF)rr)rNrrr#r#r$rOszExtrasCandidate.__init__rPcCs,t|jdd\}}d|d|j|S)NrQrz {}[{}] {},)r3rsplitrVjoinr)rNrErestr#r#r$rTszExtrasCandidate.__str__cCsdj|jj|j|jdS)Nz.{class_name}(base={base!r}, extras={extras!r}))rUrr)rVrWrXrrrSr#r#r$rYs zExtrasCandidate.__repr__cCst|j|jfSrF)rZrrrSr#r#r$r[szExtrasCandidate.__hash__r\cCs(t||jr$|j|jko"|j|jkSdSr^)r"rWrrr_r#r#r$r`s zExtrasCandidate.__eq__cCs|jjSrF)rrbrSr#r#r$rbszExtrasCandidate.project_namecCst|jj|jS)ra)rrrbrrSr#r#r$rEszExtrasCandidate.namecCs|jjSrF)rr@rSr#r#r$r@szExtrasCandidate.versioncCsd|jdt|jS)Nz{} [{}]z, )rVrrersortedrrSr#r#r$resz ExtrasCandidate.format_for_errorcCs|jjSrF)rrurSr#r#r$ruszExtrasCandidate.is_installedcCs|jjSrF)rrrSr#r#r$rszExtrasCandidate.is_editablecCs|jjSrF)rrCrSr#r#r$rCszExtrasCandidate.source_linkrjccs|jj}||jV|sdS|j|jj}|j|jj}t|D]}t d|jj |j |qN|jj |D]$}|t||jj|}|rx|VqxdS)Nz%%s %s does not provide the extra '%s')rrIZmake_requirement_from_candidater intersectionr=Ziter_provided_extras differencerr{ZwarningrEr@rmrnr3rJ)rNrkrDZ valid_extrasZinvalid_extrasZextraroZ requirementr#r#r$rms& z!ExtrasCandidate.iter_dependenciescCsdSrFr#rSr#r#r$rpsz'ExtrasCandidate.get_install_requirement) rXrqrrrs BaseCandidaterr3rOrTrYrvr[rrwr`rxr rbrErr@rerurrrrCrrrmrrpr#r#r#r$rs0 rc@seZdZdZdZeeedfddddZe ddd Z e e dd d Z e e dd d Ze edddZe dddZeeeedddZeedddZdS)RequiresPythonCandidateFN.)py_version_infor!cCs>|durt|}ntjdd}tddd|D|_dS)N.css|]}t|VqdSrF)r3).0cr#r#r$ z3RequiresPythonCandidate.__init__..)rsys version_infor rrL)rNrrr#r#r$rOs z RequiresPythonCandidate.__init__rPcCs d|jSNzPython rLrSr#r#r$rTszRequiresPythonCandidate.__str__cCstSrFREQUIRES_PYTHON_IDENTIFIERrSr#r#r$rb sz$RequiresPythonCandidate.project_namecCstSrFrrSr#r#r$rE szRequiresPythonCandidate.namecCs|jSrFrrSr#r#r$r@szRequiresPythonCandidate.versioncCs d|jSr)r@rSr#r#r$resz(RequiresPythonCandidate.format_for_errorrjcCsdSrlr#)rNrkr#r#r$rmsz)RequiresPythonCandidate.iter_dependenciescCsdSrFr#rSr#r#r$rpsz/RequiresPythonCandidate.get_install_requirement)rXrqrrrurCrrrvrOr3rTrxr rbrErr@rerwrrrmrrpr#r#r#r$rs r)7Zloggingrtypingrrrrrrrr Zpip._vendor.packaging.utilsr r Zpip._vendor.packaging.versionr Zpip._internal.exceptionsr rZpip._internal.metadatarZpip._internal.models.linkrrZpip._internal.models.wheelrZpip._internal.req.constructorsrrZpip._internal.req.req_installrZpip._internal.utils.miscrrrrrrrDrZ getLoggerrXr{rrr%r:r<rArBrrrrrr#r#r#r$sF(            {2Cu