U ��.e�_�@s�ddlmZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZmZdd lmZddl m!Z!ddl"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5e1�r�ddl m6Z6ddl7m8Z8m9Z9m:Z:ddl;mZ>ddl4m?Z?e�@eA�ZBdd�ZCdd�ZDd d!�ZEGd"d#�d#e�ZFd$d%�ZGd&d'�ZHdS)(�)�absolute_importN)�path)� SUPPRESS_HELP)� pkg_resources)�canonicalize_name)� WheelCache)� cmdoptions)�make_target_python)�RequirementCommand)�ERROR�SUCCESS)� CommandError�InstallationError�PreviousBuildDirError��distutils_scheme)�check_install_conflicts)�RequirementSet�install_given_reqs)�RequirementTracker)�check_path_owner)� ensure_dir�get_installed_version�(protect_pip_from_modification_on_windows� write_output)� TempDirectory)�MYPY_CHECK_RUNNING)�virtualenv_no_global)� WheelBuilder)�Values)�Any�List�Optional)� FormatControl)�InstallRequirement)�BinaryAllowedPredicatecCs(z ddl}Wntk r"YdSXdS)z8 Return whether the wheel package is installed. rNFT)�wheel� ImportError)r&�r(�B/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py�is_wheel_installed<s  r*cCs*t�}|j|dd�}|r&|j|dd�|S)zQ Build wheels for requirements, depending on whether wheel is installed. T)Z should_unpack)r*Zbuild)�builder�pep517_requirements�legacy_requirementsZshould_build_legacy�build_failuresr(r(r)� build_wheelsHs ��r/cs�fdd�}|S)Ncs&|jr dSt|j�}��|�}d|kS)NTZbinary)� use_pep517r�nameZget_allowed_formats)�reqZcanonical_nameZallowed_formats��format_controlr(r)�check_binary_allowedhs   z6get_check_binary_allowed..check_binary_allowedr()r4r5r(r3r)�get_check_binary_allowedfs r6cs<eZdZdZdZ�fdd�Zdd�Zdd�Zd d �Z�Z S) �InstallCommandaI Install packages from: - PyPI (and other indexes) using requirement specifiers. - VCS project urls. - Local project directories. - Local or remote source archives. pip also supports installing from "requirements files", which provide an easy way to specify a whole environment to be installed. a% %prog [options] [package-index-options] ... %prog [options] -r [package-index-options] ... %prog [options] [-e] ... %prog [options] [-e] ... %prog [options] ...cs^tt|�j||�|j}|�t���|�t���|�t���|�t� ��|�t� ��|jddddddd�t� |�|jddd d d �|jd dd t d �|jdddddd�|jdddddd�|�t� ��|�t���|jdddd dd �|jdddddgdd�|jddd d d �|jd!d"d#d d$d �|�t���|�t���|�t���|�t���|�t���|�t���|jd%d d&d'd(d)�|jd*d d&d+d,�|jd-d d.d'd/d)�|jd0d d1d'd2d)�|�t���|�t���|�t���|�t���|�t���|�t���t�tj|j�}|j�d3|�|j�d3|�dS)4Nz-tz--target� target_dir�dirz�Install packages into . By default this will not replace existing files/folders in . Use --upgrade to replace existing packages in with new versions.)�dest�metavar�default�help�--user� use_user_site� store_truez�Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.))r:�actionr=z --no-userZ store_falsez--root� root_pathz=Install everything relative to this alternate root directory.z--prefix� prefix_pathzIInstallation prefix where lib, bin and other top-level folders are placedz-Uz --upgrade�upgradez�Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.z--upgrade-strategy�upgrade_strategyzonly-if-neededZeageraGDetermines how dependency upgrading should be handled [default: %default]. "eager" - dependencies are upgraded regardless of whether the currently installed version satisfies the requirements of the upgraded package(s). "only-if-needed" - are upgraded only when they do not satisfy the requirements of the upgraded package(s).)r:r<�choicesr=z--force-reinstall�force_reinstallz;Reinstall all packages even if they are already up-to-date.z-Iz--ignore-installed�ignore_installedz�Ignore the installed packages, overwriting them. This can break your system if the existing package is of a different version or was installed with a different package manager!z --compile�compileTz'Compile Python source files to bytecode)rAr:r<r=z --no-compilez.Do not compile Python source files to bytecode)rAr:r=z--no-warn-script-location�warn_script_locationz0Do not warn when installing scripts outside PATHz--no-warn-conflicts�warn_about_conflictsz%Do not warn about broken dependenciesr)�superr7�__init__�cmd_optsZ add_optionr� requirementsZ constraintsZno_depsZpreZeditableZadd_target_python_optionsr� build_dir�src�ignore_requires_pythonZno_build_isolationr0Z no_use_pep517�install_options�global_optionsZ no_binaryZ only_binaryZ prefer_binary�no_clean�require_hashesZ progress_barZmake_option_groupZ index_group�parserZinsert_option_group)�self�args�kwrNZ index_opts�� __class__r(r)rM�s�� ����� ��� �����zInstallCommand.__init__c*Cs�t�|�dd�}t��dkrZ|�sZt�tjd�}|dkrLt�tj�d}t � d|�d}|j rj|j }|j r�tj�|j �|_ tj|dd �tj�|j�|_|jp�g}|jr�|jr�td ��t�r�td ��|�d �|�d �d}d}|j�rJd|_tj�|j�|_tj�|j��r,tj�|j��s,td��tdd�}|j}|�d|�|j�pTg} |�|�} t|�} |j || | |j!d�} |j"�p�|j } t#|j$|j%�}|j$�r�t&|j$��s�t � d|j$�d|_$t'���}t|j | dd����}t(|j)|j d�}�z��z*|�,|||| | |�|j-|||d�}|j.|| | |||j|j|j!|j/||j0d� }|�1|�z|�2d�}Wnt3k �rzd}Yn X|j4dk}t5|d�t6| j%�}g}g}|j7�8�D]$}|j0�r�|�|�n |�|��q�t9||gg|d�}t:|||d�}|�rtd�;d� �o.|j?}|�r@|�@|�|jA}|j�rRd!}tB||| |jC||j|jD||jd"� }tE|j||jC|j|jFd#�} tG�H| �}!tI|tJ�Kd$�d%�}"g}#|"D]R}|jL}$z$tM|jL|!d&�}%|%�r�|$d'|%7}$WntNk �r�YnX|#�|$��q�d(�<|#�}&|&�r tOd)|&�Wn�tPk �r�}'zN|jQd*k}(tR|'|(|j�})t jS|)|(d+�tTWY�W�HW5QR�W5QR�Sd}'~'XYntUk �r�d|_"�YnXW5|j"�s�|�*�|�+�XW5QRXW5QRX|j�r�|�V|j||j �tWS),NcSs ttd�pttd�otjtjkS)NZ real_prefix� base_prefix)�hasattr�sysr]�prefixr(r(r(r)�is_venvs   �z#InstallCommand.run..is_venvrz __main__.pyz -m pipzgRunning pip install with root privileges is generally not a good idea. Try `%s install --user` instead.zto-satisfy-onlyT)Z check_targetzVCan not combine '--user' and '--prefix' as they imply different installation locationszZCan not perform a '--user' install. User site-packages are not visible in this virtualenv.r>z --prefix=z=Target path exists but is not a directory, will not continue.�target)�kindz--home=)�options�session� target_pythonrRz�The directory '%s' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Zinstall)�deleterc)rVZcheck_supported_wheels)Ztemp_build_dirrd� req_tracker) �preparer�finderrerd� wheel_cacher?rHrRrGrEr0Zpip)� modifying_pip)Z build_optionsrTr5)r+r,r-zPCould not build wheels for {} which use PEP 517 and cannot be installed directlyz, css|] }|jVqdS�N)r1)�.0�rr(r(r)� �sz%InstallCommand.run..F)�root�homer`Z pycompilerJr?)�userrrrqr`�isolatedr1)�key)� working_set�-� zSuccessfully installed %s���exc_info)XrZcheck_install_build_global�os�getuidr�basenamer_�argv� executable�logger�warningrDrErP�abspathZcheck_dist_restrictionZsrc_dirrSr?rCr rr�appendr8rH�exists�isdirrrTZget_default_sessionr Z_build_package_finderrRrUr� cache_dirr4rrrrVZ cleanup_filesZcleanupZpopulate_requirement_setZmake_requirement_preparerZ make_resolverrGr0ZresolveZget_requirement�KeyErrorZ satisfied_byrr6rO�valuesrr/�format�joinZget_installation_orderZignore_dependenciesrK�_warn_about_conflictsrJrrBrI�get_lib_location_guessesZ isolated_moderZ WorkingSet�sorted�operator� attrgetterr1r� Exceptionr�EnvironmentError� verbosity�create_env_error_message�errorr r�_handle_target_dirr )*rXrdrYraZcommandrErS�target_temp_dirZtarget_temp_dir_pathrTrerfrjZ build_deleterkrhZ directoryZrequirement_setriZresolverZpip_reqrlr5r-r,r2Z wheel_builderr.� to_installZshould_warn_about_conflictsrJZ installedZ lib_locationsrvZreqs�items�itemZinstalled_versionZinstalled_descr��show_traceback�messager(r(r)�runs� �� ��   ��   �� �����   �� ����� � � � � � �4 �zInstallCommand.runc sft|�g}|��Jtd|jd�}|d}|d}|d}tj�|�rP|�|�tj�|�rn||krn|�|�tj�|�r�|�|�|D]�} t�| �D]�} | |kr�tj�|| ��t�fdd�|dd�D��r�q�tj�|| �} tj�| ��r>|s�t � d | �q�tj� | ��rt � d | �q�tj� | ��r4t �| �n t�| �t �tj�| | �| �q�q�W5QRXdS) N�)rr�purelib�platlib�datac3s|]}|���VqdSrm)� startswith)rn�s��ddirr(r)rp+sz4InstallCommand._handle_target_dir..�����zKTarget directory %s already exists. Specify --upgrade to force replacement.z�Target directory %s already exists and is a link. Pip will not automatically replace links, please remove if replacement is desired.)rrrr|r�r��listdirr��anyr�r��islinkr��shutilZrmtree�removeZmove) rXr8r�rDZ lib_dir_list�schemeZ purelib_dirZ platlib_dirZdata_dirZlib_dirr�Ztarget_item_dirr(r�r)r�sP     ��   �z!InstallCommand._handle_target_dirc Cs�zt|�\}}Wn$tk r4tjddd�YdSX|\}}|D]2}||d}||D]}t�d|||d�qZqB|D]8}||d}||D]\} } } t�d||| | | �q�qzdS)NzError checking for conflicts.Trzrz*%s %s requires %s, which is not installed.ryzF%s %s has requirement %s, but you'll have %s %s which is incompatible.)rr�r�r�Zcritical) rXr�Z package_setZ _dep_infoZmissingZ conflictingZ project_name�versionZ dependencyZdep_nameZ dep_versionr2r(r(r)r�Is4  � �z$InstallCommand._warn_about_conflicts) �__name__� __module__� __qualname__�__doc__ZusagerMr�r�r�� __classcell__r(r(r[r)r7ss  w8r7cOstd|�|�}|d|dgS)Nr�r�r�)r�r)rY�kwargsr�r(r(r)r�dsr�cCs�g}|�d�|s,|�d�|�t|��n |�d�|dd7<|jtjkr�d}d}|st|�|d|��g�n |�|�|�d �d �|���dS) z{Format an error message for an EnvironmentError It may occur anytime during the execution of the install command. z5Could not install packages due to an EnvironmentErrorz: �.r�� z"Consider using the `--user` optionzCheck the permissionsz or z. r�)r��str�errnoZEACCES�extend�lowerr��strip)r�r�Zusing_user_site�partsZuser_option_partZpermissions_partr(r(r)r�is&    �  r�)IZ __future__rr�Zloggingr�r|r�r_rZoptparserZ pip._vendorrZpip._vendor.packaging.utilsrZpip._internal.cacherZpip._internal.clirZpip._internal.cli.cmdoptionsr Zpip._internal.cli.req_commandr Zpip._internal.cli.status_codesr r Zpip._internal.exceptionsr rrZpip._internal.locationsrZpip._internal.operations.checkrZpip._internal.reqrrZpip._internal.req.req_trackerrZpip._internal.utils.filesystemrZpip._internal.utils.miscrrrrZpip._internal.utils.temp_dirrZpip._internal.utils.typingrZpip._internal.utils.virtualenvrZpip._internal.wheelrr�typingr r!r"Z#pip._internal.models.format_controlr#Zpip._internal.req.req_installr$r%Z getLoggerr�r�r*r/r6r7r�r�r(r(r(r)�sT                        t