
    *,hp                        d Z ddlZddlZddlZddlZddlmZmZmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZ ddlmZ dd	lmZmZ dd
lmZ ddl m!Z! ddl"m#Z# ddl$m%Z%m&Z& ddl'm(Z(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1m2Z2 ddl3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z< ddl=m>Z> ddl?m@Z@ ddlAmBZB  ej                  eD      ZEde/de-dedeFdeFdefdZGd e!d!eHd"eIddfd#ZJ G d$ d%      ZK	 	 d0d e!d&e&d'e	eH   d(e	e4   deKf
d)ZL	 d0d e!d'e	eH   d(e	e4   deKfd*ZM	 	 d0d e!d!eHd&e&d"eId'e	eH   d(e	e4   de	eK   fd+ZN	 d1d e!d'eHd(e	e4   d,eFde	eH   f
d-ZO G d. d/      ZPy)2z)Prepares a distribution for installation
    N)DictIterableListOptional)canonicalize_name))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupportedHashMismatchHashUnpinnedInstallationErrorMetadataInconsistentNetworkConnectionErrorPreviousBuildDirErrorVcsHashUnsupported)PackageFinder)BaseDistributionget_metadata_distribution)ArchiveInfo)Link)Wheel)BatchDownloader
Downloader)HTTPRangeRequestUnsupporteddist_from_wheel_url)
PipSession)BuildTracker)InstallRequirement)direct_url_for_editabledirect_url_from_link)HashesMissingHashes)
indent_log)display_path	hash_filehide_urlis_installable_dir)TempDirectory)unpack_file)vcsreqbuild_trackerfinderbuild_isolationcheck_build_depsreturnc                     t        |       }|j                  |       5  |j                  |||       ddd       |j                         S # 1 sw Y   |j                         S xY w)z(Prepare a distribution for installation.N)r   trackprepare_distribution_metadatar   )r+   r,   r-   r.   r/   abstract_dists         b/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pip/_internal/operations/prepare.py_get_prepared_distributionr6   ;   sd     >cBM			S	! 
33O%5	

 2244	
 2244s   A		A!linklocation	verbosityc                     t        j                  | j                        }|J |j                  |t	        | j
                        |       y )N)urlr9   )r*   get_backend_for_schemeschemeunpackr&   r;   )r7   r8   r9   vcs_backends       r5   unpack_vcs_linkr@   K   s=    ,,T[[9K""xXdhh%79M    c                   &    e Zd Zdedee   ddfdZy)Filepathcontent_typer0   Nc                 `    || _         |t        j                  |      d   | _        y || _        y )Nr   )rD   	mimetypes
guess_typerE   )selfrD   rE   s      r5   __init__zFile.__init__R   s/    	 ) 4 4T :1 =D ,DrA   )__name__
__module____qualname__strr   rJ    rA   r5   rC   rC   Q   s     -S - -$ -rA   rC   downloaddownload_dirhashesc                     t        dd      }d }|rt        | ||      }|r|}d }n) || |j                        \  }}|r|j                  |       t	        ||      S )Nr>   Tkindglobally_managed)r(   _check_download_dirrD   check_against_pathrC   )r7   rP   rQ   rR   temp_diralready_downloaded_path	from_pathrE   s           r5   get_http_urlr\   Z   sj     (TBH""5dL&"Q+	 #+4"?	<%%i0	<((rA   c                     d}|rt        | ||      }|r|}n| j                  }|r|j                  |       t        |d      S )z'Get file and optionally check its hash.N)rW   	file_pathrX   rC   )r7   rQ   rR   rZ   r[   s        r5   get_file_urlr_   r   sM    
 #"5dL&"Q+	NN	 !!),	4  rA   c                    | j                   rt        | ||       y| j                         rJ | j                  rt	        | ||      }nt        | |||      }| 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.
    )r9   NrR   )
is_vcsr@   is_existing_diris_filer_   r\   is_wheelr)   rD   rE   )r7   r8   rP   r9   rQ   rR   files          r5   
unpack_urlrg      s|      {{h)<##%% ||D,v> 	
 ==DIIx):):;KrA   warn_on_hash_mismatchc                 j   t         j                  j                  || j                        }t         j                  j	                  |      syt
        j                  d|       |r	 |j                  |       |S |S # t        $ r0 |rt
        j                  d|       t        j                  |       Y yw xY w)zCheck download_dir for previously downloaded file with correct hash
    If a correct file is found return its path else None
    NzFile was already downloaded %sz;Previously-downloaded file %s has bad hash. Re-downloading.)osrD   joinfilenameexistsloggerinforX   r   warningunlink)r7   rQ   rR   rh   download_paths        r5   rW   rW      s     GGLLt}}=M77>>-( KK0-@		%%m4 =  	$Q! IIm$	s   $A9 96B21B2c                   x    e Zd ZdZdedee   dededededed	ed
e	dededede
deddf fdZdeddfdZdededdfdZdedefdZdedee   fdZdedee   fdZdedee   fdZ	 d&dee   deddfdZ	 d&dededefdZ	 d&dee   deddfd Zdededefd!Zdeddfd"Zdedefd#Zded$edefd%Z xZS )'RequirementPreparerzPrepares a Requirement	build_dirrQ   src_dirr.   r/   r,   sessionprogress_barr-   require_hashesuse_user_site
lazy_wheelr9   legacy_resolverr0   Nc                 8   t         |           || _        || _        || _        || _        t        ||      | _        t        ||      | _	        |	| _
        || _        || _        || _        |
| _        || _        || _        || _        || _        i | _        d| _        y )N) r~   )superrJ   rv   ru   r,   _sessionr   	_downloadr   _batch_downloadr-   rQ   r.   r/   ry   rz   use_lazy_wheelr9   r|   _downloaded_previous_requirement_header)rI   ru   rQ   rv   r.   r/   r,   rw   rx   r-   ry   rz   r{   r9   r|   	__class__s                  r5   rJ   zRequirementPreparer.__init__   s    " 	"*#G\:.wE )  / !1 - + ) #  / ,. -5)rA   r+   c                    |j                   j                  r7|j                  s+d}t        t	        |j                   j
                              }nd}t        |j                  xs |      }|j                  rX|j                  rLt        |j                  t              r|j                  }n|j                  j                         }|r	|d| dz  }||f| j                  k7  r||f| _
        t        j                  ||       |j                  r>t               5  t        j                  d|j                   j                         ddd       yy# 1 sw Y   yxY w)z3Provide context for the requirement being prepared.zProcessing %szCollecting %sz (from )zUsing cached %sN)r7   rd   is_wheel_from_cacherN   r$   r^   r+   
comes_from
isinstancer[   r   rn   ro   r#   rl   )rI   r+   messageinformationr   s        r5   _log_preparing_linkz'RequirementPreparer._log_preparing_link  s   88C$;$;%Gl388+=+=>?K%Gcggn-K 77s~~#..#.,/NN
 ^^557
A66[!T%F%FF18+0FD-KK-"" B-sxx/@/@AB B #B Bs   +EEparallel_buildsc                 j   |j                   j                  ry|j                  J |j                   j                         r|j                   j                  |_        y|j                  | j                  d|       t        |j                        r%t        dj                  ||j                              y)z1Ensure source_dir of a linked InstallRequirement.NT)
autodeleter   zpip can't proceed with requirements '{}' due to apre-existing build directory ({}). This is likely due to a previous installation that failed . pip is being responsible and not assuming it can delete this. Please delete it and try again.)
r7   re   
source_dirrc   r^   ensure_has_source_dirru   r'   r   format)rI   r+   r   s      r5   _ensure_link_req_src_dirz,RequirementPreparer._ensure_link_req_src_dir+  s    
 88 ~~%%88##% XX//CN 	!!NN+ 	" 	
 cnn-'2 39&cnn2M  .rA   c                 F   | j                   s|j                  d      S |j                  j                  r
t	               |j                  j                         r
t               |j                  s|j                  s
t               |j                  d      xs
 t               S )NT)trust_internetF)ry   rR   r7   rb   r   rc   r
   	is_direct	is_pinnedr   r"   rI   r+   s     r5   _get_linked_req_hashesz*RequirementPreparer._get_linked_req_hashesP  s~     ""::T:22 88??$&&88##%-// }}S]].  zzz/B=?BrA   c                     | j                   rt        j                  d       y | j                  rt        j                  d       y | j	                  |      xs | j                  |j                        S )Nz9Metadata-only fetching is not used in the legacy resolverz?Metadata-only fetching is not used as hash checking is required)r|   rn   debugry   $_fetch_metadata_using_link_data_attr _fetch_metadata_using_lazy_wheelr7   r   s     r5   _fetch_metadata_onlyz(RequirementPreparer._fetch_metadata_onlyp  sk     LLK LLQ 88
 =22388<	=rA   c                    |j                   j                         }|y|j                  J t        j	                  d|j                  |       t        || j                  |j                               }t        |j                  d      5 }|j                         }ddd       t        |j                   j                  |j                  j                        }t        |j                        t        |j                  j                        k7  r,t!        |d|j                  j                  |j                        |S # 1 sw Y   xY w)zGFetch metadata from the data-dist-info-metadata attribute, if possible.Nz/Obtaining dependency information for %s from %sra   rbName)r7   metadata_linkr+   rn   ro   r\   r   	as_hashesopenrD   readr   rl   namer   raw_namer   )rI   r+   r   metadata_filefmetadata_contentsmetadata_dists          r5   r   z8RequirementPreparer._fetch_metadata_using_link_data_attr  s    ..0 ww""=GG	
 %NN **,

 -$$d+ 	)q !	) 2HHGGLL
 ]3348I#'',,8WW&VSWW\\=+A+A  %	) 	)s   	D::Er7   c                    | j                   sy|j                  s|j                  st        j	                  d|       yt        |j                        }t        |j                        }t        j                  d||j                         |j                  j                  dd      d   }	 t        ||| j                        S # t        $ r t        j	                  d|       Y yw xY w)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#   r   z"%s does not support range requests)r   rd   re   rn   r   r   rl   r   r   ro   versionr;   splitr   r   r   )rI   r7   wheelr   r;   s        r5   r   z4RequirementPreparer._fetch_metadata_using_lazy_wheel  s     ""<<t}}LLO dmm$ ,9MM	

 hhnnS!$Q'	&tS$--@@* 	LL=sC	s   (B? ?C! C!partially_downloaded_reqsc                    t        dd      j                  }i }|D ]  }|j                  sJ |||j                  <   ! | j                  |j	                         |      }|D ][  \  }\  }}	t
        j                  d||       ||   }||_        |j                  s9|| j                  |j                  j                  <   ] |D ]  }| j                  ||        y)z>Download any requirements which were only fetched by metadata.r>   TrT   zDownloading link %s to %sN)r(   rD   r7   r   keysrn   r   local_file_pathre   r   r;   _prepare_linked_requirement)
rI   r   r   rY   links_to_fully_downloadr+   batch_downloadr7   filepath_s
             r5   _complete_partial_requirementsz2RequirementPreparer._complete_partial_requirements  s     !hFKK
 CE, 	4C88O03#CHH-	4 --#((*
 $2 	:D-8QLL4dHE)$/C"*C ||19  .!	:( - 	CC,,S/B	CrA   c                     |j                   sJ | j                  |       t               5  d}| j                  U|j                   j                  r?| j                  |      }t        |j                   | j                  ||j                         }|$|| j                  |j                   j                  <   n%| j                  |      }|d|_        |cddd       S | j                  ||      cddd       S # 1 sw Y   yxY w)z3Prepare a requirement to be obtained from req.link.N)rh   T)r7   r   r#   rQ   re   r   rW   r   r   r;   r   needs_more_preparationr   )rI   r+   r   r^   rR   r   s         r5   prepare_linked_requirementz.RequirementPreparer.prepare_linked_requirement  s     xx  %\ 	J I  ,1B1B44S9/HH%% /2.E.E*E	 $1:  . !% 9 9# > ,15C.(7	J 	J< 33CI=	J 	J 	Js   B%C4C44C=reqsc                    |D cg c]  }|j                   s| }}|D ]  }| j                  |j                  j                  s'| j	                  |      }t        |j                  | j                  |      }|\|| j                  |j                  j                  <   d|_          g }|D ]2  }|j                   r|j                  |       !| j                  ||       4 | j                  ||       yc c}w )z,Prepare linked requirements more, if needed.NF)r   )r   rQ   r7   re   r   rW   r   r;   appendr   r   )rI   r   r   r+   rR   r^   r   s          r5    prepare_linked_requirements_morez4RequirementPreparer.prepare_linked_requirements_more  s      $Bs'A'ABB 	7C  ,1B1B44S9/$:K:KVT	(5>D$$SXX\\216C.	7 ?A! 	GC)))00500oF		G 	++%+ 	, 	
+ Cs
   C4C4c                    |j                   sJ |j                   }| j                  |      }|r|j                  r|j                  J |j                  sJ |j
                  sJ t        |j                  j                  t              rR|j                  j                  j                  r2|j                  |j                  j                  j                        rd }n2t        j                  d       |j                  |_         |j                   }| j                  ||       |j                         rd }n|j                   | j"                  vr:	 t%        ||j&                  | j(                  | j*                  | j,                  |      }n9| j"                  |j                      }|r|j5                  |       t7        |d       }|j                  |j8                  rJ t;        ||j&                        |_        t        |j                  j                  t              rf|j                  j                  j                  sF|rDt=        |j>                        d   jA                         }d| |j                  j                  _!        |r|j>                  |_"        tG        || jH                  | jJ                  | jL                  | jN                        }	|	S # t.        $ r!}t1        dj3                  |||            d }~ww xY w)NzyThe hashes of the source archive found in cache entry don't match, ignoring cached built wheel and re-downloading source.zDCould not install requirement {} because of HTTP error {} for URL {})rE   r   zsha256=)(r7   r   r   download_infore   rd   r   ro   r   rR   
has_one_ofrn   rp   cached_wheel_source_linkr   rc   r;   r   rg   r   r   r9   rQ   r   r   r   rX   rC   editabler    r%   rD   	hexdigesthashr   r6   r,   r-   r.   r/   )
rI   r+   r   r7   rR   
local_fileexcr^   r   dists
             r5   r   z/RequirementPreparer._prepare_linked_requirement:  sz    xxxx,,S1c--$$00== << 3,,11;?%%**11%%c&7&7&<&<&C&CD 1
 77xx%%c?;!JXXT---'NNNNNN%%
 ((2I)))4id;J $ ||# 4T3>> JC 3,,11;?))..55 1!4>>@ 18v.>!!&&+ ",//C)KK  !!
 W * '**0&c4*@ s   
8K 	K1K,,K1c                 n   | j                   J |j                  J |j                  }|j                  s|j                         r(|j                  r|j                  | j                          y |j                         rt        j                  d|       y |j                  y t        j                  j                  | j                   |j                        }t        j                  j                  |      sBt        j                  |j                  |       t!        |      }t        j#                  d|       y y )NzENot copying link to destination directory since it is a directory: %szSaved %s)rQ   r7   rb   rc   r   archivern   r   r   rj   rD   rk   rl   rm   shutilcopyr$   ro   )rI   r+   r7   download_locationrr   s        r5   save_linked_requirementz+RequirementPreparer.save_linked_requirement  s      ,,xx##xx;;4//1cllKK))*!LL.
 &GGLL):):DMMJww~~/0KK++->?():;MKK
M2 1rA   c                 .   |j                   sJ d       t        j                  d|       t               5  | j                  rt        dj                  |            |j                  | j                         |j                          |j                  sJ t        |j                        |_        t        || j                  | j                   | j"                  | j$                        }|j'                  | j(                         ddd       |S # 1 sw Y   S xY w)z Prepare an editable requirement.z-cannot prepare a non-editable req as editablezObtaining %szoThe editable requirement {} cannot be installed when requiring hashes, because there is no single file to hash.N)r   rn   ro   r#   ry   r   r   r   rv   update_editabler   r   unpacked_source_directoryr   r6   r,   r-   r.   r/   check_if_existsrz   )rI   r+   r   s      r5   prepare_editable_requirementz0RequirementPreparer.prepare_editable_requirement  s    
 ||LLLNC(\ 	4""'"F3K 
 %%dll3!>>! 78U8U VC-""$$%%D  2 23)	4, -	4, s   CD

Dskip_reasonc                 x   |j                   sJ d       | J dj                  |j                                t        j                  d|||j                   j                         t               5  | j                  rt        j                  d       t        |      j                         cddd       S # 1 sw Y   yxY w)z)Prepare an already-installed requirement.z(req should have been satisfied but isn'tNzAdid not get skip reason skipped but req.satisfied_by is set to {}zRequirement %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_byr   rn   ro   r   r#   ry   r   r	   r   )rI   r+   r   s      r5   prepare_installed_requirementz1RequirementPreparer.prepare_installed_requirement  s     K!KK& 	
!6#"2"23	
 	%{C9I9I9Q9Q	
 \ 	J""( )-GGI	J 	J 	Js   ,:B00B9)F)rK   rL   rM   __doc__rN   r   boolr   r   r   intrJ   r   r   r   r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r5   rt   rt      sA    8585 sm85 	85
 85 85 $85 85 85 85 85 85 85 85 85  
!85tB'9 Bd B6#%#8<#	#JC*< C C@== 
"	#=&'' 
"	#'R 
"	#@ !&+C#+,>#?+C +C 
	+C\ @E$J%$J8<$J	$JN KP
/0
CG
	
<Z%Z8<Z	Zx3+= 3$ 34 
BJJ J 
	JrA   rt   )NN)T)Qr   loggingrG   rj   r   typingr   r   r   r   pip._vendor.packaging.utilsr   pip._internal.distributionsr   %pip._internal.distributions.installedr	   pip._internal.exceptionsr
   r   r   r   r   r   r   r   "pip._internal.index.package_finderr   pip._internal.metadatar   r   pip._internal.models.direct_urlr   pip._internal.models.linkr   pip._internal.models.wheelr   pip._internal.network.downloadr   r    pip._internal.network.lazy_wheelr   r   pip._internal.network.sessionr   ,pip._internal.operations.build.build_trackerr   pip._internal.req.req_installr   &pip._internal.utils.direct_url_helpersr   r    pip._internal.utils.hashesr!   r"   pip._internal.utils.loggingr#   pip._internal.utils.miscr$   r%   r&   r'   pip._internal.utils.temp_dirr(   pip._internal.utils.unpackingr)   pip._internal.vcsr*   	getLoggerrK   rn   r   r6   rN   r   r@   rC   r\   r_   rg   rW   rt   rO   rA   r5   <module>r      s      	  1 1 9 Q G	 	 	 = N 7 * , F 5 E < = 2  7 5 !			8	$5	55 5 	5
 5 5 N$ N# N# N$ N- - #'#	)
)) 3-) V	)
 
)2 PT!
!&sm!<DV<L!	!: #'#(
(( ( 	(
 3-( V( d^(^ #'	
 V  	
 c]<TJ TJrA   