관리-도구
편집 파일: prepare.cpython-39.opt-1.pyc
a ����[��f]����������������������@���sR��d�Z�ddlZddlZddlZddlZddlmZmZmZm Z �ddl mZ�ddlm Z �ddlmZ�ddlmZmZmZmZmZmZmZ�ddlmZ�dd lmZ�dd lmZ�ddlmZ�ddl 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/m0Z0�ddl1m2Z2�ddl3m4Z4m5Z5m6Z6m7Z7�ddl8m9Z9�ddl:m;Z;�ddl<m=Z=�e�>e?�Z@e)e+eeAed�dd�ZBeeCdd�dd�ZDG�dd��d�ZEd3ee"e eC�e e/�eEd �d!d"�ZFeCeCdd#�d$d%�ZGeCeCdd&�d'd(�ZHd4ee eC�e e/�eEd)�d*d+�ZId5eeCe"e eC�e e/�e eE�d,�d-d.�ZJeeCe e/�e eC�d)�d/d0�ZKG�d1d2��d2�ZLdS�)6z)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�returnc�����������������C���sF���t�|��}|�|����|�||��W�d����n1�s40����Y��|���S�)z(Prepare a distribution for installation.N)r���ZtrackZprepare_distribution_metadata�get_metadata_distribution)r&���r'���r(���r)���Z abstract_dist��r,����D/usr/lib/python3.9/site-packages/pip/_internal/operations/prepare.py�_get_prepared_distribution1���s����*r.���)�link�locationr*���c�����������������C���s$���t��|�j�}|j|t|�j�d��d�S�)N)�url)r%���Zget_backend_for_scheme�scheme�unpackr ���r1���)r/���r0���Zvcs_backendr,���r,���r-����unpack_vcs_link>���s����r4���c�������������������@���s"���e�Zd�Zeee�dd�dd�ZdS�)�FileN)�path�content_typer*���c�����������������C���s*���||�_�|d�u�r t�|�d�|�_n||�_d�S�)Nr���)r6���� mimetypesZ guess_typer7���)�selfr6���r7���r,���r,���r-����__init__E���s����z File.__init__)�__name__� __module__�__qualname__�strr���r:���r,���r,���r,���r-���r5���D���s���r5���)r/����download�download_dir�hashesr*���c�����������������C���sV���t�ddd�}d�}|r t|�||�}|r.|}d�}n||�|j�\}}|rL|�|��t||�S�)Nr3���T��kindZglobally_managed)r#����_check_download_dirr6����check_against_pathr5���)r/���r?���r@���rA����temp_dir�already_downloaded_path� from_pathr7���r,���r,���r-����get_http_urlM���s���� rI���)�src�destr*���c�������������� ���C���sN���zt�|�|��W�n:�tjyH�}�z t�dt|�|�|��W�Y�d}~n d}~0�0�dS�)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�warningr>���)rJ���rK����er,���r,���r-����_copy2_ignoring_special_filese���s�����rQ���)�source�targetr*���c��������������������s^���t�j�|�}t�j�|��t�j�|��ttt�tt�d�����fdd�}tj��||dt d��d�S�)N)�d�namesr*���c��������������������s6���g�}|���kr|ddg7�}t�j�|���kr2|�g7�}|S�)Nz.toxz.nox)�osr6����abspath)rT���rU���Zskipped�rR���Ztarget_basenameZtarget_dirnamer,���r-����ignore~���s���� z!_copy_source_tree.<locals>.ignoreT)rY����symlinks� copy_function) rV���r6���rW����basename�dirnamer>���r���rL����copytreerQ���)rR���rS���Ztarget_abspathrY���r,���rX���r-����_copy_source_treey���s����"�r_���)r/���r@���rA���r*���c�����������������C���s<���d}|rt�|�||�}|r|}n|�j}|r2|�|��t|d�S�)z'Get file and optionally check its hash.N)rD���� file_pathrE���r5���)r/���r@���rA���rG���rH���r,���r,���r-����get_file_url����s���� ra���)r/���r0���r?���r@���rA���r*���c�����������������C���s����|�j�rt|�|��dS�|����r@tj�|�r0t|��t|�j|��dS�|�j rVt |�||d�}nt|�|||d�}|�js|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. N)rA���)�is_vcsr4����is_existing_dirrV���r6����isdirr"���r_���r`����is_filera���rI����is_wheelr$���r7���)r/���r0���r?���r@���rA����filer,���r,���r-���� unpack_url����s&���� � rh���c�����������������C���sn���t�j�||�j�}t�j�|�s dS�t�d|��|rjz|�|��W�n*�tyh���t� d|��t�� |��Y�dS�0�|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.)rV���r6����join�filename�existsrN����inforE���r ���rO����unlink)r/���r@���rA���� download_pathr,���r,���r-���rD�������s����� rD���c�����������������������s��e�Zd�ZdZeee�eeeeee eeeedd� ��fdd�Z edd�dd�Zeedd �d d�Z eed�dd �Zeee�d�dd�Zd#ee�edd�dd�Zd$eeed �dd�Zd%ee�edd�dd�Zeeed �dd�Zedd�dd�Zeed�dd�Zeeed �d!d"�Z���ZS�)&�RequirementPreparerzPrepares a RequirementN) � build_dirr@����src_dirr)���r'����session�progress_barr(����require_hashes� use_user_site� lazy_wheel� in_tree_buildr*���c ����������� ���������st���t�������||�_||�_||�_||�_t||�|�_t||�|�_ ||�_ ||�_||�_| |�_ | |�_||�_||�_i�|�_d|�_d�S�)N)��rx���)�superr:���rq���rp���r'����_sessionr���� _downloadr����_batch_downloadr(���r@���r)���rt���ru����use_lazy_wheelrw����_downloaded�_previous_requirement_header) r9���rp���r@���rq���r)���r'���rr���rs���r(���rt���ru���rv���rw����� __class__r,���r-���r:�����s ���� zRequirementPreparer.__init__)r&���r*���c�����������������C���s����|j�jr$|js$d}tt|j�j��}nd}t|jp2|�}||f|�jkrZ||f|�_t� ||��|jr�t ��� �t� d|j�j��W�d����n1�s�0����Y��dS�)z3Provide context for the requirement being prepared.z Processing %sz Collecting %szUsing cached %sN)r/���re���Zoriginal_link_is_in_wheel_cacher>���r���r`���r&���r���rN���rl���r���rj���)r9���r&����messageZinformationr,���r,���r-����_log_preparing_link3��s���� z'RequirementPreparer._log_preparing_link)r&����parallel_buildsr*���c�����������������C���s\���|j�jrdS�|j����r*|�jr*|j�j|_dS�|j|�jd|d��t|j�rXt d� ||j���dS�)z1Ensure source_dir of a linked InstallRequirement.NT)Z 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.)r/���rf���rc���rw���r`���� source_dir�ensure_has_source_dirrp���r!���r����format)r9���r&���r����r,���r,���r-����_ensure_link_req_src_dirD��s ���� � ��z,RequirementPreparer._ensure_link_req_src_dirc�����������������C���sX���|�j�s|jdd�S�|jjr t���|j���r0t���|jd�u�rF|jsFt ���|jdd�pVt ��S�)NT)Ztrust_internetF)rt���rA���r/���rb���r���rc���r ���Z original_linkZ is_pinnedr���r���)r9���r&���r,���r,���r-����_get_linked_req_hashesi��s���� z*RequirementPreparer._get_linked_req_hashes)r/���r*���c�����������������C���s����|�j�s dS�|�jrt�d��dS�|js*|js:t�d|��dS�t|j�}t|j �}t� d||j��|j� dd�d�}zt|||�j�W�S��ty����t�d|��Y�dS�0�dS�) 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�#����r���z"%s does not support range requests)r}���rt���rN����debugre���rf���r���rj���r����namerl����versionr1����splitr���rz���r���)r9���r/���Zwheelr����r1���r,���r,���r-���� _fetch_metadata_using_lazy_wheel���s0���� � �z4RequirementPreparer._fetch_metadata_using_lazy_wheelF)�partially_downloaded_reqsr����r*���c����������� ������C���s~���t�ddd�j}i�}|D�]}|||j<�q|��|���|�}|D�](\}\}} t�d||��||�}||_q:|D�]}|��||��qhdS�)z>Download any requirements which were only fetched by metadata.r3���TrB���zDownloading link %s to %sN) r#���r6���r/���r|����keysrN���r�����local_file_path�_prepare_linked_requirement) r9���r����r����rF���Zlinks_to_fully_downloadr&���Zbatch_downloadr/����filepath�_r,���r,���r-����_complete_partial_requirements���s�����z2RequirementPreparer._complete_partial_requirementsc�����������������C���s����|j�}|��|��t�����d}|�jdurF|jrF|��|�}t|j�|�j|�}|dur^||�j|j�j<�n*|�� |�}|dur�d|_ |W��d����S�|��||�W��d����S�1�s�0����Y��dS�)z3Prepare a requirement to be obtained from req.link.NT)r/���r����r���r@���rf���r����rD���r~���r1���r�����needs_more_preparationr����)r9���r&���r����r/���r`���rA���Z wheel_distr,���r,���r-����prepare_linked_requirement���s���� z.RequirementPreparer.prepare_linked_requirement)�reqsr����r*���c�����������������C���s����dd��|D��}|D�]L}|�j�dur|jjr|��|�}t|j|�j�|�}|dur||�j|jj<�d|_qg�}|D�]"}|jr~|�|��qh|�� ||��qh|�j ||d��dS�)z,Prepare linked requirements more, if needed.c�����������������S���s���g�|�]}|j�r|�qS�r,���)r����)�.0r&���r,���r,���r-���� <listcomp>��������zHRequirementPreparer.prepare_linked_requirements_more.<locals>.<listcomp>NF)r����)r@���r/���rf���r����rD���r~���r1���r�����appendr����r����)r9���r����r����r&���rA���r`���r����r,���r,���r-���� prepare_linked_requirements_more���s"���� �z4RequirementPreparer.prepare_linked_requirements_morec����������� ��� ���C���s����|j�}|��||��|��|�}|���r0|�jr0d�}n�|j|�jvr�zt||j|�j |�j |�}W�q��ty��}�ztd� |||���W�Y�d�}~q�d�}~0�0�n&|�j|j�}|r�|�|��t|d�d�}|r�|j|_t||�j|�j|�j�}|S�)NzDCould not install requirement {} because of HTTP error {} for URL {})r7���)r/���r����r����rc���rw���r1���r~���rh���r����r{���r@���r ���r���r����rE���r5���r6���r����r.���r'���r(���r)���) r9���r&���r����r/���rA���Z local_file�excr`����distr,���r,���r-���r������s:���� ��� �z/RequirementPreparer._prepare_linked_requirementc�����������������C���s����|j�}|js|���r*|jr*|�|�j��d�S�|���rBt�d|��d�S�|jd�u�rPd�S�t j �|�j|j�}t j � |�s�t�|j|��t|�}t�d|��d�S�)NzENot copying link to destination directory since it is a directory: %szSaved %s)r/���rb���rc���Zeditable�archiver@���rN���r����r����rV���r6���ri���rj���rk���rL����copyr���rl���)r9���r&���r/���Zdownload_locationrn���r,���r,���r-����save_linked_requirement*��s"����� z+RequirementPreparer.save_linked_requirementc�����������������C���s~���t��d|��t���X�|�jr(td�|���|�|�j��|����t ||�j |�j|�j�}|� |�j��W�d����n1�sp0����Y��|S�)z Prepare an editable requirement.zObtaining %szoThe editable requirement {} cannot be installed when requiring hashes, because there is no single file to hash.N)rN���rl���r���rt���r���r����r����rq���Zupdate_editabler.���r'���r(���r)���Zcheck_if_existsru���)r9���r&���r����r,���r,���r-����prepare_editable_requirementD��s$�������*z0RequirementPreparer.prepare_editable_requirement)r&����skip_reasonr*���c�����������������C���sZ���t��d|||jj��t���,�|�jr,t��d��t|����W��d����S�1�sL0����Y��dS�)z)Prepare an already-installed requirement.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.N) rN���rl���Zsatisfied_byr����r���rt���r����r���r+���)r9���r&���r����r,���r,���r-����prepare_installed_requirementb��s������z1RequirementPreparer.prepare_installed_requirement)F)F)F)r;���r<���r=����__doc__r>���r����boolr���r���r���r:���r���r����r����r���r����r���r���r����r���r����r����r����r����r����r����r����� __classcell__r,���r,���r����r-���ro�������sd����2�%"�"���!�������(� �ro���)NN)NN)NN)Mr����Zloggingr8���rV���rL����typingr���r���r���r���Zpip._vendor.packaging.utilsr���Zpip._internal.distributionsr���Z%pip._internal.distributions.installedr���Zpip._internal.exceptionsr ���r ���r���r���r ���r���r���Z"pip._internal.index.package_finderr���Zpip._internal.metadatar���Zpip._internal.models.linkr���Zpip._internal.models.wheelr���Zpip._internal.network.downloadr���r���Z pip._internal.network.lazy_wheelr���r���Zpip._internal.network.sessionr���Zpip._internal.req.req_installr���Zpip._internal.req.req_trackerr���Zpip._internal.utils.filesystemr���Zpip._internal.utils.hashesr���r���Zpip._internal.utils.loggingr���Zpip._internal.utils.miscr���r ���r!���r"���Zpip._internal.utils.temp_dirr#���Zpip._internal.utils.unpackingr$���Zpip._internal.vcsr%���Z getLoggerr;���rN���r����r.���r>���r4���r5���rI���rQ���r_���ra���rh���rD���ro���r,���r,���r,���r-����<module>���s����$ � �����������7 �