7imdZddlZddlZddlZddlmZddlmZmZm Z m Z ddl m Z ddl mZddlmZddlmZmZmZmZmZmZmZdd lmZdd lmZmZdd lmZdd l m!Z!dd l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3m4Z4ddl5m6Z6m7Z7ddl8m9Z9ddl:m;Z;mZ>ddl?m@Z@ddlAmBZBddlCmDZDe1eEZFde/de-dedeGdeGd ef d!ZHd"e!d#eId$eJd dfd%ZKGd&d'ZL d2d"e!d(e&d)e eId*e e6d eLf d+ZM d2d"e!d)e eId*e e6d eLfd,ZN d2d"e!d#eId(e&d$eJd)e eId*e e6d e eLfd-ZO d3d"e!d)eId*e e6d.eGd e eIf d/ZPGd0d1ZQy)4z)Prepares a distribution for installation N)Path)DictIterableListOptional)canonicalize_name))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupported HashMismatch HashUnpinnedInstallationErrorMetadataInconsistentNetworkConnectionErrorVcsHashUnsupported) PackageFinder)BaseDistributionget_metadata_distribution) ArchiveInfo)Link)Wheel)BatchDownloader Downloader)HTTPRangeRequestUnsupporteddist_from_wheel_url) PipSession) BuildTracker)InstallRequirement) getLogger)direct_url_for_editabledirect_url_from_link)Hashes MissingHashes) indent_log) display_path hash_filehide_urlredact_auth_from_requirement) TempDirectory) unpack_file)vcsreq build_trackerfinderbuild_isolationcheck_build_depsreturnct|}|j}|>|j||5|j|||ddd|j S|j S#1swY|j SxYw)z(Prepare a distribution for installation.N)r build_tracker_idtrackprepare_distribution_metadatar)r,r-r.r/r0 abstract_dist tracker_ids i/mnt/ssd/data/python-lab/ChefSystem/venv/lib/python3.12/site-packages/pip/_internal/operations/prepare.py_get_prepared_distributionr9;s>cBM//J  j 1   7 7)9    2 2 44= 2 2 44    2 2 44s A((Blinklocation verbosityctj|j}|J|j|t |j |y)N)urlr<)r+get_backend_for_schemeschemeunpackr'r>)r:r;r< vcs_backends r8unpack_vcs_linkrCMs@,,T[[9K  "" "xXdhh%79Mc&eZdZdedeeddfdZy)Filepath content_typer1Nc`||_|tj|d|_y||_y)Nr)rG mimetypes guess_typerH)selfrGrHs r8__init__z File.__init__Ts/   ) 4 4T :1 =D  ,D rD)__name__ __module__ __qualname__strrrMrDr8rFrFSs -S- -$-rDrFdownload download_dirhashesctdd}d}|r t|||}|r|}d}n)|||j\}}|r|j|t ||S)NrATkindglobally_managed)r)_check_download_dirrGcheck_against_pathrF)r:rSrTrUtemp_diralready_downloaded_path from_pathrHs r8 get_http_urlr_\sj (TBH""5dL&"Q+  #+4"? <   % %i 0  < ((rDcd}|r t|||}|r|}n |j}|r|j|t|dS)z'Get file and optionally check its hash.N)rZ file_pathr[rF)r:rTrUr]r^s r8 get_file_urlrbtsM #"5dL&"Q+ NN !!),  4  rDc|jrt|||y|jrJ|jrt |||}nt ||||}|j s!t|j||j|S)a_Unpack link into location, downloading if required. :param hashes: A Hashes object, one of whose embedded hashes must match, or HashMismatch will be raised. If the Hashes is empty, no matches are required, and unhashable types of requirements (like VCS ones, which would ordinarily raise HashUnsupported) are allowed. )r<NrU) is_vcsrCis_existing_diris_filerbr_is_wheelr*rGrH)r:r;rSr<rTrUfiles r8 unpack_urlrjs  {{h)<##%% % ||D,v>      ==DIIx):):; KrDwarn_on_hash_mismatchcjtjj||j}tjj |syt j d||r |j||S|S#t$r0|rt jd|tj|YywxYw)zCheck download_dir for previously downloaded file with correct hash If a correct file is found return its path else None NzFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.) osrGjoinfilenameexistsloggerinfor[r warningunlink)r:rTrUrk download_paths r8rZrZsGGLLt}}=M 77>>- ( KK0-@    % %m 4 = $Q! IIm $ s$A996B21B2cxeZdZdZdedeedededededed ed e d ed ed ede deddffd Z de ddfdZ de deddfdZde defdZde deefdZde deefdZdedeefdZ d&dee deddfdZ d&de dedefdZ d&dee deddfd Zde dedefd!Zde ddfd"Zde defd#Zde d$edefd%ZxZS)'RequirementPreparerzPrepares a Requirement build_dirrTsrc_dirr/r0r-session progress_barr.require_hashes use_user_site lazy_wheelr<legacy_resolverr1Nc8t|||_||_||_||_t |||_t|||_ | |_ ||_ ||_ ||_ | |_| |_| |_| |_||_i|_d|_y)N)r)superrMryrxr-_sessionr _downloadr_batch_downloadr.rTr/r0r|r}use_lazy_wheelr<r _downloaded_previous_requirement_header)rLrxrTryr/r0r-rzr{r.r|r}r~r<r __class__s r8rMzRequirementPreparer.__init__s"  "* #G\:.w E ) /!1-+)# /,.-5)rDr,c|jjr7|js+d}tt |jj }n.d}|j rt|j n t|}|j rX|jrLt|jtr |j}n|jj}|r |d|dz }||f|jk7r||f|_ tj|||jr>t5tjd|jjdddyy#1swYyxYw)z3Provide context for the requirement being prepared.z Processing %sz Collecting %sz (from )zUsing cached %sN)r:rgis_wheel_from_cacherQr%rar,r( comes_from isinstancer^rrqrrr$ro)rLr,message informationrs r8_log_preparing_linkz'RequirementPreparer._log_preparing_links 88  C$;$;%Gl388+=+=>?K%GCF776sww?PSTWPXK 77s~~#..#.,/NN  ^^557  A66 [ !T%F%F F18+0FD - KK -  " " B -sxx/@/@A B B # B Bs &+EE$parallel_buildsc|jjry|jJ|jjr|jj|_y|j |j d||jy)z1Ensure source_dir of a linked InstallRequirement.NT) autodeleter)r:rh source_dirrfraensure_has_source_dirrxensure_pristine_source_checkout)rLr,rs r8_ensure_link_req_src_dirz,RequirementPreparer._ensure_link_req_src_dir-sz 88   ~~%%% 88 # # % XX//CN  !! NN+ " ++-rDcF|js|jdS|jjr t |jj r t |js|js t|jdxs tS)NT)trust_internetF) r|rUr:rerrfr is_direct is_pinnedr r#rLr,s r8_get_linked_req_hashesz*RequirementPreparer._get_linked_req_hashesDs~ ""::T:2 2 88??$& & 88 # # %-/ /}}S]]. zzz/B=?BrDc|jrtjdy|jrtjdy|j |xs|j |j S)Nz9Metadata-only fetching is not used in the legacy resolverz?Metadata-only fetching is not used as hash checking is required)rrqdebugr|$_fetch_metadata_using_link_data_attr _fetch_metadata_using_lazy_wheelr:rs r8_fetch_metadata_onlyz(RequirementPreparer._fetch_metadata_onlydsk    LLK     LLQ 88  =  2 2388 < =rDc|jj}|y|jJtj d|j|t ||j |j}t|jd5}|j}dddt|jj|jj}t|jt|jjk7r,t!|d|jj|j|S#1swYxYw)zGFetch metadata from the data-dist-info-metadata attribute, if possible.Nz/Obtaining dependency information for %s from %srdrbName)r: metadata_linkr,rqverboser_r as_hashesopenrGreadrronamerraw_namer)rLr,r metadata_filefmetadata_contents metadata_dists r8rz8RequirementPreparer._fetch_metadata_using_link_data_attrws ..0  ww""" = GG  %  NN **, -$$d + )q !  )2  HH   GGLL  ]33 48I#'',,8W W&VSWW\\=+A+A % ) )s D::Er:c|jsy|js |jstj d|yt |j }t|j}tjd||j|jjddd} t|||jS#t$rtj d|YywxYw)z-Fetch metadata using lazy wheel, if possible.Nz=Lazy wheel is not used as %r does not point to a remote wheelz+Obtaining dependency information from %s %s#rz"%s does not support range requests)rrgrhrqrrrorrrrversionr>splitrrr)rLr:wheelrr>s r8rz4RequirementPreparer._fetch_metadata_using_lazy_wheels "" <Download any requirements which were only fetched by metadata.rATrWzDownloading link %s to %sN)r)rGr:rkeysrqrlocal_file_pathrr>rhneeds_unpacked_archiver_prepare_linked_requirement) rLrrr\links_to_fully_downloadr,batch_downloadr:filepath_s r8_complete_partial_requirementsz2RequirementPreparer._complete_partial_requirementss!hFKK CE, 4C88O803 #CHH - 4-- # ( ( *  $2 ; D-8Q LL4dH E)$/C#+C .6D  SXX\\ * <<**4>: ;&- CC  , ,S/ B CrDc|jsJ|j|t5d}|jU|jjr?|j |}t |j|j||j }|$||j|jj<n%|j|}|d|_ |cdddS|j||cdddS#1swYyxYw)z3Prepare a requirement to be obtained from req.link.N)rkT) r:rr$rTrhrrZrrr>rneeds_more_preparationr)rLr,rrarUrs r8prepare_linked_requirementz.RequirementPreparer.prepare_linked_requirementsxxx   % \ JI  ,1B1B44S9/HH%%/2.E.E*E  $1:  .!% 9 9# >  ,15C.(7 J J<33CI= J J JsB%C4C44C=reqsc|Dcgc]}|js|}}|D]}|j|jjs'|j |}t |j|j|}|\||j |jj<d|_g}|D]2}|jr|j|!|j||4|j||ycc}w)z,Prepare linked requirements more, if needed.NF)r) rrTr:rhrrZrr>appendrr)rLrrr,rUrars r8 prepare_linked_requirements_morez4RequirementPreparer.prepare_linked_requirements_mores $Bs'A'ABB 7C  ,1B1B44S9/$:K:KVT (5>D$$SXX\\216C. 7?A! GC)))00500oF  G ++ %+ , +Cs C4C4c |jsJ|j}|j|}|r|jr|jJ|jsJ|j sJt |jjtrR|jjjr2|j|jjjrd}n2tjd|j|_|j}|j|||jrd}n|j |j"vr: t%||j&|j(|j*|j,|}n9|j"|j }|r|j3|t5|d}|j|j6rJt9||j&|_t |jjtrf|jjjsF|rDt;|j<dj?}d||jj_ |r|j<|_!tE||jF|jH|jJ|jL} | S#t.$r}t1d|d|d|d}~wwxYw)NzyThe hashes of the source archive found in cache entry don't match, ignoring cached built wheel and re-downloading source.zCould not install requirement z because of HTTP error z for URL )rHrzsha256=)'r:rr download_inforhrgrrrrrU has_one_ofrqrscached_wheel_source_linkrrfr>rrjrrr<rTrrr[rFeditabler!r&rG hexdigesthashrr9r-r.r/r0) rLr,rr:rU local_fileexcrardists r8rz/RequirementPreparer._prepare_linked_requirement-sxxxxx,,S1 c--$$0 00== =<< <3,,11;?%%**11%%c&7&7&<&<&C&CD 1 77xx %%c?;    !J XXT-- - 'NNNNNN%%  ((2I)))4id;J    $|| ## 4T3>> JC  3,,11;?))..55 1!4>>@18v.>!!&&+ ",//C )     KK   ! !   W* '4SE: E4&2 s 8K K)K$$K)cn|jJ|jJ|j}|js|jr(|jr|j |jy|jrt jd|y|jytjj|j|j}tjj|sBtj|j|t!|}t j#d|yy)NzENot copying link to destination directory since it is a directory: %szSaved %s)rTr:rerfrarchiverqrrrmrGrnrorpshutilcopyr%rr)rLr,r:download_locationrus r8save_linked_requirementz+RequirementPreparer.save_linked_requirements  ,,,xx###xx ;;4//1cll KK)) *     ! LL.      & GGLL):):DMMJww~~/0 KK++-> ?():;M KK M 21rDc|jsJdtjd|t5|jrt d|d|j |j|j|jsJt|j|_ t||j|j|j |j"}|j%|j&ddd|S#1swYSxYw)z Prepare an editable requirement.z-cannot prepare a non-editable req as editablez Obtaining %szThe editable requirement zT cannot be installed when requiring hashes, because there is no single file to hash.N)rrqrrr$r|rrryupdate_editablerr unpacked_source_directoryrr9r-r.r/r0check_if_existsr})rLr,rs r8prepare_editable_requirementz0RequirementPreparer.prepare_editable_requirements ||LLL| NC( \ 4""'/u5  % %dll 3    !>> !> 78U8U VC -"" $$%% D    2 2 3) 4, - 4, s CC??D  skip_reasonc`|jsJd|Jd|jtjd|||jjt 5|j rtj dt|jcdddS#1swYyxYw)z)Prepare an already-installed requirement.z(req should have been satisfied but isn'tNz?did not get skip reason skipped but req.satisfied_by is set to zRequirement %s: %s (%s)zSince it is already installed, we are trusting this package without checking its hash. To ensure a completely repeatable environment, install into an empty virtualenv.) satisfied_byrqrrrr$r|rr r)rLr,rs r8prepare_installed_requirementz1RequirementPreparer.prepare_installed_requirements K!KK&  ))* , &  %{C9I9I9Q9Q \ J"" ( )-GGI J J Js :B$$B-)F)rNrOrP__doc__rQrboolrrrintrMrrrr"rrrrrrrrrrrrrr __classcell__)rs@r8rwrws@ 8585sm85 85  85  85$858585858585858585 !85tB'9BdB6.%.8<. ..C*<CC@= = " #=&' ' " #'R " #@!&*C#+,>#?*C*C  *CZ@E$J%$J8<$J $JNKP /0 CG  rs  119QG=N7*,F5E<.=2 75! 8 5 55 5 5  5  5$N$N#N#N$N --#'# ) ))3-) V  )  )2PT! !&sm!