I ipdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZdd lmZmZmZmZmZmZmZdd lmZddl m!Z!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;ddlm?Z?m@Z@mAZAmBZBddlCmDZDddlEmFZFddlGmHZHe rddlImJZJe5eKZL d*d ZMd+d!ZNe Gd"d#ZO d, d-d$ZP d, d.d%ZQ d, d/d&ZR d0 d1d'ZSGd(d)ZTy)2z(Prepares a distribution for installation) annotationsN)Iterable) dataclass)Path) TYPE_CHECKING)canonicalize_name)BuildEnvironmentInstaller))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupported HashMismatch HashUnpinnedInstallationErrorMetadataInconsistentNetworkConnectionErrorVcsHashUnsupported) PackageFinder)BaseDistributionget_metadata_distribution) ArchiveInfo)Link)Wheel) 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)vcs)BarTypect|}|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)req build_trackerbuild_env_installerbuild_isolationcheck_build_deps abstract_dist tracker_ids f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pip/_internal/operations/prepare.py_get_prepared_distributionr9As>cBM//J  j 1   7 7#_6F    2 2 44= 2 2 44    2 2 44s A((Bctj|j}|J|j|t |j |y)N)url verbosity)r+get_backend_for_schemeschemeunpackr'r;)linklocationr< vcs_backends r8unpack_vcs_linkrCSs@,,T[[9K  "" "xXdhh%79Mc.eZdZUded<dZded<ddZy)FilestrpathN str | None content_typec|j) tj|jd|_yy#t$rYywxYw)Nr)rJ mimetypes guess_typerHOSError)selfs r8 __post_init__zFile.__post_init__^sH    $ $-$8$8$CA$F! %   s'7 AA)returnNone)__name__ __module__ __qualname____annotations__rJrPrDr8rFrFYs I#L*#rDrFctdd}d}|r t|||}|r|}d}n)|||j\}}|r|j|t ||S)Nr?Tkindglobally_managed)r)_check_download_dirrHcheck_against_pathrF)r@download download_dirhashestemp_diralready_downloaded_path from_pathrJs r8 get_http_urlrdhsj (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)r\ file_pathr]rF)r@r_r`rbrcs r8 get_file_urlrgsM #"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<Nr`) is_vcsrCis_existing_diris_filergrdis_wheelr*rHrJ)r@rAr^r<r_r`files r8 unpack_urlros  {{h)<##%% % ||D,v>      ==DIIx):):; KrDcjtjj||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.) osrHjoinfilenameexistsloggerinfor]r warningunlink)r@r_r`warn_on_hash_mismatch download_paths r8r\r\sGGLLt}}=M 77>>- ( KK0-@    % %m 4 = $Q! IIm $ s$A996B21B2c>eZdZdZ dfd ZddZ ddZddZ ddZ ddZ ddZ d dd Z d dd Z d dd Z dd Zdd Z ddZ ddZxZS)RequirementPreparerzPrepares a Requirementc&t|||_||_||_||_t || ||_| |_||_ ||_ ||_ ||_ | |_ | |_| |_||_||_i|_d|_y)N)r~)super__init__src_dir build_dirr2_sessionr _downloadfinderr_r4r3r5require_hashes use_user_siteuse_lazy_wheelr<legacy_resolver _downloaded_previous_requirement_header)rOrr_rr4build_isolation_installerr5r2session progress_barrrr lazy_wheelr<rresume_retries __class__s r8rzRequirementPreparer.__init__s(  "* #G\>J ) /#< !1-+)# /,.-5)rDc|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@rlis_wheel_from_cacherGr%rfr1r( comes_from isinstancercrrurvr$rs)rOr1message informationrs r8_log_preparing_linkz'RequirementPreparer._log_preparing_link!s 88  C$;$;%Gl388+=+=>?K%GCF776sww?PSTWPXK 77s~~#..#.),  ^^557  A66 [ !T%F%F F18+0FD - KK -  " " B -sxx/@/@A B B # B Bs &+EE$c|jjry|jJ|jjr|jj|_y|j |j d||jy)z1Ensure source_dir of a linked InstallRequirement.NT) autodeleteparallel_builds)r@rm source_dirrkrfensure_has_source_dirrensure_pristine_source_checkout)rOr1rs 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) rr`r@rjrrkr is_direct is_pinnedrr#rOr1s r8_get_linked_req_hashesz*RequirementPreparer._get_linked_req_hashesSs~ ""::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)rrudebugr$_fetch_metadata_using_link_data_attr _fetch_metadata_using_lazy_wheelr@rs r8_fetch_metadata_onlyz(RequirementPreparer._fetch_metadata_onlyssk    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 %srirbName)r@ metadata_linkr1ruverboserdr as_hashesopenrHreadrrsnamerraw_namer)rOr1r metadata_filefmetadata_contents metadata_dists r8rz8RequirementPreparer._fetch_metadata_using_link_data_attrs ..0  ww""" = GG  %  NN **, -$$d + )q !  )2  HH   GGLL  ]33 48I#'',,8W W&VSWW\\=+A+A % ) )s D::Ec|jsy|js |jstj d|yt |j }|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)rrlrmrurrrsrrvversionr;splitrrr)rOr@wheelrr;s r8rz4RequirementPreparer._fetch_metadata_using_lazy_wheels "" <Download any requirements which were only fetched by metadata.r?TrYzDownloading link %s to %sN)r)rHr@rbatchkeysrurlocal_file_pathrr;rmneeds_unpacked_archiver_prepare_linked_requirement) rOpartially_downloaded_reqsrralinks_to_fully_downloadr1batch_downloadr@filepath_s r8_complete_partial_requirementsz2RequirementPreparer._complete_partial_requirementss!hFKK CE, 4C88O803 #CHH - 4--.E.J.J.LhW#1 ; 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<ng|j|}|Td|_ |j||j%t|j|j|_ |cdddS|j!||cdddS#1swYyxYw)z3Prepare a requirement to be obtained from req.link.N)ryT)r@rr$r_rmrr\rrr;rneeds_more_preparationset_dist download_infor!rr)rOr1rrfr`rs r8prepare_linked_requirementz.RequirementPreparer.prepare_linked_requirements-xxx   % \$ JI  ,1B1B44S9/HH%%/2.E.E*E  $1:  .!% 9 9# >  ,15C.LL/((0,@HHcnn-))C$ J$ JH33CII$ J$ J$ JsC'D6D66D?c|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) rr_r@rmrr\rr;appendrr)rOreqsrr1r`rfrs r8 prepare_linked_requirements_morez4RequirementPreparer.prepare_linked_requirements_more!s $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 )rJrzsha256=)'r@rrrrmrlrrvrr` has_one_ofrurwcached_wheel_source_linkrrkr;rrorrr<r_rrr]rFeditabler!r&rH hexdigesthashrr9r2r3r4r5) rOr1rr@r` local_fileexcrfrdists 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 )      $ $   ! !   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)r_r@rjrkrarchiverurrrqrHrrrsrtshutilcopyr%rv)rOr1r@download_locationrzs 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)rrurvr$rrrrupdate_editablerr unpacked_source_directoryrr9r2r3r4r5check_if_existsr)rOr1rs r8prepare_editable_requirementz0RequirementPreparer.prepare_editable_requirements ||LLL| NC( \ 4""'/u5  % %dll 3    !>> !> 78U8U VC -""(($$%% D    2 2 3) 4, - 4, s CC??D c`|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_byrurvrr$rrr r)rOr1 skip_reasons r8prepare_installed_requirementz1RequirementPreparer.prepare_installed_requirements K!KK&  ))* , &  %{C9I9I9Q9Q \ J"" ( )-GGI J J Js :B$$B-)"rrGr_rIrrGr4boolrr r5rr2rrrrr,rrrrrrrrr<intrrrrrQrR)r1rrQrR)r1rrrrQrR)r1rrQr")r1rrQBaseDistribution | None)r@rrQr)F)rIterable[InstallRequirement]rrrQrR)r1rrrrQr)rrrrrQrR)r1rrQr)r1rrrGrQr)rSrTrU__doc__rrrrrrrrrrrrrr __classcell__)rs@r8r|r|s ;5;5! ;5  ;5  ;5$=;5;5$;5;5;5;5;5;5;5 !;5"#;5$%;5& ';5zB6.%.8<. ..C@= = !=&' ' !'R !@!&'C#?'C'C  'CT@E*J%*J8<*J *JZKP 0 CG  rs.# $! 9=QG=N7*,55E<.=2 75!7 8 5 5535 5  5  5$N      " $ ) )))  )  )2JN! !(!9F! !: $ ( ((( (  (  ((^#'