HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/operations/__pycache__/prepare.cpython-310.pyc
o

@%NeQ^�@s�dZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZddlm
Z
ddlmZddlmZmZmZmZmZmZmZddlmZdd	lmZdd
lmZddlmZddl m!Z!m"Z"dd
l#m$Z$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=e�>e?�Z@de)de+dedeAdef
dd�ZBded eCd!eDddfd"d#�ZEGd$d%�d%�ZF		d;ded&e"d'e	eCd(e	e/deFf
d)d*�ZGd+eCd,eCddfd-d.�ZHd/eCd0eCddfd1d2�ZI	d;ded'e	eCd(e	e/deFfd3d4�ZJ		d;ded eCd&e"d!eDd'e	eCd(e	e/de	eFfd5d6�ZKded'eCd(e	e/de	eCfd7d8�ZLGd9d:�d:�ZMdS)<z)Prepares a distribution for installation
�N)�Dict�Iterable�List�Optional)�canonicalize_name)�)make_distribution_for_install_requirement)�InstalledDistribution)�DirectoryUrlHashUnsupported�HashMismatch�HashUnpinned�InstallationError�NetworkConnectionError�PreviousBuildDirError�VcsHashUnsupported)�
PackageFinder)�BaseDistribution)�Link)�Wheel)�BatchDownloader�
Downloader)�HTTPRangeRequestUnsupported�dist_from_wheel_url)�
PipSession)�InstallRequirement)�RequirementTracker)�copy2_fixed)�Hashes�
MissingHashes)�
indent_log)�display_path�hide_url�is_installable_dir�rmtree)�
TempDirectory)�unpack_file)�vcs�req�req_tracker�finder�build_isolation�returncCsLt|�}|�|��|�||�Wd�|��S1swY|��S)z(Prepare a distribution for installation.N)r�track�prepare_distribution_metadata�get_metadata_distribution)r&r'r(r)�
abstract_dist�r/�B/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py�_get_prepared_distribution1s
��r1�link�location�	verbositycCs2t�|j�}|dusJ�|j|t|j�|d�dS)N)�urlr4)r%�get_backend_for_scheme�scheme�unpackr r5)r2r3r4�vcs_backendr/r/r0�unpack_vcs_link>sr:c@s&eZdZdedeeddfdd�ZdS)�File�path�content_typer*NcCs,||_|durt�|�d|_dS||_dS)Nr)r<�	mimetypes�
guess_typer=)�selfr<r=r/r/r0�__init__Es
z
File.__init__)�__name__�
__module__�__qualname__�strrrAr/r/r/r0r;Dsr;�download�download_dir�hashescCsVtddd�}d}|rt|||�}|r|}d}n|||j�\}}|r&|�|�t||�S)Nr8T��kind�globally_managed)r#�_check_download_dirr<�check_against_pathr;)r2rFrGrH�temp_dir�already_downloaded_path�	from_pathr=r/r/r0�get_http_urlMs

rQ�src�destc
CsNzt||�WdStjy&}zt�dt|�||�WYd}~dSd}~ww)z�Copying special files is not supported, but as a convenience to users
    we skip errors copying them. This supports tools that may create e.g.
    socket files in the project source directory.
    z>Ignoring special file error '%s' encountered copying %s to %s.N)r�shutil�SpecialFileError�logger�warningrE)rRrS�er/r/r0�_copy2_ignoring_special_fileses���rY�source�targetcsbtj�|�}tj�|��tj�|��dtdttdttf���fdd�}tj�||dt	d�dS)N�d�namesr*cs6g}|�kr|ddg7}tj�|��kr|�g7}|S)Nz.toxz.nox)�osr<�abspath)r\r]�skipped�rZ�target_basename�target_dirnamer/r0�ignore~s
z!_copy_source_tree.<locals>.ignoreT)rd�symlinks�
copy_function)
r^r<r_�basename�dirnamerErrT�copytreerY)rZr[�target_abspathrdr/rar0�_copy_source_treeys&
�rkcCs<d}|r
t|||�}|r|}n|j}|r|�|�t|d�S)z'Get file and optionally check its hash.N)rL�	file_pathrMr;)r2rGrHrOrPr/r/r0�get_file_url�s

rmcCs�|jrt|||d�dS|��r"tj�|�rt|�t|j|�dS|j	r-t
|||d�}nt||||d�}|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.
    )r4N)rH)�is_vcsr:�is_existing_dirr^r<�isdirr"rkrl�is_filermrQ�is_wheelr$r=)r2r3rFr4rGrH�filer/r/r0�
unpack_url�s&
�	rtcCsptj�||j�}tj�|�sdSt�d|�|r6z|�|�W|Sty5t�	d|�t�
|�YdSw|S)z�Check 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.)r^r<�join�filename�existsrV�inforMr
rW�unlink)r2rGrH�
download_pathr/r/r0rL�s"��
�rLcsTeZdZdZdedeedededededed	e	d
ededed
e
deddf�fdd�Zdeddfdd�Z
dededdfdd�Zdedefdd�Zdedeefdd�Z	d0deededdfd d!�Z	d0dededefd"d#�Z	d0d$eededdfd%d&�Zdededefd'd(�Zdeddfd)d*�Zdedefd+d,�Zded-edefd.d/�Z�ZS)1�RequirementPreparerzPrepares a Requirement�	build_dirrG�src_dirr)r'�session�progress_barr(�require_hashes�
use_user_site�
lazy_wheelr4�
in_tree_buildr*Ncszt���||_||_||_||_t||�|_t||�|_	||_
||_||_|	|_
|
|_||_||_|
|_i|_d|_dS)N)�r�)�superrAr}r|r'�_sessionr�	_downloadr�_batch_downloadr(rGr)r�r��use_lazy_wheelr4r��_downloaded�_previous_requirement_header)r@r|rGr}r)r'r~rr(r�r�r�r4r���	__class__r/r0rAs"

zRequirementPreparer.__init__r&cCs�|jjr|jsd}tt|jj��}n	d}t|jp|�}||f|jkr-||f|_t�	||�|jrNt
��t�	d|jj�Wd�dS1sGwYdSdS)z3Provide context for the requirement being prepared.z
Processing %sz
Collecting %szUsing cached %sN)r2rq�original_link_is_in_wheel_cacherErrlr&r�rVrxrrv)r@r&�message�informationr/r/r0�_log_preparing_link8s
"��z'RequirementPreparer._log_preparing_link�parallel_buildscCsj|jjrdS|jdus
J�|j��r|jr|jj|_dS|j|jd|d�t|j�r3t	d�
||j���dS)z1Ensure source_dir of a linked InstallRequirement.NT)�
autodeleter�z�pip 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.)r2rr�
source_dirror�rl�ensure_has_source_dirr|r!r�format)r@r&r�r/r/r0�_ensure_link_req_src_dirIs"
�

��z,RequirementPreparer._ensure_link_req_src_dircCsX|js	|jdd�S|jjrt��|j��rt��|jdur#|js#t	��|jdd�p+t
�S)NT)�trust_internetF)r�rHr2rnrror	�
original_link�	is_pinnedrr)r@r&r/r/r0�_get_linked_req_hashesns
z*RequirementPreparer._get_linked_req_hashesr2cCs�|jsdS|jrt�d�dS|js|jst�d|�dSt|j�}t|j	�}t�
d||j�|j�
dd�d}zt|||j�WStyPt�d|�YdSw)	z-Fetch metadata using lazy wheel, if possible.Nz3Lazy wheel is not used as hash checking is requiredz>Lazy wheel is not used as %r does not points to a remote wheelz+Obtaining dependency information from %s %s�#�rz"%s does not support range requests)r�r�rV�debugrqrrrrvr�namerx�versionr5�splitrr�r)r@r2�wheelr�r5r/r/r0� _fetch_metadata_using_lazy_wheel�s2
�

��z4RequirementPreparer._fetch_metadata_using_lazy_wheelF�partially_downloaded_reqsc
Cs�tddd�j}i}|D]}|jsJ�|||j<q|�|��|�}|D]\}\}}	t�d||�||}||_q"|D]}|�||�q9dS)z>Download any requirements which were only fetched by metadata.r8TrIzDownloading link %s to %sN)	r#r<r2r��keysrVr��local_file_path�_prepare_linked_requirement)
r@r�r�rN�links_to_fully_downloadr&�batch_downloadr2�filepath�_r/r/r0�_complete_partial_requirements�s 
��z2RequirementPreparer._complete_partial_requirementscCs�|jsJ�|j}|�|�t��Fd}|jdur(|jr(|�|�}t|j|j|�}|dur4||j|jj<n|�	|�}|durId|_
|Wd�S|�||�Wd�S1sYwYdS)z3Prepare a requirement to be obtained from req.link.NT)r2r�rrGrrr�rLr�r5r��needs_more_preparationr�)r@r&r�r2rlrH�
wheel_distr/r/r0�prepare_linked_requirement�s"



�
$�z.RequirementPreparer.prepare_linked_requirement�reqscCs�dd�|D�}|D]&}|jdur/|jjr/|�|�}t|j|j|�}|dur/||j|jj<d|_q	g}|D]}|jr?|�|�q4|�	||�q4|j
||d�dS)z,Prepare linked requirements more, if needed.cSsg|]}|jr|�qSr/)r�)�.0r&r/r/r0�
<listcomp>�szHRequirementPreparer.prepare_linked_requirements_more.<locals>.<listcomp>NF)r�)rGr2rrr�rLr�r5r��appendr�r�)r@r�r�r&rHrlr�r/r/r0� prepare_linked_requirements_more�s$
�
�z4RequirementPreparer.prepare_linked_requirements_morec	
Cs�|jsJ�|j}|�||�|�|�}|��r|jrd}n>|j|jvrHzt||j|j	|j
|j|�}Wn(tyG}z	t
d�|||���d}~ww|j|j}|rU|�|�t|dd�}|ra|j|_t||j|j|j�}|S)NzDCould not install requirement {} because of HTTP error {} for URL {})r=)r2r�r�ror�r5r�rtr�r�r4rGr
rr�rMr;r<r�r1r'r(r))	r@r&r�r2rH�
local_file�excrl�distr/r/r0r�sH

�
���
�z/RequirementPreparer._prepare_linked_requirementcCs�|jdusJ�|jdusJ�|j}|js|��r#|jr#|�|j�dS|��r/t�d|�dS|jdur6dSt	j
�|j|j�}t	j
�
|�sXt�|j|�t|�}t�d|�dSdS)NzENot copying link to destination directory since it is a directory: %szSaved %s)rGr2rnro�editable�archiverVr�r�r^r<rurvrwrT�copyrrx)r@r&r2�download_locationrzr/r/r0�save_linked_requirement4s(�
�z+RequirementPreparer.save_linked_requirementcCs�|jsJd��t�d|�t��-|jrtd�|���|�|j�|�	�t
||j|j|j
�}|�|j�Wd�|S1s@wY|S)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�rVrxrr�rr�r�r}�update_editabler1r'r(r)�check_if_existsr�)r@r&r�r/r/r0�prepare_editable_requirementNs*��
��z0RequirementPreparer.prepare_editable_requirement�skip_reasoncCs�|jsJd��|dusJd�|j���t�d|||jj�t��|jr)t�d�t|��	�Wd�S1s9wYdS)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 {}zRequirement %s: %s (%s)z�Since 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�rVrxr�rr�r�rr-)r@r&r�r/r/r0�prepare_installed_requirementls
���
$�z1RequirementPreparer.prepare_installed_requirement)F)rBrCrD�__doc__rEr�boolrrr�intrArr�r�rr�rrr�rr�r�r�r�r�r�r��
__classcell__r/r/r�r0r{�s��������	�
���
���6��
�% �
�"���
�!���
����
���
�-�
����r{)NN)Nr��loggingr>r^rT�typingrrrr�pip._vendor.packaging.utilsr�pip._internal.distributionsr�%pip._internal.distributions.installedr�pip._internal.exceptionsr	r
rrr
rr�"pip._internal.index.package_finderr�pip._internal.metadatar�pip._internal.models.linkr�pip._internal.models.wheelr�pip._internal.network.downloadrr� pip._internal.network.lazy_wheelrr�pip._internal.network.sessionr�pip._internal.req.req_installr�pip._internal.req.req_trackerr�pip._internal.utils.filesystemr�pip._internal.utils.hashesrr�pip._internal.utils.loggingr�pip._internal.utils.miscrr r!r"�pip._internal.utils.temp_dirr#�pip._internal.utils.unpackingr$�pip._internal.vcsr%�	getLoggerrBrVr�r1rEr�r:r;rQrYrkrmrtrLr{r/r/r/r0�<module>s�$	
����
�
�����
�����
��������
�7���
�