U n a{@s,ddlmZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z"ddl#m$Z$ddl#m%Z&ddl'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>ddl?m@Z@ddlAmBZBmCZCddlDmEZEddlFmGZGddlHmIZIeErddlJmKZKmLZLmMZMmNZNmOZOmPZPmQZQddlmRZRdd lSmTZTdd!lUmVZVdd"lWmXZXeYeZZ[d#d$Z\Gd%d&d&e]Z^dS)')absolute_importN) pkg_resourcessix) Requirement)canonicalize_name)Version)parse)Pep517HookCaller)NoOpBuildEnvironment)InstallationError) get_scheme)Link)generate_metadata)install_editable)LegacyInstallFailure)install) install_wheel)load_pyproject_tomlmake_pyproject_path)UninstallPathSet) deprecated)direct_url_from_link)Hashes) indent_log)ask_path_exists backup_dir display_pathdist_in_site_packagesdist_in_usersiteget_installed_versionhide_urlredact_auth_from_url) get_metadata) TempDirectory tempdir_kinds)MYPY_CHECK_RUNNING)running_under_virtualenv)vcs)AnyDictIterableListOptionalSequenceUnion)BuildEnvironment) Distribution) SpecifierSet)MarkercCs|tj}tj|\}}t||}|drJtj}tj |d}n.|dsXt tj }tj |ddd}||||dS)zQReturn a pkg_resources.Distribution for the provided metadata directory. z .egg-inforz .dist-info-) project_namemetadata) rstriposseppathsplitr PathMetadataendswithr0splitextAssertionErrorDistInfoDistribution)metadata_directorydist_dirbase_dir dist_dir_namer5dist_cls dist_namerF^C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\req\req_install.py _get_distBs   rHc @sFeZdZdZdFddZddZd d Zd d Zed dZ eddZ eddZ eddZ dGddZ eddZdHddZddZddZd d!Zd"d#Zd$d%Zed&d'Zed(d)Zed*d+Zed,d-Zd.d/Zd0d1Zd2d3Zed4d5Zd6d7Zd8d9ZdId:d;ZdJdd?Z!d@dAZ"dBdCZ#dLdDdEZ$dS)MInstallRequirementz Represents something that may be installed later on, may have information about where to fetch the relevant requirement and also contains logic for installing the said requirement. FNrFc Cs~|dkst|tst|||_||_| |_||_d|_|jrd|sFt|jrdt j t j |j |_|dkr|r|jrt|j}||_|_d|_d|_|jr|jjr|jj |_| r| |_n |rdd|jD|_nt|_|dkr|r|j}||_d|_d|_d|_d|_|r|ng|_| r&| ng|_| r6| ni|_d|_d|_ d|_!||_"t#|_$d|_%d|_&g|_'d|_(||_)dS)NFcSsh|]}t|qSrF)r safe_extra.0extrarFrFrG sz.InstallRequirement.__init__..)* isinstancerr>req comes_from constrainteditable source_diris_filer7r9normpathabspath file_pathurlr link original_linkoriginal_link_is_in_wheel_cachelocal_file_pathextrassetmarkermarkers satisfied_byshould_reinstall_temp_build_dirinstall_succeededinstall_optionsglobal_options hash_optionsprepared is_directsuccessfully_downloadedisolatedr build_envr@pyproject_requiresrequirements_to_checkpep517_backend use_pep517) selfrPrQrSrZrarqrlrfrgrhrRr^rFrFrG__init__ds\       zInstallRequirement.__init__cCs|jr.t|j}|jrF|dt|jj7}n|jrBt|jj}nd}|jdk rf|dt|jj7}|j rt |j t j r|j }n |j }|r|d|7}|S)Nz from {}zz in {}z (from {}))rPstrrZformatr!rYrbrlocationrQrOr string_types from_pathrrsrQrFrFrG__str__s    zInstallRequirement.__str__cCsd|jjt||jS)Nz<{} object: {} editable={!r}>)ru __class____name__rtrSrrrFrFrG__repr__s zInstallRequirement.__repr__cs>t|t}fddt|D}dj|jjd|dS)z>An un-tested helper for getting state, for debugging. c3s|]}d||VqdS)z{}={!r}N)ru)rLattr attributesrFrG sz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )namestate)varssortedrur|r}join)rrnamesrrFrrG format_debugs zInstallRequirement.format_debugcCs"|jdkrdStt|jjSN)rPr ensure_strr safe_namerr~rFrFrGrs zInstallRequirement.namecCs|jjSr)rP specifierr~rFrFrGrszInstallRequirement.specifiercCs$|j}t|dko"tt|jdkS)zReturn whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. >=====)rlennextiteroperator)rr specifiersrFrFrG is_pinneds zInstallRequirement.is_pinnedcCs t|jSr)rrr~rFrFrGinstalled_versionsz$InstallRequirement.installed_versioncs0|sd}jdk r(tfdd|DSdSdS)N)c3s|]}jd|iVqdS)rMN)raevaluaterKr~rFrGrsz3InstallRequirement.match_markers..T)raany)rrextras_requestedrFr~rG match_markerss  z InstallRequirement.match_markerscCs t|jS)zReturn whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. )boolrhr~rFrFrGhas_hash_options%s z#InstallRequirement.has_hash_optionsTcCsB|j}|r|jn|j}|r:|jr:||jg|jt|S)aReturn a hash-comparer that considers my option- and URL-based hashes to be known-good. Hashes in URLs--ones embedded in the requirements file, not ones downloaded from an index server--are almost peers with ones from flags. They satisfy --require-hashes (whether it was implicitly or explicitly activated) but do not activate it. md5 and sha224 are not allowed in flags, which should nudge people toward good algos. We always OR all hashes together, even ones from URLs. :param trust_internet: Whether to trust URL-based (#md5=...) hashes downloaded from the internet, as by populate_link() ) rhcopyrZr[hash setdefault hash_nameappendr)rrtrust_internet good_hashesrZrFrFrGhashes0s   zInstallRequirement.hashescCsR|jdkrdSt|j}|jrNt|jtjr4|j}n |j}|rN|d|7}|S)z@Format a nice indicator to show where this "comes from" Nz->)rPrtrQrOrrwrxryrFrFrGrxFs    zInstallRequirement.from_pathcCs|dk s t|jdk r*|jjs"t|jjS|jdkrLttjdd|_|jjS|jr^|j }n|j}t j |st d|t |t j||}|rdnd}t||tjddjS)NT)kindglobally_managedzCreating directory %sF)r9deleterr)r>rdr9rPr#r$ REQ_BUILDrSrlowerr7existsloggerdebugmakedirsr)rr build_dir autodeleteractual_build_dir delete_argrFrFrGensure_build_locationVs0         z(InstallRequirement.ensure_build_locationcCsn|jdkst|jdk st|jdk s*ttt|jdtrDd}nd}td|jd||jdg|_dS)z3Set requirement after generating metadata. NrrrrName) rPr>r5rTrO parse_versionrrr)rroprFrFrG_set_requirementysz#InstallRequirement._set_requirementcCsDt|jd}t|jj|kr"dStd|j||jt||_dS)NrzeGenerating metadata for package %s produced metadata for project name %s. Fix your #egg=%s fragments.)rr5rPrrwarningr)rr metadata_namerFrFrGwarn_on_mismatching_namesz+InstallRequirement.warn_on_mismatching_namecCs|jdkrdStt|j}d|_ztt||_Wnxtjk rNYdStjk rt|jj }|rt |rd|_ qt rt |rtd|j|jnd|_ YnX|jr|jrd|_ d|_dS)zFind an installed distribution that satisfies or conflicts with this requirement, and set self.satisfied_by or self.should_reinstall appropriately. NTzVWill not install to the user site because it will lack sys.path precedence to {} in {})rPrrtr`rget_distributionrbDistributionNotFoundVersionConflictrrrcr&rr rur4rvrS)rr use_user_site no_marker existing_distrFrFrGcheck_if_existss8   z"InstallRequirement.check_if_existscCs|js dS|jjS)NF)rZis_wheelr~rFrFrGrszInstallRequirement.is_wheelcCstj|j|jr|jjpdS)Nr)r7r9rrTrZsubdirectory_fragmentr~rFrFrGunpacked_source_directorysz,InstallRequirement.unpacked_source_directorycCsH|jstd|tj|jd}tjrDt |tj rD| t }|S)NNo source dir for {}zsetup.py)rTr>rur7r9rrrPY2rO text_typeencodesysgetfilesystemencoding)rrsetup_pyrFrFrG setup_py_paths z InstallRequirement.setup_py_pathcCs|jstd|t|jS)Nr)rTr>rurrr~rFrFrGpyproject_toml_pathsz&InstallRequirement.pyproject_toml_pathcCs^t|j|j|jt|}|dkr*d|_dSd|_|\}}}}||_||_t|j||d|_ dS)aALoad the pyproject.toml file. After calling this routine, all of the attributes related to PEP 517 processing for this requirement have been set. In particular, the use_pep517 attribute can be used to determine whether we should follow the PEP 517 or legacy (setup.py) code path. NFT) backend_path) rrqrrrtrornr rrp)rrpyproject_toml_datarequiresbackendcheckrrFrFrGrs$  z&InstallRequirement.load_pyproject_tomlcCsV|js8|jstt|j|j|j|j|jp2d|j dS|j dk sFtt |j|j dS)zKInvokes metadata generator functions, with the required arguments. zfrom {})rmrrTrldetailsN)rmr) rqrr>generate_metadata_legacyrmrrlrrurZrprr~rFrFrG_generate_metadatas z%InstallRequirement._generate_metadatac CsJ|js tt||_W5QRX|js6|n||dS)zEnsure that project metadata is available. Under PEP 517, call the backend hook to prepare the metadata. Under legacy processing, call setup.py egg-info. N) rTr>rrr@rrrassert_source_matches_versionr~rFrFrGprepare_metadatas  z#InstallRequirement.prepare_metadatacCst|dst||_|jS)N _metadata)hasattrr"get_distrr~rFrFrGr50s zInstallRequirement.metadatacCs t|jSr)rHr@r~rFrFrGr8szInstallRequirement.get_distcCsR|js t|jd}|jjr8||jjkr8td||ntdt|j||dS)Nversionz'Requested %s, but installing version %sz;Source in %s has version %s, which satisfies requirement %s) rTr>r5rPrrrrr)rrrrFrFrGr<s  z0InstallRequirement.assert_source_matches_versioncCs|jdkr||||_dS)aAEnsure that a source_dir is set. This will create a temporary build dir if the name of the requirement isn't known yet. :param parent_dir: The ideal pip parent_dir for the source_dir. Generally src_dir for editables and build_dir for sdists. :return: self.source_dir N)rTr)rr parent_dirrrFrFrGensure_has_source_dirOs z(InstallRequirement.ensure_has_source_dircCs|jstd|jdS|js"t|js,t|jjdkrCannot update repository at %s; repository location is unknownfile+zbad url: {self.link.url!r}rz5This form of VCS requirement is being deprecated: {}.zgit+git@zmgit+https://git@example.com/..., git+ssh://git@example.com/..., or the insecure git+git://git@example.com/...z21.0i)gone_inissue)rYrz+Unexpected version control type (in {}): {})rZrrrTrSr>schemerYrulocalsr:r' get_backendis_vcs startswithrr obtainexport)rrrvc_typerY vcs_backendreason replacement hidden_urlrFrFrGupdate_editable`sH      z"InstallRequirement.update_editablecCsj|js tzt|jj}Wn&tjk rBtd|jYdSXtd|t |}| |||S)a Uninstall the distribution currently satisfying this requirement. Prompts before removing or modifying files unless ``auto_confirm`` is True. Refuses to delete or modify files outside of ``sys.prefix`` - thus uninstallation within a virtual environment can only modify that virtual environment, even if the virtualenv is linked to global site-packages. z#Skipping %s as it is not installed.NzFound existing installation: %s) rPr>rrrrrrinfor from_distremove)rr auto_confirmverbosedistuninstalled_pathsetrFrFrG uninstalls    zInstallRequirement.uninstallcCs.dd}tj||}|||}|jd|S)NcSsL||tjjs$tdjft|t|dd}|tjjd}|S)Nz2name {name!r} doesn't start with prefix {prefix!r}r/) rr7r9r8r>rurrreplace)rprefixrFrFrG_clean_zip_namesz=InstallRequirement._get_archive_name.._clean_zip_namer)r7r9rr)rrr9 parentdirrootdirrrrFrFrG_get_archive_names  z$InstallRequirement._get_archive_namec Cs|js td}d|j|jd}tj||}tj|rt dt |d}|dkr^d}nj|dkrt d t |t |nF|d krt|}t d t |t |t||n|d krtd |sdStj|dtjdd}|tjtj|j}t|D]~\} } } | D]6} |j| | |d} t| d}d|_||dq| D]0}|j|| |d}tj| |}|||qTq W5QRXt dt |dS)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. Tz {}-{}.ziprz8The file {} exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )iwbarFrz Deleting %srzBacking up %s to %srN) allowZip64)rrrirzSaved %s) rTr>rurr5r7r9rrrrrrrrshutilmoverexitzipfileZipFile ZIP_DEFLATEDnormcaserWrwalkrZipInfo external_attrwritestrwriter)rrrcreate_archive archive_name archive_pathresponse dest_file zip_outputdirdirpathdirnames filenamesdirname dir_arcnamezipdirfilename file_arcnamerFrFrGarchivesr     zInstallRequirement.archivec Csft|j||||j|d} |dk r$|ng}|jr^t||||||j|j|j|j|jd d|_dS|j r|j snt d} |j rt |j |j|j} t|j|j | t|j||| dd|_dSt||j}t||j}z8t|||||||| |j|j|j|j|jt|jd} WnRtk r>} zd|_tj| jW5d} ~ XYntk rZd|_YnX| |_dS)N)userhomerootrlr)rr#rrrrlrmrT)rreq_description pycompilewarn_script_location direct_url)rfrgr$r#rrr&rrrlreq_namermrr%F)r rrlrSinstall_editable_legacyrrmrrerr]r>r[rrTr\rrtrPlistrgrfinstall_legacyrrreraiseparent Exception) rrrfrgr$r#rr'rr&rr(successexcrFrFrGrs       zInstallRequirement.install) FNNNFNNNFrF)N)T)F)T)FF)NNNNTFT)%r} __module__ __qualname____doc__rsr{rrpropertyrrrrrrrrxrrrrrrrrrrrr5rrrrrrr!rrFrFrFrGrI]sx  n      #*       , @rI)_ __future__rloggingr7rrr  pip._vendorrrZ"pip._vendor.packaging.requirementsrpip._vendor.packaging.utilsrpip._vendor.packaging.versionrrrpip._vendor.pep517.wrappersr pip._internal.build_envr pip._internal.exceptionsr pip._internal.locationsr pip._internal.models.linkr 'pip._internal.operations.build.metadatar.pip._internal.operations.build.metadata_legacyr0pip._internal.operations.install.editable_legacyrr*'pip._internal.operations.install.legacyrrr,&pip._internal.operations.install.wheelrpip._internal.pyprojectrrpip._internal.req.req_uninstallrpip._internal.utils.deprecationr&pip._internal.utils.direct_url_helpersrpip._internal.utils.hashesrpip._internal.utils.loggingrpip._internal.utils.miscrrrrrrr r!pip._internal.utils.packagingr"pip._internal.utils.temp_dirr#r$pip._internal.utils.typingr%pip._internal.utils.virtualenvr&pip._internal.vcsr'typingr(r)r*r+r,r-r.r/Zpip._vendor.pkg_resourcesr0Z pip._vendor.packaging.specifiersr1Zpip._vendor.packaging.markersr2 getLoggerr}rrHobjectrIrFrFrFrGsT                     (    $