3 ReM@s:dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z mZmZmZmZmZddlmZddlmZdd lmZdd lmZmZmZmZdd lmZdd l m!Z!dd l"m#Z#ddl$m%Z%e!rddl&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddlm-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddlm8Z8ere,de'e9e(e9ge(e9fe:dddZ;n8e,de'e9e9gdfe'e9e(e9ge(e9fe:e:dddZ;ejddZ?dd Z@Gd!d"d"eAZBd3d#d$ZCd%d&ZDd'd(ZEd4d)d*ZFd5d+d,ZGd-d.ZHd/d0ZIGd1d2d2eAZJdS)6z)Prepares a distribution for installation N)PY2))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupported HashMismatch HashUnpinnedInstallationErrorNetworkConnectionErrorPreviousBuildDirErrorVcsHashUnsupported) copy2_fixed) MissingHashes) indent_log) display_pathhide_urlpath_to_displayrmtree) TempDirectory)MYPY_CHECK_RUNNING) unpack_file)vcs)CallableListOptionalTuple) TypedDict)AbstractDistribution) PackageFinder)Link) Downloader)InstallRequirement)RequirementTracker)HashesCopytreeKwargs)ignoresymlinksF)total) copy_functionr$ignore_dangling_symlinksr%c Cs.t|}|j||j||WdQRX|S)z-Prepare a distribution for installation. N)rtrackprepare_distribution_metadata)req req_trackerfinderbuild_isolation abstract_distr0/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/operations/prepare.py_get_prepared_distributionPs  r2cCs0tj|j}|dk st|j|t|jddS)N)url)rget_backend_for_schemeschemeAssertionErrorunpackrr3)linklocation vcs_backendr0r0r1unpack_vcs_link_s  r;c@seZdZddZdS)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)kindglobally_managedr)r_check_download_dir mimetypes guess_type_download_http_urlr=r<)r8 downloader download_dirhashestemp_diralready_downloaded_path from_pathr>r0r0r1 get_http_urlms  rPcCsTyt||Wn@tjk rN}z"tjdt|t|t|WYdd}~XnXdS)zCopying 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 shutilSpecialFileErrorloggerwarningstrr)srcdester0r0r1_copy2_ignoring_special_filessrYcs`tjj|}tjj|tjj|fdd}t|dd}tsLt|d<tj |f|dS)Ncs6g}|kr|ddg7}tjj|kr2|g7}|S)Nz.toxz.nox)osr=abspath)dnamesskipped)sourcetarget_basenametarget_dirnamer0r1r$s   z!_copy_source_tree..ignoreT)r$r%r') rZr=r[basenamedirnamedictrrYrQcopytree)r_targettarget_abspathr$kwargsr0)r_r`rar1_copy_source_trees    ricCsJd}|rt|||}|r|}n|j}|r2|j|tj|d}t||S)z,Get file and optionally check its hash. Nr)rF file_pathcheck_against_pathrGrHr<)r8rKrLrNrOr>r0r0r1 get_file_urls   rlcCs|jrt||dS|jr@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=isdirrrirjis_filerlrPis_wheelrr>)r8r9rJrKrLfiler0r0r1 unpack_urls$   rsc Csj||}tjj||j}t|d }x|jD]}|j|q,WWdQRX|rV|j|||jj j ddfS)z6Download link url into temp_dir using provided sessionwbNz content-type) rZr=joinfilenameopenchunkswriterkresponseheadersget)r8rJrMrLdownloadrj content_filechunkr0r0r1rIs   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=rvrwexistsrSinforkrrTunlink)r8rKrL download_pathr0r0r1rF#s   rFcs^eZdZdZfddZeddZddZdd Zd d Z dd dZ ddZ ddZ Z S)RequirementPreparerzPrepares a Requirement c sNtt|j||_||_||_||_||_||_||_ ||_ | |_ | |_ dS)N) superrr@src_dir build_dirr,rJr-rKwheel_download_dirr.require_hashes use_user_site) r?rrKrrr.r,rJr-rr) __class__r0r1r@AszRequirementPreparer.__init__cCs:|js dStjj|jrdStjdtdj|jdS)NFTz!Could not find download directoryz0Could not find or access download directory '{}')rKrZr=rrScriticalrformat)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)r8rprjrSrrr+)r?r+r=r0r0r1_log_preparing_link|sz'RequirementPreparer._log_preparing_linkcCsZ|jjr dS|jdkst|j|jd|dtjjtjj |jdrVt dj ||jdS)z1Ensure source_dir of a linked InstallRequirement.NT) autodeleteparallel_buildszsetup.pyzpip 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_dirr6ensure_has_source_dirrrZr=rrvr r)r?r+rKrr0r0r1_ensure_link_req_src_dirsz,RequirementPreparer._ensure_link_req_src_dircCsZ|js|jddS|jjr t|jjr0t|jdkrH|j rHt |jddpXt S)NT)trust_internetF) rrLr8rmr rnr original_link is_pinnedrr )r?r+r0r0r1_get_linked_req_hashess  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"|jrtjdnF|r"tjj||j}tjj|s"tj|j|t|} tjd| |jr>|j r>|j!|jWdQRX|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)"r8r6rrqrrKrrrsrrJrr rrr=local_file_pathr2r,r-r.rnrSrrZrvrwrrQcopyrrrmarchive) r?r+rr8rK local_fileexcr/download_locationrr0r0r1prepare_linked_requirementsD        z.RequirementPreparer.prepare_linked_requirementc Cs|jstdtjd|tf|jr6tdj||j|j |j |j t ||j |j|j}|j rv|j|j|j|jWdQRX|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)editabler6rSrrrrrrrupdate_editablerr2r,r-r.rrKcheck_if_existsr)r?r+r/r0r0r1prepare_editable_requirements   z0RequirementPreparer.prepare_editable_requirementc Csh|jstd|dk s&tdj|jtjd|||jjt|jrRtjdt |}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)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_byr6rrSrversionrrdebugr)r?r+ skip_reasonr/r0r0r1prepare_installed_requirements  z1RequirementPreparer.prepare_installed_requirement)F)rArBrC__doc__r@propertyrrrrrrr __classcell__r0r0)rr1r=s -  ! 4r)NN)NN)NN)KrloggingrGrZrQZpip._vendor.sixrpip._internal.distributionsr%pip._internal.distributions.installedrpip._internal.exceptionsrrrrr r r pip._internal.utils.filesystemr pip._internal.utils.hashesr pip._internal.utils.loggingrpip._internal.utils.miscrrrrpip._internal.utils.temp_dirrpip._internal.utils.typingrpip._internal.utils.unpackingrpip._internal.vcsrtypingrrrrZmypy_extensionsrr"pip._internal.index.package_finderrpip._internal.models.linkrpip._internal.network.downloadrZpip._internal.req.req_installr pip._internal.req.req_trackerr!r"rUboolr# getLoggerrArSr2r;objectr<rPrYrirlrsrIrFrr0r0r0r1sl   $                   " " +