U ÀÒ.e�ã@sLddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lm Z ddl!m"Z"ddl#m$Z$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mm?Z?ddl@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHddlImJZJddlKmLZLeH�r.ddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTddlmUZUddlVmWZWdd lXmYZYdd!lZm[Z[dd"l\m]Z]dd#l^m_Z_e `ea¡ZbGd$d%„d%ecƒZddS)&é)Úabsolute_importN)Ú change_root)Ú pkg_resourcesÚsix)Ú Requirement)Úcanonicalize_name)ÚVersion)Úparse)ÚPep517HookCaller)Ú pep425tagsÚwheel)ÚNoOpBuildEnvironment)ÚInstallationError)ÚLink)Úget_metadata_generator)Úload_pyproject_tomlÚmake_pyproject_path)ÚUninstallPathSet)Ú native_str)ÚHashes)Ú indent_log)ÚPIP_DELETE_MARKER_FILENAMEÚhas_delete_marker_file) Ú_make_build_dirÚask_path_existsÚ backup_dirÚ display_pathÚdist_in_install_pathÚdist_in_site_packagesÚdist_in_usersiteÚ ensure_dirÚget_installed_versionÚhide_urlÚredact_auth_from_urlÚrmtree)Ú get_metadata)Úmake_setuptools_shim_args)Úcall_subprocessÚrunner_with_spinner_message)Ú TempDirectory)ÚMYPY_CHECK_RUNNING)Úrunning_under_virtualenv)Úvcs)ÚAnyÚDictÚIterableÚListÚOptionalÚSequenceÚUnion)ÚBuildEnvironment)Ú WheelCache)Ú PackageFinder)Ú Distribution)Ú SpecifierSet)ÚMarkerc @speZdZdZdPdd„Zdd„Zd d „Zd d „Zd d„Ze dd„ƒZ e dd„ƒZ e dd„ƒZ e dd„ƒZ dQdd„Ze dd„ƒZdRdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Ze d(d)„ƒZdSd*d+„Ze d,d-„ƒZe d.d/„ƒZe d0d1„ƒZd2d3„Zd4d5„Zd6d7„Ze d8d9„ƒZd:d;„Zdd?„Z!dTd@dA„Z"dUdBdC„Z#dVdDdE„Z$dFdG„Z%dHdI„Z&dJdK„Z'dWdLdM„Z(dNdO„Z)dS)XÚInstallRequirementzÆ 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. NF©c Cs||_||_| |_|dkr"d|_ntj tj |¡¡|_||_| |_ |dkr`|r`|j r`t |j ƒ}||_ |_ | rx| |_n |r�dd„|jDƒ|_ntƒ|_|dkrª|rª|j}||_d|_d|_d|_d|_d|_| rÖ| ni|_d|_d|_||_tƒ|_d|_d|_g|_d|_ ||_!dS)NcSsh|]}t |¡’qSr;)rZ safe_extra©Ú.0Úextrar;r;úA/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.pyÚ wsz.InstallRequirement.__init__..F)"ÚreqÚ comes_fromÚ constraintÚ source_dirÚosÚpathÚnormpathÚabspathÚeditableÚ _wheel_cacheÚurlrÚlinkÚ original_linkÚextrasÚsetÚmarkerÚmarkersÚ satisfied_byÚconflicts_withÚ_temp_build_dirÚ_ideal_build_dirÚinstall_succeededÚoptionsZpreparedZ is_directÚisolatedr Ú build_envÚmetadata_directoryÚpyproject_requiresÚrequirements_to_checkÚpep517_backendÚ use_pep517) ÚselfrArBrDrIrLrQr^rXrWZ wheel_cacherCrNr;r;r?Ú__init__TsH  ÿ  zInstallRequirement.__init__cCsœ|jr,t|jƒ}|jrD|dt|jjƒ7}n|jr@t|jjƒ}nd}|jdk rb|dt|jjƒ7}|jr˜t |jt j ƒr~|j}n |j  ¡}|r˜|d|7}|S)Nz from %szz in %sz (from %s)) rAÚstrrLr#rKrRrÚlocationrBÚ isinstancerÚ string_typesÚ from_path©r_ÚsrBr;r;r?Ú__str__«s     zInstallRequirement.__str__cCsd|jjt|ƒ|jfS)Nz<%s object: %s editable=%r>)Ú __class__Ú__name__rarI©r_r;r;r?Ú__repr__Às ÿzInstallRequirement.__repr__cs>t|ƒ‰tˆƒ}‡fdd„t|ƒDƒ}dj|jjd |¡d�S)z>An un-tested helper for getting state, for debugging. c3s|]}d |ˆ|¡VqdS)z{}={!r}N)Úformat)r=Úattr©Z attributesr;r?Ú Ìsz2InstallRequirement.format_debug..z<{name} object: {{{state}}}>z, )ÚnameÚstate)ÚvarsÚsortedrmrirjÚjoin)r_Únamesrrr;ror?Ú format_debugÅs ÿþzInstallRequirement.format_debugcCsh|jdkr| ||¡|_|jdk rd|sd|j}t ¡}|jj|j|j|d�|_||jkrdt d|j¡dS)aEnsure that if a link can be found for this, that it is found. Note that self.link may still be None - if Upgrade is False and the requirement is already installed. If require_hashes is True, don't use the wheel cache, because cached wheels, always built locally, have different hashes than the files downloaded from the index server and thus throw false hash mismatches. Furthermore, cached wheels at present have undeterministic contents due to file modification times. N)rLZ package_nameÚsupported_tagszUsing cached wheel link: %s) rLZfind_requirementrJr Z get_supportedÚgetrqÚloggerÚdebug)r_ÚfinderZupgradeZrequire_hashesZold_linkrxr;r;r?Ú populate_linkÔs ý z InstallRequirement.populate_linkcCs |jdkrdStt |jj¡ƒS©N)rArrZ safe_namerqrkr;r;r?rqïs zInstallRequirement.namecCs|jjSr~)rAÚ specifierrkr;r;r?röszInstallRequirement.specifiercCs$|j}t|ƒdko"tt|ƒƒjdkS)z„Return whether I am pinned to an exact version. For example, some-package==1.2 is pinned; some-package>1.2 is not. é>ú==ú===)rÚlenÚnextÚiterÚoperator)r_Z specifiersr;r;r?Ú is_pinnedûs ÿzInstallRequirement.is_pinnedcCs t|jƒSr~)r!rqrkr;r;r?Úinstalled_versionsz$InstallRequirement.installed_versioncs0|sd}ˆjdk r(t‡fdd„|DƒƒSdSdS)N)Úc3s|]}ˆj d|i¡VqdS)r>N)rQZevaluater<rkr;r?rpsÿz3InstallRequirement.match_markers..T)rQÚany)r_Zextras_requestedr;rkr?Ú match_markers s  þz InstallRequirement.match_markerscCst|j di¡ƒS)z©Return whether any known-good hashes are specified as options. These activate --require-hashes mode; hashes specified as part of a URL do not. Úhashes)ÚboolrWryrkr;r;r?Úhas_hash_optionss z#InstallRequirement.has_hash_optionsTcCsJ|j di¡ ¡}|r|jn|j}|rB|jrB| |jg¡ |j¡t |ƒS)a§Return 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() rŒ) rWryÚcopyrLrMÚhashÚ setdefaultZ hash_nameÚappendr)r_Ztrust_internetZ good_hashesrLr;r;r?rŒ#s  zInstallRequirement.hashescCsR|jdkrdSt|jƒ}|jrNt|jtjƒr4|j}n |j ¡}|rN|d|7}|S)z@Format a nice indicator to show where this "comes from" Nz->)rArarBrcrrdrerfr;r;r?re9s    zInstallRequirement.from_pathcCs||jdk r|jjS|jdkr6tdd�|_||_|jjS|jrH|j ¡}n|j}tj  |¡snt   d|¡t |ƒtj  ||¡S)Nz req-build©ÚkindzCreating directory %s)rTrFrAr)rUrIrqÚlowerrEÚexistsrzr{rru)r_Ú build_dirrqr;r;r?Úensure_build_locationIs      z(InstallRequirement.ensure_build_locationcCsÞ|jdk rdS|j}d|_| |j¡}tj |¡rBtdt|ƒƒ‚t   d|t|jƒt|ƒ¡t   |j|¡tj  tj |¡¡|_t|dd�|_|jrÔ|j}tjj||jd�}tj ||¡}tj  tj |¡¡}||_d|_dS)a�Move self._temp_build_dir to "self._ideal_build_dir/self.req.name" For some requirements (e.g. a path to a directory), the name of the package is not available until we run egg_info, so the build_location will return a temporary directory and store the _ideal_build_dir. This is only called to "fix" the build directory after generating metadata. NzCannot update repository at %s; repository location is unknownÚfileú+r€)rK) rLrzr{rDZschemerKrÃr,Z get_backendr"ÚobtainZexport)r_rÑZvc_typerKZ vcs_backendZ hidden_urlr;r;r?Úupdate_editableÂs ý   z"InstallRequirement.update_editablecCsB| |¡st d|j¡dS|jp&|j}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.N) r¢rzrµrqrRrSrZ from_distÚremove)r_Z auto_confirmÚverboser¡ZdistZuninstalled_pathsetr;r;r?Ú uninstallßs    zInstallRequirement.uninstallcCs(|t|ƒdd…}| tjjd¡}|S)Nr€ú/)rƒÚreplacerErFrÁ)r_rqr§r;r;r?Ú_clean_zip_name÷sz"InstallRequirement._clean_zip_namecCs(tj ||¡}| ||¡}|jd|S)NrÖ)rErFrurØrq)r_rFÚ parentdirÚrootdirrqr;r;r?Ú_get_archive_names z$InstallRequirement._get_archive_namec Cs¼d}d|j|jdf}tj ||¡}tj |¡r¼tdt|ƒdƒ}|dkrRd}nj|dkrvt  d t|ƒ¡t  |¡nF|d krªt |ƒ}t  d t|ƒt|ƒ¡t   ||¡n|d kr¼t d ¡|sÄdStj|dtjdd�}|�Ætj tj |j¡¡}t |¡D]ž\} } } d| k�r|   d¡| D]6} |j| | |d�} t | d¡}d|_| |d¡�q | D]>}|tk�rn�q\|j|| |d�}tj | |¡}| ||¡�q\qþW5QRXt dt|ƒ¡dS)z}Saves archive to provided build_dir. Used for saving downloaded VCS requirements as part of `pip download`. Tz %s-%s.ziprÅz8The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)bort )ÚiÚwÚbÚarÜFrÝz Deleting %srÞzBacking up %s to %srßéÿÿÿÿN)Z allowZip64z pip-egg-info)rÙrÚrÖiír‰zSaved %s)rqr´rErFrur–rrrzrµrÓrršr›r­ÚexitÚzipfileZZipFileZ ZIP_DEFLATEDÚnormcaserHr«ÚwalkrÛZZipInfoZ external_attrZwritestrrÚwriterË)r_r—Zcreate_archiveZ archive_nameZ archive_pathZresponseZ dest_fileZ zip_outputÚdirÚdirpathZdirnamesÚ filenamesÚdirnameZ dir_arcnameZzipdirÚfilenameZ file_arcnamer;r;r?Úarchivesx ÿþ ý ÿ ÿ  ÿ ÿzInstallRequirement.archivec  sh|dk r |ng}|jr*|j|||d�dS|jrnt |j¡} t | |j¡|j|jˆ|||||d�d|_ dSt |ƒ|j   dg¡}t |ƒ|j   dg¡}t dd���¸} tj | jd¡} | || ˆ||¡} td  |j¡ƒ} tƒ�*|j�| | ||jd �W5QRXW5QRXtj | ¡�s8t d | ¡W5QR£dSd|_ ‡fd d „}t| ƒ�\}|D],}tj |¡}| d¡�rX||ƒ}�qª�qXt d|¡W5QR£W5QR£dSW5QRXg}t| ƒ�L}|D]@}| ¡}tj |¡�rì|tjj 7}| !tj "||ƒ|¡¡�qÆW5QRX| #¡t$|ƒtj |d¡}t|dƒ�}| %d |¡d¡W5QRXW5QRXdS)N)r§)r¦r§r¥r©r¡r¨TrÈrÍÚrecordr“zinstall-record.txtzRunning setup.py install for {})ÚcmdrÊzRecord file %s not foundcs&ˆdkstj |¡s|Stˆ|ƒSdSr~)rErFÚisabsr)rF©r¦r;r?Ú prepend_root�sz0InstallRequirement.install..prepend_rootr¿z;Could not find .egg-info directory in install record for %szinstalled-files.txtrÝÚ )&rIrÎr£r Z wheel_versionrDZcheck_compatibilityrqrªrVrÌrWryr)rErFruÚget_install_argsr(rmrrYr«r–rzr{ÚopenrérÂrµÚstripÚisdirrÁr’rœÚsortr rå)r_rÍrÈr¦r¥r§r©r¡r¨rÅZtemp_dirÚrecord_filenameÚ install_argsrºrðÚfÚlineZ directoryZ egg_info_dirZ new_linesrêZinst_files_pathr;rïr?ÚinstallEs– ÿ ý ÿ ÿÿ ÿþ      ý"  ÿ zInstallRequirement.installc Cs¤t|j||jdd�}|dd|g7}|dg7}|dk r@|d|g7}|dk rT|d|g7}|rd|dg7}n |d g7}tƒr d t ¡}|d tj t j d d ||j ¡g7}|S)NT)rÈrÉZunbuffered_outputrûz--recordz#--single-version-externally-managedz--rootz--prefixz --compilez --no-compileÚpythonz--install-headersZincludeZsite) r&r¯rXr+Ú sysconfigZget_python_versionrErFrur­r§rq)r_rÈr÷r¦r§r¨røZ py_ver_strr;r;r?rò¥s0 ü      ÿÿz#InstallRequirement.get_install_args) NFNNNFNNFr;)N)T)NNNTFT)r;N)T)FFF)NNNNTFT)*rjÚ __module__Ú __qualname__Ú__doc__r`rhrlrwr}Úpropertyrqrr‡rˆr‹rŽrŒrer˜r�rŸr¢r£rªr«r¯r°rr·r»r´r¾rÆrÇrÎrÒrÕrØrÛrërûròr;r;r;r?r:Ms– ó W      8 + ø    % ü  ÿ  B÷ `r:)eZ __future__rr¸ZloggingrEršr­rýrâZdistutils.utilrZ pip._vendorrrZ"pip._vendor.packaging.requirementsrZpip._vendor.packaging.utilsrZpip._vendor.packaging.versionrr r³Zpip._vendor.pep517.wrappersr Z pip._internalr r Zpip._internal.build_envr Zpip._internal.exceptionsrZpip._internal.models.linkrZ*pip._internal.operations.generate_metadatarZpip._internal.pyprojectrrZpip._internal.req.req_uninstallrZpip._internal.utils.compatrZpip._internal.utils.hashesrZpip._internal.utils.loggingrZ pip._internal.utils.marker_filesrrZpip._internal.utils.miscrrrrrrrr r!r"r#r$Zpip._internal.utils.packagingr%Z$pip._internal.utils.setuptools_buildr&Zpip._internal.utils.subprocessr'r(Zpip._internal.utils.temp_dirr)Zpip._internal.utils.typingr*Zpip._internal.utils.virtualenvr+Zpip._internal.vcsr,Útypingr-r.r/r0r1r2r3r4Zpip._internal.cacher5Zpip._internal.indexr6Zpip._vendor.pkg_resourcesr7Z pip._vendor.packaging.specifiersr8Zpip._vendor.packaging.markersr9Z getLoggerrjrzÚobjectr:r;r;r;r?ÚsV               8      $