3 ”Re¿Mã@s:dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z mZmZmZmZmZddlmZddlmZdd lmZdd lmZmZmZmZdd lmZdd l m!Z!dd l"m#Z#ddl$m%Z%e!�r¾ddl&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddlm-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddlm8Z8e�r†e,de'e9e(e9ge(e9fe:dœdd�Z;n8e,de'e9e9gdfe'e9e(e9ge(e9fe:e:dœdd�Z;ejdd„Z?dd „Z@Gd!d"„d"eAƒZBd3d#d$„ZCd%d&„ZDd'd(„ZEd4d)d*„ZFd5d+d,„ZGd-d.„ZHd/d0„ZIGd1d2„d2eAƒZJdS)6z)Prepares a distribution for installation éN)ÚPY2)Ú)make_distribution_for_install_requirement)ÚInstalledDistribution)ÚDirectoryUrlHashUnsupportedÚ HashMismatchÚ HashUnpinnedÚInstallationErrorÚNetworkConnectionErrorÚPreviousBuildDirErrorÚVcsHashUnsupported)Ú copy2_fixed)Ú MissingHashes)Ú indent_log)Ú display_pathÚhide_urlÚpath_to_displayÚrmtree)Ú TempDirectory)ÚMYPY_CHECK_RUNNING)Ú unpack_file)Úvcs)ÚCallableÚListÚOptionalÚTuple)Ú TypedDict)ÚAbstractDistribution)Ú PackageFinder)ÚLink)Ú Downloader)ÚInstallRequirement)ÚRequirementTracker)ÚHashesÚCopytreeKwargs)ÚignoreÚsymlinksF)Útotal)Ú copy_functionr$Úignore_dangling_symlinksr%c Cs.t|ƒ}|j|ƒ�|j||ƒWdQRX|S)z-Prepare a distribution for installation. N)rÚtrackÚprepare_distribution_metadata)ÚreqÚ req_trackerÚfinderÚbuild_isolationÚ abstract_dist©r0ú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/operations/prepare.pyÚ_get_prepared_distributionPs  r2cCs0tj|jƒ}|dk st‚|j|t|jƒd�dS)N)Úurl)rÚget_backend_for_schemeÚschemeÚAssertionErrorÚunpackrr3)ÚlinkÚlocationÚ vcs_backendr0r0r1Úunpack_vcs_link_s  r;c@seZdZdd„ZdS)ÚFilecCs||_||_dS)N)ÚpathÚ content_type)Úselfr=r>r0r0r1Ú__init__gsz File.__init__N)Ú__name__Ú __module__Ú __qualname__r@r0r0r0r1r<fsr<cCsVtddd�}d}|r t|||ƒ}|r8|}tj|ƒd}nt|||j|ƒ\}}t||ƒS)Nr7T)ÚkindÚglobally_managedr)rÚ_check_download_dirÚ mimetypesÚ guess_typeÚ_download_http_urlr=r<)r8Ú downloaderÚ download_dirÚhashesÚtemp_dirÚalready_downloaded_pathÚ from_pathr>r0r0r1Ú get_http_urlms  rPcCsTyt||ƒWn@tjk rN}z"tjdt|ƒt|ƒt|ƒƒWYdd}~XnXdS)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ÚwarningÚstrr)ÚsrcÚdestÚer0r0r1Ú_copy2_ignoring_special_filesˆsrYcs`tjj|ƒ}tjj|ƒ‰tjj|ƒ‰‡‡‡fdd„}t|dd�}tsLt|d<tj ˆ|f|ŽdS)Ncs6g}|ˆkr|ddg7}tjj|ƒˆkr2|ˆg7}|S)Nz.toxz.nox)Úosr=Úabspath)ÚdÚnamesÚskipped)ÚsourceÚtarget_basenameÚtarget_dirnamer0r1r$£s   z!_copy_source_tree..ignoreT)r$r%r') rZr=r[ÚbasenameÚdirnameÚdictrrYrQÚcopytree)r_ÚtargetÚtarget_abspathr$Úkwargsr0)r_r`rar1Ú_copy_source_tree�s    ricCsJd}|rt|||ƒ}|r|}n|j}|r2|j|ƒtj|ƒd}t||ƒS)z,Get file and optionally check its hash. Nr)rFÚ file_pathÚcheck_against_pathrGrHr<)r8rKrLrNrOr>r0r0r1Ú get_file_url½s   rlcCs€|jrt||ƒdS|jƒr@tjj|ƒr0t|ƒt|j|ƒdS|j rVt |||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. N)rL)Úis_vcsr;Úis_existing_dirrZr=ÚisdirrrirjÚis_filerlrPÚis_wheelrr>)r8r9rJrKrLÚfiler0r0r1Ú unpack_urlÞs$   rsc Csj||ƒ}tjj||jƒ}t|dƒ� }x|jD]}|j|ƒq,WWdQRX|rV|j|ƒ||jj j ddƒfS)z6Download link url into temp_dir using provided sessionÚwbNz content-typeÚ) rZr=ÚjoinÚfilenameÚopenÚchunksÚwriterkÚresponseÚheadersÚget)r8rJrMrLÚdownloadrjÚ content_fileÚchunkr0r0r1rIs   rIc Csntjj||jƒ}tjj|ƒs dStjd|ƒ|rjy|j|ƒWn*tk rhtj d|ƒtj |ƒdSX|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.) rZr=rvrwÚexistsrSÚinforkrrTÚunlink)r8rKrLÚ download_pathr0r0r1rF#s   rFcs^eZdZdZ‡fdd„Zedd„ƒZdd„Zdd „Zd d „Z dd d„Z dd„Z dd„Z ‡Z S)ÚRequirementPreparerzPrepares a Requirement c sNtt|ƒjƒ||_||_||_||_||_||_||_ ||_ | |_ | |_ dS)N) Úsuperr…r@Úsrc_dirÚ build_dirr,rJr-rKÚwheel_download_dirr.Úrequire_hashesÚ use_user_site) r?rˆrKr‡r‰r.r,rJr-rŠr‹)Ú __class__r0r1r@AszRequirementPreparer.__init__cCs:|js dStjj|jƒrdStjdƒtdj|jƒƒ‚dS)NFTz!Could not find download directoryz0Could not find or access download directory '{}')rKrZr=r�rSÚcriticalrÚformat)r?r0r0r1Ú_download_should_savens z)RequirementPreparer._download_should_savecCs8|jjr"|jj}tjdt|ƒƒntjd|jp0|ƒdS)zLog the way the link prepared.z Processing %sz Collecting %sN)r8rprjrSr‚rr+)r?r+r=r0r0r1Ú_log_preparing_link|sz'RequirementPreparer._log_preparing_linkcCsZ|jjr dS|jdkst‚|j|jd|d�tjjtjj |jdƒƒrVt dj ||jƒƒ‚dS)z1Ensure source_dir of a linked InstallRequirement.NT)Ú autodeleteÚparallel_buildszsetup.pyzí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.) r8rqÚ source_dirr6Úensure_has_source_dirrˆrZr=r�rvr rŽ)r?r+rKr’r0r0r1Ú_ensure_link_req_src_dir…sz,RequirementPreparer._ensure_link_req_src_dircCsZ|js|jdd�S|jjr tƒ‚|jjƒr0tƒ‚|jdkrH|j rHt ƒ‚|jdd�pXt ƒS)NT)Útrust_internetF) rŠrLr8rmr rnrÚ original_linkÚ is_pinnedrr )r?r+r0r0r1Ú_get_linked_req_hashes£s  z*RequirementPreparer._get_linked_req_hashesFc CsL|js t‚|j}|j|ƒ|jr.|jr.|j}n|j}tƒ��|j|||ƒy t||j |j ||j |ƒd�}Wn4t k r }zt dj|||ƒƒ‚WYdd}~XnX|r®|j|_t||j|j|jƒ}|�r"|jƒrÜtjdƒnF|�r"tjj||jƒ}tjj|ƒ�s"tj|j|ƒt|ƒ} tjd| ƒ|j�r>|j �r>|j!|jƒWdQRX|S)z3Prepare a requirement to be obtained from req.link.)rLzDCould not install requirement {} because of HTTP error {} for URL {}Nz*Link is a directory, ignoring download_dirzSaved %s)"r8r6r�rqr‰rKrr•rsr“rJr™r rrŽr=Úlocal_file_pathr2r,r-r.rnrSr‚rZrvrwr�rQÚcopyrr�rmÚarchive) r?r+r’r8rKÚ local_fileÚexcr/Údownload_locationr„r0r0r1Úprepare_linked_requirementÄsD        z.RequirementPreparer.prepare_linked_requirementc Cs�|jstdƒ‚tjd|ƒtƒ�f|jr6tdj|ƒƒ‚|j|j ƒ|j |j ƒt ||j |j|jƒ}|j rv|j|jƒ|j|jƒWdQRX|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)Úeditabler6rSr‚rrŠrrŽr”r‡Úupdate_editabler�r2r,r-r.rœrKÚcheck_if_existsr‹)r?r+r/r0r0r1Úprepare_editable_requirementøs   z0RequirementPreparer.prepare_editable_requirementc Csh|jstdƒ‚|dk s&tdj|jƒƒ‚tjd|||jjƒtƒ�|jrRtjdƒt |ƒ}WdQRX|S)z1Prepare 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_byr6rŽrSr‚ÚversionrrŠÚdebugr)r?r+Ú skip_reasonr/r0r0r1Úprepare_installed_requirements  z1RequirementPreparer.prepare_installed_requirement)F)rArBrCÚ__doc__r@Úpropertyr�r�r•r™r r¤r©Ú __classcell__r0r0)rŒr1r…=s -  ! 4r…)NN)NN)NN)KrªÚloggingrGrZrQZpip._vendor.sixrÚpip._internal.distributionsrÚ%pip._internal.distributions.installedrÚpip._internal.exceptionsrrrrr r r Úpip._internal.utils.filesystemr Úpip._internal.utils.hashesr Úpip._internal.utils.loggingrÚpip._internal.utils.miscrrrrÚpip._internal.utils.temp_dirrÚpip._internal.utils.typingrÚpip._internal.utils.unpackingrÚpip._internal.vcsrÚtypingrrrrZmypy_extensionsrrÚ"pip._internal.index.package_finderrÚpip._internal.models.linkrÚpip._internal.network.downloadrZpip._internal.req.req_installr Úpip._internal.req.req_trackerr!r"rUÚboolr#Ú getLoggerrArSr2r;Úobjectr<rPrYrirlrsrIrFr…r0r0r0r1Úsl   $                   " " +