U
    ißŽi–j  ã                   @   s  d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZmZmZ d dlmZ d dlm Z  d dl!m"Z"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6 d dl7m8Z8m9Z9 e4�r¦d dlm:Z: d dl;m<Z<m=Z=m>Z>m?Z? d dl@mAZA d dlBmCZC d dl7mDZD d dlmEZE e FeG¡ZHdd„ ZIG d d!„ d!eƒZJd"d#„ ZKd$d%„ ZLd-d'd(„ZMd)d*„ ZNd+d,„ ZOdS ).é    )Úabsolute_importN)Ú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)Úget_requirement_tracker)Ú
deprecated)Úparse_distutils_args©Útest_writable_dir)Ú
ensure_dirÚget_installed_versionÚ(protect_pip_from_modification_on_windowsÚwrite_output)ÚTempDirectory)ÚMYPY_CHECK_RUNNING)Úvirtualenv_no_global)ÚbuildÚ should_build_for_install_command)ÚValues)ÚAnyÚIterableÚListÚOptional)ÚFormatControl)ÚInstallRequirement)ÚBinaryAllowedPredicate)Úrunning_under_virtualenvc                    s   ‡ fdd„}|S )Nc                    s&   | j r
dS t| jƒ}ˆ  |¡}d|kS )NTÚbinary)Ú
use_pep517r   ÚnameÚget_allowed_formats)ÚreqÚcanonical_nameZallowed_formats©Úformat_control© ú\/var/www/html/IITS/school/venv/lib/python3.8/site-packages/pip/_internal/commands/install.pyÚcheck_binary_allowed@   s
    

z6get_check_binary_allowed.<locals>.check_binary_allowedr3   )r2   r5   r3   r1   r4   Úget_check_binary_allowed>   s    r6   c                       s<   e Zd ZdZdZ‡ fdd„Zdd„ Zdd„ Zd	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] <requirement specifier> [package-index-options] ...
      %prog [options] -r <requirements file> [package-index-options] ...
      %prog [options] [-e] <vcs project url> ...
      %prog [options] [-e] <local project path> ...
      %prog [options] <archive url/path> ...c                    sp  t t| ƒj||Ž | j}| t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t 	¡ ¡ | t 
¡ ¡ |jddddd dd� t |¡ |jddd	d
d� |jddd	td� |jdddd dd� |jdddd dd� |jddd	dd� | t ¡ ¡ | t ¡ ¡ |jdddd	dd� |jdddddgdd� |jd d!d	d"d� |jd#d$d%d	d&d� | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ |jd'd	d(d)d*d+� |jd,d-d(d.d/� |jd0d-d1d)d2d+� |jd3d-d4d)d5d+� | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ | t ¡ ¡ t tj| j¡}| j d6|¡ | j d6|¡ d S )7Nz-tz--targetÚ
target_dirÚdirz¥Install packages into <dir>. By default this will not replace existing files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with new versions.)ÚdestÚmetavarÚdefaultÚhelpz--userÚuse_user_siteÚ
store_truea  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.)  On Debian systems, this is the default when running outside of a virtual environment and not as root.)r:   Úactionr=   z	--no-userÚuse_system_locationz--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--systemzDInstall using the system scheme (overrides --user on Debian systems)z-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_strategyzonly-if-neededZeageraG  Determines 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)r@   r:   r<   r=   z--no-compileÚstore_falsez.Do not compile Python source files to bytecode)r@   r:   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_optsÚ
add_optionr   ÚrequirementsÚconstraintsÚno_depsÚpreÚeditableÚadd_target_python_optionsr   Ú	build_dirÚsrcÚignore_requires_pythonÚno_build_isolationr,   Úno_use_pep517Úinstall_optionsÚglobal_optionsÚ	no_binaryÚonly_binaryÚprefer_binaryÚno_cleanÚrequire_hashesÚprogress_barÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚargsÚkwrO   Z
index_opts©Ú	__class__r3   r4   rN   _   sô     û

üüûûü ü	ûü ü
ûüûûþzInstallCommand.__init__c           '         s�  t  |¡ d}|jr|j}t j|dd� |jr8|jg}nd }|jsl|jsl|jsl|j	slt
ƒ slt ¡ dkrld|_|j	rxd|_tj |j¡|_|jp�g }t|j|j|j|j|jd�|_d }d }|j�r
d|_tj |j¡|_tj |j¡rútj |j¡sútdƒ‚tdd	�}|j}|j�pg }|  |¡}	t|ƒ}
| j||	|
|jd
�}|j�pH|j }t |j!|j"ƒ}t#ƒ ��
}t|j|dd���ì}t$|j d�}�zº�z(|  '|||||	|¡ t(||jƒ | j)||||	||jd�}| j*|||||j|j|j|j+||j,d�
}|  -|¡ | .|¡ z| /d¡}W n t0k
�r*   d }Y nX |j1d k}t2|d� t3|j"ƒ‰ ‡ fdd„|j4 5¡ D ƒ}t6||g g d�\}}dd„ |D ƒ}|�r¨t7d 8d 9dd„ |D ƒ¡¡ƒ‚| :|¡}|j; �oÀ|j<}|�rÒ|  =|¡ |j>}|j�räd}t?||||j||j|j@||jd�	}tA|j||j|j|jd�}tB C|¡}|jDtE Fd¡d� g }|D ]R} | jG}!z$tH| jG|d�}"|"�rp|!d|" 7 }!W n tIk
�rˆ   Y nX | J|!¡ �qDd  9|¡}#|#�r²tKd!|#ƒ W nŠ tLk
�r" }$ zN| jMd"k}%tN|$|%|jƒ}&tOjP|&|%d#� tQ W Y ¢W ¢HW  5 Q R £ W  5 Q R £ S d }$~$X Y n tRk
�r>   d|_‚ Y nX W 5 |j�s\| %¡  | &¡  X W 5 Q R X W 5 Q R X |j�rŒ|  S|j||j¡ tTS )$Nzto-satisfy-onlyT)Úcheck_targetr   F)rC   r8   rB   Úisolated_modez=Target path exists but is not a directory, will not continue.Útarget)Úkind)ÚoptionsÚsessionÚtarget_pythonrY   Úinstall)Údeleterp   )Zcheck_supported_wheels)Ztemp_build_dirrq   Úreq_trackerrr   Úfinderr>   )
Úpreparerrw   rq   Úwheel_cacher>   rH   rY   rG   rE   r,   Úpip)Úmodifying_pipc                    s   g | ]}t |ˆ ƒr|‘qS r3   )r!   ©Ú.0Úr©r5   r3   r4   Ú
<listcomp>w  s    ÿÿz&InstallCommand.run.<locals>.<listcomp>)ry   Úbuild_optionsr]   c                 S   s   g | ]}|j r|‘qS r3   )r,   r|   r3   r3   r4   r€   Š  s     zPCould not build wheels for {} which use PEP 517 and cannot be installed directlyz, c                 s   s   | ]}|j V  qd S ©N)r-   r|   r3   r3   r4   Ú	<genexpr>‘  s     z%InstallCommand.run.<locals>.<genexpr>)ÚrootÚhomeÚprefixZ	pycompilerK   r>   )Úuserr…   r„   r†   Úisolatedr-   )Úkey)Úworking_setú-ú zSuccessfully installed %sé   ©Úexc_info)Ur   Úcheck_install_build_globalrD   rE   Úcheck_dist_restrictionÚpython_versionr>   rC   r8   rA   r*   ÚosÚgeteuidÚpathÚabspathÚsrc_dirr\   Údecide_user_installrB   rn   rH   ÚexistsÚisdirr   r   r]   Zget_default_sessionr   Z_build_package_finderrY   ra   rW   r   Ú	cache_dirr2   r   r   Zcleanup_filesÚcleanupZpopulate_requirement_setÚwarn_deprecated_install_optionsZmake_requirement_preparerZmake_resolverrG   r,   Ztrace_basic_infoÚresolveZget_requirementÚKeyErrorZsatisfied_byr   r6   rQ   Úvaluesr    r   ÚformatÚjoinZget_installation_orderÚignore_dependenciesrL   Ú_warn_about_conflictsrK   r   rI   Úget_lib_location_guessesr   Ú
WorkingSetÚsortÚoperatorÚ
attrgetterr-   r   Ú	ExceptionÚappendr   ÚEnvironmentErrorÚ	verbosityÚcreate_env_error_messageÚloggerÚerrorr
   r   Ú_handle_target_dirr   )'rh   rq   ri   rE   Zpython_versionsr\   Útarget_temp_dirZtarget_temp_dir_pathr]   rr   rs   rw   Zbuild_deletery   rv   Ú	directoryÚrequirement_setrx   ÚresolverZpip_reqr{   Zreqs_to_buildÚ_Zbuild_failuresZpep517_build_failuresÚ
to_installZshould_warn_about_conflictsrK   Ú	installedZlib_locationsrŠ   ÚitemsÚresultÚitemZinstalled_versionZinstalled_descr°   Úshow_tracebackÚmessager3   r   r4   Úruný   s†   

ÿÿ
ûÿÿ

ü  ÿÿ    þ ÿúö



ÿÿ
ÿü
ÿþÿÿ
þ
÷û
 ÿ
 ÿ
  ÿ4  ÿzInstallCommand.runc              	      sf  t |ƒ g }|��J td|jd�}|d }|d }|d }tj |¡rP| |¡ tj |¡rn||krn| |¡ tj |¡r„| |¡ |D ]Î}	t |	¡D ]¾}
|	|krÐtj ||
¡‰ t‡ fdd„|d d… D ƒƒrÐq–tj ||
¡}tj |¡�r>|sþt	 
d	|¡ q–tj |¡�rt	 
d
|¡ q–tj |¡�r4t |¡ n
t |¡ t tj |	|
¡|¡ q–qˆW 5 Q R X d S )NÚ )r…   ÚpurelibÚplatlibÚdatac                 3   s   | ]}|  ˆ ¡V  qd S r‚   )Ú
startswith)r}   Ús©Zddirr3   r4   rƒ   ÿ  s     z4InstallCommand._handle_target_dir.<locals>.<genexpr>éÿÿÿÿ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.)r   r   r•   r“   r™   r«   Úlistdirr¢   Úanyr¯   ÚwarningÚislinkrš   ÚshutilÚrmtreeÚremoveÚmove)rh   r8   r²   rD   Zlib_dir_listÚschemeZpurelib_dirZplatlib_dirZdata_dirÚlib_dirr»   Ztarget_item_dirr3   rÅ   r4   r±   å  sP    


ýû
þz!InstallCommand._handle_target_dirc              
   C   s¸   zt |ƒ\}}W n$ tk
r4   tjddd� Y d S X |\}}|D ]2}|| d }|| D ]}t d|||d ¡ qZqB|D ]8}|| d }|| D ]\}	}
}t d||||	|
¡ q’qzd S )NzError checking for conflicts.TrŽ   r   z*%s %s requires %s, which is not installed.r�   zF%s %s has requirement %s, but you'll have %s %s which is incompatible.)r   rª   r¯   r°   Úcritical)rh   r·   Zpackage_setZ	_dep_infoÚmissingZconflictingÚproject_nameÚversionÚ
dependencyZdep_nameZdep_versionr/   r3   r3   r4   r¤     s4      þ    ýz$InstallCommand._warn_about_conflicts)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚusagerN   r¾   r±   r¤   Ú__classcell__r3   r3   rk   r4   r7   K   s     i8r7   c                  O   s   t d| ž|Ž}|d |d gS )Nr¿   rÀ   rÁ   )r¿   r   )ri   ÚkwargsrÏ   r3   r3   r4   r¥   8  s    r¥   c                  K   s   t dd„ ttf | ŽƒD ƒƒS )Nc                 s   s   | ]}t |ƒV  qd S r‚   r   )r}   Údr3   r3   r4   rƒ   >  s    z)site_packages_writable.<locals>.<genexpr>)ÚallÚsetr¥   )rÜ   r3   r3   r4   Úsite_packages_writable=  s    ÿrà   Fc                 C   s¤   | dk	r| st  d¡ dS | rF|r*tdƒ‚tƒ r8tdƒ‚t  d¡ dS | dksRt‚|sZ|rht  d¡ dS tjs|t  d	¡ dS t||d
�r–t  d¡ dS t  	d¡ dS )aZ  Determine whether to do a user install based on the input options.

    If use_user_site is False, no additional checks are done.
    If use_user_site is True, it is checked for compatibility with other
    options.
    If use_user_site is None, the default behaviour depends on the environment,
    which is provided by the other arguments.
    Nz$Non-user install by explicit requestFzVCan 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.z User install by explicit requestTz3Non-user install due to --prefix or --target optionz4Non-user install because user site-packages disabled)r„   rˆ   z0Non-user install because site-packages writeablezMDefaulting to user installation because normal site-packages is not writeable)
r¯   Údebugr   r   r   ÚAssertionErrorÚsiteÚENABLE_USER_SITErà   Úinfo)r>   rC   r8   rB   rn   r3   r3   r4   r˜   C  s4    
ÿÿ




r˜   c                 C   s®   dd„ }| j t| j ¡ ƒ }g }|D ]8}|j dg ¡}t|ƒ}|r$| d || 	¡ ƒ|¡¡ q$|r†t|ƒ}|r†| d || 	¡ ƒ¡¡ |sŽdS t
d d |¡¡d	d
dd� dS )z’If any location-changing --install-option arguments were passed for
    requirements or on the command-line, then show a deprecation warning.
    c                 S   s   dd„ | D ƒS )Nc                 S   s   g | ]}d   | dd¡¡‘qS )z--{}r¶   r‹   )r¡   Úreplace)r}   r-   r3   r3   r4   r€   †  s     zKwarn_deprecated_install_options.<locals>.format_options.<locals>.<listcomp>r3   )Zoption_namesr3   r3   r4   Úformat_options„  s    z7warn_deprecated_install_options.<locals>.format_optionsr\   z{!r} from {}z{!r} from command lineNz}Location-changing options found in --install-option: {}. This configuration may cause unexpected behavior and is unsupported.z; zCusing pip-level options like --user, --prefix, --root, and --targetz20.2i�  )ÚreasonÚreplacementÚgone_inÚissue)Zunnamed_requirementsÚlistrQ   r    rq   Úgetr   r«   r¡   Úkeysr   r¢   )r´   rq   rç   rQ   Z	offendersÚrequirementr\   Zlocation_optionsr3   r3   r4   r�     sD    ÿÿ
 ÿÿ
ÿÿýór�   c                 C   sš   g }|  d¡ |s,|  d¡ |  t| ƒ¡ n
|  d¡ |d  d7  < | jtjkrˆd}d}|st| |d| ¡ g¡ n
|  |¡ |  d	¡ d
 |¡ ¡ d S )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` optionzCheck the permissionsz or z.
r¿   )r«   ÚstrÚerrnoÚEACCESÚextendÚlowerr¢   Ústrip)r°   r¼   Zusing_user_siteÚpartsZuser_option_partZpermissions_partr3   r3   r4   r®   ¶  s&    


 þ

r®   )NNNF)PÚ
__future__r   ró   Úloggingr¨   r“   rË   rã   Úoptparser   Zpip._vendorr   Úpip._vendor.packaging.utilsr   Zpip._internal.cacher   Zpip._internal.clir   Zpip._internal.cli.cmdoptionsr   Zpip._internal.cli.req_commandr	   Úpip._internal.cli.status_codesr
   r   Úpip._internal.exceptionsr   r   r   Úpip._internal.locationsr   Zpip._internal.operations.checkr   Zpip._internal.reqr   r   Zpip._internal.req.req_trackerr   Úpip._internal.utils.deprecationr   Z"pip._internal.utils.distutils_argsr   Zpip._internal.utils.filesystemr   Úpip._internal.utils.miscr   r   r   r   Zpip._internal.utils.temp_dirr   Úpip._internal.utils.typingr   Úpip._internal.utils.virtualenvr   Zpip._internal.wheel_builderr    r!   r"   Útypingr#   r$   r%   r&   Ú#pip._internal.models.format_controlr'   Zpip._internal.req.req_installr(   r)   r*   Ú	getLoggerrÖ   r¯   r6   r7   r¥   rà   r˜   r�   r®   r3   r3   r3   r4   Ú<module>   sb   
   p    û
<7