a  zea@sdZddlZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z ddl mZddlmZddlmZddlmZmZmZmZmZmZmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#dd l$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:ddl;mZ>ddl?m@Z@eAeBZCddZDddZEGdddZFd-dd ZGd!d"ZHd#d$ZId.d%d&ZJd/d'd(ZKd)d*ZLGd+d,d,ZMdS)0z)Prepares a distribution for installation N)DictIterableListOptionalTuple)canonicalize_name) Distribution))make_distribution_for_install_requirement)InstalledDistribution)DirectoryUrlHashUnsupported HashMismatch HashUnpinnedInstallationErrorNetworkConnectionErrorPreviousBuildDirErrorVcsHashUnsupported) PackageFinder)Link)Wheel)BatchDownloader Downloader)HTTPRangeRequestUnsupporteddist_from_wheel_url) PipSession)InstallRequirement)RequirementTracker) deprecated) copy2_fixed)Hashes MissingHashes) indent_log) display_pathhide_urlis_installable_dirrmtree) TempDirectory) unpack_file)vcscCsFt|}|||||Wdn1s40Y|S)z(Prepare a distribution for installation.N)r trackprepare_distribution_metadataget_pkg_resources_distribution)req req_trackerfinderbuild_isolation abstract_distr0b/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/operations/prepare.py_get_prepared_distribution2s *r2cCs0t|j}|dusJ|j|t|jddS)N)url)r'get_backend_for_schemeschemeunpackr"r3)linklocation vcs_backendr0r0r1unpack_vcs_link@s  r:c@seZdZddZdS)FilecCs*||_|dur t|d|_n||_dS)Nr)path mimetypes guess_type content_type)selfr<r?r0r0r1__init__Isz File.__init__N)__name__ __module__ __qualname__rAr0r0r0r1r;Gsr;cCsVtddd}d}|r t|||}|r.|}d}n|||j\}}|rL||t||S)Nr6Tkindglobally_managed)r%_check_download_dirr<check_against_pathr;)r7download download_dirhashestemp_diralready_downloaded_path from_pathr?r0r0r1 get_http_urlRs  rPc CsNzt||Wn:tjyH}z tdt|||WYd}~n d}~00dS)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)rshutilSpecialFileErrorloggerwarningstr)srcdester0r0r1_copy2_ignoring_special_filesmsrYcsLtj|}tj|tj|fdd}tj||dtddS)Ncs6g}|kr|ddg7}tj|kr2|g7}|S)Nz.toxz.nox)osr<abspath)dnamesskippedsourcetarget_basenametarget_dirnamer0r1ignores   z!_copy_source_tree..ignoreT)rcsymlinks copy_function)rZr<r[basenamedirnamerQcopytreerY)r`targettarget_abspathrcr0r_r1_copy_source_trees   rkcCs<d}|rt|||}|r|}n|j}|r2||t|dS)z,Get file and optionally check its hash. N)rH file_pathrIr;)r7rKrLrNrOr0r0r1 get_file_urls  rmcCs|jrt||dS|rPtdddddtj|r@t|t|j |dS|j rft |||d}nt ||||d}|j st|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. NzA future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default. z21.3i) replacementgone_inissue)rL)is_vcsr:is_existing_dirrrZr<isdirr$rkrlis_filermrPis_wheelr&r?)r7r8rJrKrLfiler0r0r1 unpack_urls2    rwcCsntj||j}tj|s dStd||rjz||Wn*tyht d|t |YdS0|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<joinfilenameexistsrSinforIr rTunlink)r7rKrL download_pathr0r0r1rHs    rHcs~eZdZdZfddZddZddZdd Zd d Zdd dZ dddZ dddZ ddZ ddZ ddZddZZS)RequirementPreparerzPrepares a Requirement c stt||_||_||_||_t|||_t|||_ ||_ ||_ ||_ | |_ | |_| |_| |_i|_d|_dS)N)r)superrAsrc_dir build_dirr,_sessionr _downloadr_batch_downloadr-rKr.require_hashes use_user_siteuse_lazy_wheel in_tree_build _downloaded_previous_requirement_header) r@rrKrr.r,session progress_barr-rr lazy_wheelr __class__r0r1rAs    zRequirementPreparer.__init__cCs|jjr$|js$d}tt|jj}nd}t|jp2|}||f|jkrZ||f|_t |||jrt t d|jj Wdn1s0YdS)z3Provide context for the requirement being prepared.z Processing %sz Collecting %szUsing cached %sN) r7rtoriginal_link_is_in_wheel_cacherUr!rlr+rrSr{r ry)r@r+message informationr0r0r1_log_preparing_linkOs  z'RequirementPreparer._log_preparing_linkcCsj|jjr dS|jdusJ|jr8|jr8|jj|_dS|j|jd|dt|jrft d ||jdS)z1Ensure source_dir of a linked InstallRequirement.NT) autodeleteparallel_buildszpip 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.) r7ru source_dirrrrrlensure_has_source_dirrr#rformat)r@r+rr0r0r1_ensure_link_req_src_diras"  z,RequirementPreparer._ensure_link_req_src_dircCsX|js|jddS|jjr t|jr0t|jdurF|jsFt |jddpVt S)NT)trust_internetF) rrLr7rqrrrr original_link is_pinnedr r)r@r+r0r0r1_get_linked_req_hashess  z*RequirementPreparer._get_linked_req_hashescCs|js dS|jrtddS|js*|js:td|dSt|j}t|j }t d||j |j ddd}zt|||jWStytd|YdS0dS) 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)rrrSdebugrtrurryrnamer{versionr3splitrrr)r@r7wheelrr3r0r0r1 _fetch_metadata_using_lazy_wheels.      z4RequirementPreparer._fetch_metadata_using_lazy_wheelFc Cstdddj}i}|D]}|js$J|||j<q|||}|D](\}\}} td||||}||_qD|D]}|||qrdS)z>Download any requirements which were only fetched by metadata.r6TrEzDownloading link %s to %sN) r%r<r7rkeysrSrlocal_file_path_prepare_linked_requirement) r@partially_downloaded_reqsrrMlinks_to_fully_downloadr+batch_downloadr7filepath_r0r0r1_complete_partial_requirementss   z2RequirementPreparer._complete_partial_requirementscCs|js J|j}||td}|jdurP|jrP||}t|j|j|}|durl|df|j|jj<n*| |}|durd|_ |WdS| ||WdS1s0YdS)z3Prepare a requirement to be obtained from req.link.NT) r7rr rKrurrHrr3rneeds_more_preparationr)r@r+rr7rlrL wheel_distr0r0r1prepare_linked_requirements    z.RequirementPreparer.prepare_linked_requirementcCsdd|D}|D]P}|jdur|jjr||}t|j|j|}|dur|df|j|jj<d|_qg}|D]"}|jr||ql| ||ql|j ||ddS)z,Prepare linked requirements more, if needed.cSsg|]}|jr|qSr0)r).0r+r0r0r1 zHRequirementPreparer.prepare_linked_requirements_more..NF)r) rKr7rurrHrr3rappendrr)r@reqsrr+rLrlrr0r0r1 prepare_linked_requirements_mores   z4RequirementPreparer.prepare_linked_requirements_morec Cs|js J|j}|||||}|r:|jr:d}n|j|jvrzt||j|j |j |}Wqt y}zt d |||WYd}~qd}~00n(|j|j\}}|r||t||}|r|j|_t||j|j|j} | S)NzDCould not install requirement {} because of HTTP error {} for URL {})r7rrrrrr3rrwrrrKrrrrIr;r<rr2r,r-r.) r@r+rr7rL local_fileexcrlr?distr0r0r1rs8       z/RequirementPreparer._prepare_linked_requirementcCs|jdusJ|jdusJ|j}|js6|rF|jrF||jdS|r^td|dS|jdurldSt j |j|j }t j |st|j|t|}td|dS)NzENot copying link to destination directory since it is a directory: %szSaved %s)rKr7rqrreditablearchiverSrrrZr<rxryrzrQcopyr!r{)r@r+r7download_locationr}r0r0r1save_linked_requirement?s&   z+RequirementPreparer.save_linked_requirementcCs|jsJdtd|tX|jr6td|||j| t ||j |j |j }||jWdn1s~0Y|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)rrSr{r rrrrrupdate_editabler2r,r-r.check_if_existsr)r@r+rr0r0r1prepare_editable_requirementYs   *z0RequirementPreparer.prepare_editable_requirementcCs|jsJd|dus&Jd|jtd|||jjt,|jrRtdt| WdS1sr0YdS)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_byrrSr{rr rrr r*)r@r+ skip_reasonr0r0r1prepare_installed_requirementvs   z1RequirementPreparer.prepare_installed_requirement)F)F)F)rBrCrD__doc__rArrrrrrrrrrr __classcell__r0r0rr1r~s 3#! !  %r~)NN)NN)NN)Nrloggingr=rZrQtypingrrrrrpip._vendor.packaging.utilsrpip._vendor.pkg_resourcesrpip._internal.distributionsr %pip._internal.distributions.installedr pip._internal.exceptionsr r r rrrr"pip._internal.index.package_finderrpip._internal.models.linkrpip._internal.models.wheelrpip._internal.network.downloadrr pip._internal.network.lazy_wheelrrpip._internal.network.sessionrZpip._internal.req.req_installrpip._internal.req.req_trackerrpip._internal.utils.deprecationrpip._internal.utils.filesystemrpip._internal.utils.hashesrrpip._internal.utils.loggingr pip._internal.utils.miscr!r"r#r$pip._internal.utils.temp_dirr%pip._internal.utils.unpackingr&pip._internal.vcsr' getLoggerrBrSr2r:r;rPrYrkrmrwrHr~r0r0r0r1sV    $              ! " ?