U
    +|jÿi  ã                   @   sÂ  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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 d dlmZ d dlmZmZmZ d d	lmZ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&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z:m;Z; d dl<m=Z=m>Z>m?Z? e @eA¡ZBdd„ ZCG dd„ deƒZDd'dd„ZEdd „ ZFd(d!d"„ZGd#d$„ ZHd%d&„ ZIdS ))é    N)ÚSUPPRESS_HELPÚValues)ÚIterableÚListÚOptional)Úcanonicalize_name)Ú
WheelCache)Ú
cmdoptions)Úmake_target_python)ÚRequirementCommandÚwarn_if_run_as_rootÚwith_cleanup)ÚERRORÚSUCCESS)ÚCommandErrorÚInstallationError)Ú
get_scheme)Úget_environment)ÚFormatControl)ÚConflictDetailsÚcheck_install_conflicts)Úinstall_given_reqs)ÚInstallRequirement)Úget_requirement_tracker)Úparse_distutils_args©Útest_writable_dir)Ú
ensure_dirÚget_pip_versionÚ(protect_pip_from_modification_on_windowsÚwrite_output)ÚTempDirectory)Úrunning_under_virtualenvÚvirtualenv_no_global)ÚBinaryAllowedPredicateÚbuildÚ should_build_for_install_commandc                    s   ‡ fdd„}|S )Nc                    s    t | jp
dƒ}ˆ  |¡}d|kS )NÚ Úbinary)r   ÚnameÚget_allowed_formats)ÚreqÚcanonical_nameÚallowed_formats©Úformat_control© úfC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_internal/commands/install.pyÚcheck_binary_allowed5   s    
z6get_check_binary_allowed.<locals>.check_binary_allowedr0   )r/   r2   r0   r.   r1   Úget_check_binary_allowed3   s    r3   c                   @   s@   e Zd ZdZdZdd„ Zedd„ ƒZdd„ Zd	d
„ Z	dd„ Z
d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                 C   sz  | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j jddddd dd� t | j ¡ | j jddd	d
d� | j jdddt	d� | j jdddd dd� | j jdddd dd� | j  t 
¡ ¡ | j  t ¡ ¡ | j jdddd	dd� | j jdddddgdd� | j jddd	d d� | j jd!d"d#d	d$d� | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j jd%d	d&d'd(d)� | j jd*dd&d+d,� | j jd-dd.d'd/d)� | j jd0dd1d'd2d)� | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ t tj| j¡}| j d3|¡ | j d3| j ¡ d S )4Nz-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_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.))r7   Úactionr:   z	--no-userÚ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_strategyzonly-if-neededÚ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).)r7   r9   Ú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=   r7   r9   r:   z--no-compilez.Do not compile Python source files to bytecode)r=   r7   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   )Úcmd_optsÚ
add_optionr	   ÚrequirementsÚconstraintsÚno_depsÚpreÚeditableÚadd_target_python_optionsr   Ú	build_dirÚsrcÚignore_requires_pythonÚno_build_isolationÚ
use_pep517Úno_use_pep517Úinstall_optionsÚglobal_optionsÚ	no_binaryÚonly_binaryÚprefer_binaryÚrequire_hashesÚprogress_barÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_optsr0   r0   r1   Úadd_optionsR   sâ     û
üüûû ü	ûü ü
ûüûûþzInstallCommand.add_optionsc           (         s  |j r|jd k	rtdƒ‚t |¡ d}|jr2|j}tj|dd� |jpHg }t	 
dtƒ ¡ 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
�}
t|j|jƒ}|  t ƒ ¡}t|j! ddd�}�zb|  "|||
|¡}t#||jƒ | j$|||||
|j d�}| j%||
|||j |j|j|j&||j'd�
}|  (|
¡ |j)||j d�}z| *d¡}W n t+k
�rØ   d}Y nX |j,d k}t-|d� t.|
jƒ‰ ‡ fdd„|j/ 0¡ D ƒ}t1||dg g d�\}}dd„ |D ƒ}|�rNt2d 3d 4|¡¡ƒ‚|D ]}|j'�sRd|_5�qR| 6|¡}d }|j7 �o„|j8}|�r–|  9|¡}|j:}|j�r¨d}t;||||j||j||j |j<d�	}t=|j ||j|j|jd�}t>|ƒ}|j?t@ Ad¡d� g } |D ]V}!|!jB}"z(| C|"¡}#|#d k	�r6|"› d|#jD› �}"W n tEk
�rN   Y nX |  F|"¡ �q|d k	�r|| jG||  H|¡d� d  4| ¡}$|$�r–tId!|$ƒ W nR tJk
�rê }% z2| jKd"k}&tL|%|&|j ƒ}'t	jM|'|&d#� tN W Y ¢S d }%~%X Y nX |j�r|�sþtO‚|  P|j||j¡ tQƒ  tRS )$Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)Úcheck_targetzUsing %s)r@   r5   r?   Úisolated_modez=Target path exists but is not a directory, will not continue.Útarget)Úkind)ÚoptionsÚsessionÚtarget_pythonrT   Úinstall)Údeleteri   Úglobally_managed)Útemp_build_dirrj   Úreq_trackerrk   Úfinderr;   )
Úpreparerrr   rj   Úwheel_cacher;   rF   rT   rE   rB   rV   )Úcheck_supported_wheelsÚpipF)Úmodifying_pipc                    s   g | ]}t |ˆ ƒr|‘qS r0   )r&   ©Ú.0Úr©r2   r0   r1   Ú
<listcomp>R  s    ÿÿz&InstallCommand.run.<locals>.<listcomp>)rt   ÚverifyÚbuild_optionsrY   c                 S   s   g | ]}|j r|j‘qS r0   )rV   r)   rx   r0   r0   r1   r|   c  s    ÿzPCould not build wheels for {} which use PEP 517 and cannot be installed directlyz, i°   )ÚrootÚhomeÚprefixrH   r;   Ú	pycompile)Úuserr€   r   r�   Úisolatedr)   )Úkeyú-)Úresolver_variantú zSuccessfully installed %sé   )Úexc_info)Sr;   r5   r   r	   Úcheck_install_build_globalrA   rB   Úcheck_dist_restrictionrX   ÚloggerÚdebugr   Údecide_user_installr@   r?   rg   rF   ÚosÚpathÚabspathÚexistsÚisdirr!   Úenter_contextrY   Úget_default_sessionr
   Ú_build_package_finderrT   r   Ú	cache_dirr/   r   Úno_cleanÚget_requirementsÚ'reject_location_related_install_optionsÚmake_requirement_preparerÚmake_resolverrE   rV   Útrace_basic_infoÚresolveÚget_requirementÚKeyErrorÚsatisfied_byr   r3   rL   Úvaluesr%   r   ÚformatÚjoinÚlegacy_install_reasonÚget_installation_orderÚignore_dependenciesrI   Ú_determine_conflictsrH   r   rG   Úget_lib_location_guessesr   ÚsortÚoperatorÚ
attrgetterr)   Úget_distributionÚversionÚ	ExceptionÚappendÚ_warn_about_conflictsÚdetermine_resolver_variantr    ÚOSErrorÚ	verbosityÚcreate_os_error_messageÚerrorr   ÚAssertionErrorÚ_handle_target_dirr   r   )(rc   rj   ÚargsrB   rX   Útarget_temp_dirÚtarget_temp_dir_pathrY   rk   rl   rr   rt   rq   Ú	directoryÚreqsrs   ÚresolverÚrequirement_setÚpip_reqrw   Úreqs_to_buildÚ_Úbuild_failuresÚpep517_build_failure_namesrz   Ú
to_installÚ	conflictsÚshould_warn_about_conflictsrH   Ú	installedÚlib_locationsÚenvÚitemsÚresultÚitemÚinstalled_distÚinstalled_descr·   Úshow_tracebackÚmessager0   r{   r1   Úrunâ   sj   

ûÿÿ



üý ÿúö
 ÿ

ÿÿ
ÿû

þþÿ

ÿ
þ
÷û


þ
 ÿ
  ÿ
  ÿzInstallCommand.runc                    sN  t |ƒ g }td|jd�}|j}|j}|j}tj |¡rB| |¡ tj |¡r`||kr`| |¡ tj |¡rv| |¡ |D ]Î}	t 	|	¡D ]¾}
|	|krÂtj 
||
¡‰ t‡ fdd„|d d… D ƒƒrÂqˆtj 
||
¡}tj |¡�r0|sðt d|¡ qˆtj |¡�rt d|¡ qˆtj |¡�r&t |¡ n
t |¡ t tj 
|	|
¡|¡ qˆqzd S )Nr'   )r€   c                 3   s   | ]}|  ˆ ¡V  qd S ©N)Ú
startswith)ry   Ús©Úddirr0   r1   Ú	<genexpr>â  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‘   ÚpurelibÚplatlibÚdatar�   r“   r±   Úlistdirr¥   Úanyr�   ÚwarningÚislinkr”   ÚshutilÚrmtreeÚremoveÚmove)rc   r5   r»   rA   Úlib_dir_listÚschemeÚpurelib_dirÚplatlib_dirÚdata_dirÚlib_dirrÎ   Útarget_item_dirr0   r×   r1   r¹   È  sN    


ýû
þz!InstallCommand._handle_target_dirc                 C   s0   z
t |ƒW S  tk
r*   t d¡ Y d S X d S )NzwError while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new)r   r°   r�   Ú	exception)rc   rÆ   r0   r0   r1   r©      s    
ÿz#InstallCommand._determine_conflictsc              
   C   sò   |\}\}}|s|sd S g }|dkr0|  d¡ n|dks<t‚|  d¡ |D ]<}|| d }|| D ]"}	dj|||	d d�}
|  |
¡ qbqJ|D ]P}|| d }|| D ]6\}}}d	j||||||dkrÈd
ndd�}
|  |
¡ q¤qŒt d |¡¡ d S )NÚlegacyz¤pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.z2020-resolverz§pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.r   z@{name} {version} requires {requirement}, which is not installed.r‰   )r)   r¯   Úrequirementzg{name} {version} requires {requirement}, but {you} have {dep_name} {dep_version} which is incompatible.Úyouzyou'll)r)   r¯   rï   Údep_nameÚdep_versionrð   Ú
)r±   r¸   r¤   r�   Úcriticalr¥   )rc   Úconflict_detailsr‡   Úpackage_setÚmissingÚconflictingÚpartsÚproject_namer¯   Ú
dependencyrÒ   rñ   rò   r+   r0   r0   r1   r²     sH    ÿÿÿúÿ÷z$InstallCommand._warn_about_conflictsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusagere   r   rÓ   r¹   r©   r²   r0   r0   r0   r1   r4   >   s    
 f8r4   Fc                 C   s    t d| ||||d�}|j|jgS )Nr'   )rƒ   r€   r   r„   r�   )r   rÛ   rÜ   )rƒ   r€   r   r„   r�   rç   r0   r0   r1   rª   A  s    úrª   c                 C   s   t dd„ tt| |d�ƒD ƒƒS )Nc                 s   s   | ]}t |ƒV  qd S rÔ   r   )ry   Údr0   r0   r1   rÙ   V  s    z)site_packages_writable.<locals>.<genexpr>©r   r„   )ÚallÚsetrª   r  r0   r0   r1   Úsite_packages_writableT  s
    
ÿÿr  c                 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 disabledr  z0Non-user install because site-packages writeablezMDefaulting to user installation because normal site-packages is not writeable)
r�   rŽ   r   r#   r   r¸   ÚsiteÚENABLE_USER_SITEr  Úinfo)r;   r@   r5   r?   rg   r0   r0   r1   r�   \  s4    
ÿÿ




r�   c                 C   sŠ   dd„ }g }| D ]0}|j }t|ƒ}|r| d || ¡ ƒ|¡¡ q|rjt|ƒ}|rj| d || ¡ ƒ¡¡ |srdS t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)ry   r)   r0   r0   r1   r|   Ÿ  s     zSreject_location_related_install_options.<locals>.format_options.<locals>.<listcomp>r0   )Úoption_namesr0   r0   r1   Úformat_options�  s    z?reject_location_related_install_options.<locals>.format_optionsz{!r} from {}z{!r} from command lineNz˜Location-changing options found in --install-option: {}. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.z; )rX   r   r±   r¤   Úkeysr   r¥   )rL   rj   r  Ú	offendersrï   rX   Úlocation_optionsr0   r0   r1   r›   ˜  s6    
 ÿÿ
ÿÿýÿr›   c                 C   s    g }|  d¡ |s,|  d¡ |  t| ƒ¡ n
|  d¡ |d  d7  < | jtjkrŽd}d}tƒ sz|sz| |d| ¡ g¡ n
|  |¡ |  d	¡ d
 |¡ ¡ d S )zrFormat an error message for an OSError

    It may occur anytime during the execution of the install command.
    z,Could not install packages due to an OSErrorz: Ú.rÚ   ró   z"Consider using the `--user` optionzCheck the permissionsz or z.
r'   )	r±   ÚstrÚerrnoÚEACCESr"   ÚextendÚlowerr¥   Ústrip)r·   rÑ   Úusing_user_siterù   Úuser_option_partÚpermissions_partr0   r0   r1   r¶   Â  s&    



 þ

r¶   )FNNFN)NNNF)Jr  Úloggingr¬   r�   râ   r  Úoptparser   r   Útypingr   r   r   Úpip._vendor.packaging.utilsr   Úpip._internal.cacher   Zpip._internal.clir	   Zpip._internal.cli.cmdoptionsr
   Úpip._internal.cli.req_commandr   r   r   Úpip._internal.cli.status_codesr   r   Úpip._internal.exceptionsr   r   Úpip._internal.locationsr   Úpip._internal.metadatar   Ú#pip._internal.models.format_controlr   Úpip._internal.operations.checkr   r   Úpip._internal.reqr   Zpip._internal.req.req_installr   Úpip._internal.req.req_trackerr   Ú"pip._internal.utils.distutils_argsr   Úpip._internal.utils.filesystemr   Úpip._internal.utils.miscr   r   r   r    Úpip._internal.utils.temp_dirr!   Úpip._internal.utils.virtualenvr"   r#   Úpip._internal.wheel_builderr$   r%   r&   Ú	getLoggerrü   r�   r3   r4   rª   r  r�   r›   r¶   r0   r0   r0   r1   Ú<module>   s`   
         û

    û
<*