U
    ƒIÀdq  ã                   @   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 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% d dl&m'Z'm(Z( d dl)m*Z* d dl+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; d dl<m=Z=m>Z> d dl?m@Z@mAZA e3eBƒZCG dd„ deƒZDd(eEeeF eeF eEeeF e
eF dœdd„ZGeeF eEeEdœd d!„ZHd)eeE eeF eeF eeF eEeEd"œd#d$„ZIeJeEeEeFd%œd&d'„ZKdS )*é    N)ÚSUPPRESS_HELPÚValues)ÚListÚOptional)Ú
print_json)Ú
WheelCache)Ú
cmdoptions)Úmake_target_python)ÚRequirementCommandÚwarn_if_run_as_rootÚwith_cleanup)ÚERRORÚSUCCESS)ÚCommandErrorÚInstallationError)Ú
get_scheme)Úget_environment)ÚInstallationReport)Úget_build_tracker)ÚConflictDetailsÚcheck_install_conflicts)Úinstall_given_reqs)ÚInstallRequirementÚcheck_legacy_setup_py_options)ÚWINDOWS©Útest_writable_dir)Ú	getLogger)Úcheck_externally_managedÚ
ensure_dirÚget_pip_versionÚ(protect_pip_from_modification_on_windowsÚwrite_output)ÚTempDirectory)Úrunning_under_virtualenvÚvirtualenv_no_global)ÚbuildÚ should_build_for_install_commandc                   @   sz   e Zd ZdZdZddœdd„Zeeee	 e
dœdd	„ƒZe	eedd
œdd„Zee ee dœdd„Zee	ddœ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> ...N)Úreturnc                 C   sÆ  | 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 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 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  t ¡ ¡ | j  t ¡ ¡ | j jd*dd+d,d-d� | j jd.dd+d/d0� | j jd1dd2d,d3d� | j jd4dd5d,d6d� | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ | j  t ¡ ¡ t tj| j¡}| j d7|¡ | j d7| j ¡ | j jd8d9d:d d;d� d S )<Nz	--dry-runÚ
store_trueÚdry_runFzŒDon't actually install anything, just print what would be. Can be used in combination with --ignore-installed to 'resolve' the requirements.)ÚactionÚdestÚdefaultÚhelpz-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.)r-   Úmetavarr.   r/   z--userÚuse_user_sitez¸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-   r,   r/   z	--no-userÚstore_falsez--rootÚ	root_pathz=Install everything relative to this alternate root directory.z--prefixÚprefix_patha[  Installation prefix where lib, bin and other top-level folders are placed. Note that the resulting installation may contain scripts and other resources which reference the Python interpreter of pip, and not that of ``--prefix``. See also the ``--python`` option if the intention is to install packages into another (possibly pip-free) environment.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-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).)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 bytecodez--no-compilez.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   z--reportÚjson_report_fileÚfileaW  Generate a JSON file describing what pip did to install the provided requirements. Can be used in combination with --dry-run and --ignore-installed to 'resolve' the requirements. When - is used as file name it writes to stdout. When writing to stdout, please combine with the --quiet option to avoid mixing pip logging output with JSON output.)Úcmd_optsÚ
add_optionr   ÚrequirementsÚconstraintsÚno_depsÚpreÚeditableÚadd_target_python_optionsr   ÚsrcÚignore_requires_pythonÚno_build_isolationÚ
use_pep517Úno_use_pep517Úcheck_build_depsÚoverride_externally_managedÚconfig_settingsÚglobal_optionsÚ	no_binaryÚonly_binaryÚprefer_binaryÚrequire_hashesÚprogress_barÚroot_user_actionÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r_   úW/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/pip/_internal/commands/install.pyÚadd_optionsH   s   úùûüûúúúüúûüûûþúzInstallCommand.add_options)ÚoptionsÚargsr)   c           *      C   sæ  |j r|jd k	rtdƒ‚|jo"|j oB|jd koB|jd koB|jd k}|rT|jsTtƒ  d}|j	rd|j
}tj|dd� 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ƒ ¡}t|j  ddd�}�z|  !|||
|¡}t"||ƒ t#|j$ƒ}|D ]}d|_%�q~| j&|||||
|j | j'd�}| j(||
|||j |j|j|j)||j*d�
}|  +|
¡ |j,||j d�}|j�rLt-|j.ƒ}|jdk�rt/| 0¡ d� n2t1|jddd��}t2j3| 0¡ |ddd� W 5 Q R X |j�r–| 4¡  t5dd„ |j.D ƒƒ}|�r�t6dd 7dd„ |D ƒ¡ƒ t8W S z| 9d¡}W n t:k
�r¾   d}Y nX |j;d k}t<|d� dd „ |j= >¡ D ƒ}t?||dg |d!�\}}|�r"t@d" Ad# 7d$d„ |D ƒ¡¡ƒ‚| B|¡}d }|jC �o>|jD}|�rP|  E|¡}|jF}|j�sf|j�rjd}tG|||j||j||j |jHd%�}tI|j ||j|j|jd&�} tJ| ƒ}!|jKtL Md'¡d(� g }"|D ]V}#|#jN}$z(|! O|$¡}%|%d k	�rö|$› d|%jP› �}$W n tQk
�r   Y nX |" R|$¡ �qÆ|d k	�r<| jS||  T|¡d)� d 7|"¡}&|&�rVt6d*|&ƒ W nR tUk
�rª }' z2| j'd+k}(tV|'|(|j ƒ})tjW|)|(d,� tX W Y ¢S d }'~'X Y nX |j�rÐ|�s¾tY‚|  Z|j||j	¡ |j[d-k�rât\ƒ  t8S ).Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)Úcheck_targetzUsing %s)r6   r0   r5   Úisolated_modez=Target path exists but is not a directory, will not continue.Útarget)Úkind)rb   ÚsessionÚtarget_pythonrK   Úinstall)Údeleterg   Úglobally_managed)Útemp_build_dirrb   Úbuild_trackerrh   Úfinderr3   Ú	verbosity)
Úpreparerro   rb   Úwheel_cacher3   r<   rK   r;   r8   rM   )Úcheck_supported_wheelsú-)ÚdataÚwzutf-8)Úencodingé   F)ÚindentÚensure_asciic                 s   s"   | ]}|j d  |j d fV  qdS )ÚnameÚversionN)Úmetadata©Ú.0Úrr_   r_   r`   Ú	<genexpr>‰  s   ÿz%InstallCommand.run.<locals>.<genexpr>zWould install %sú c                 s   s   | ]}d   |¡V  qdS )rt   N)Újoin)r   Úitemr_   r_   r`   r�   �  s     Úpip)Úmodifying_pipc                 S   s   g | ]}t |ƒr|‘qS r_   )r'   r~   r_   r_   r`   Ú
<listcomp>ž  s   þz&InstallCommand.run.<locals>.<listcomp>)rr   ÚverifyÚbuild_optionsrR   zYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, c                 s   s   | ]}|j V  qd S ©N)r{   r~   r_   r_   r`   r�   °  s     )ÚrootÚhomeÚprefixr>   r3   Ú	pycompile)ÚuserrŒ   r‹   r�   Úisolatedr{   )Úkey)Úresolver_variantzSuccessfully installed %sé   )Úexc_infoÚwarn)]r3   r0   r   r+   r@   r5   r6   rP   r   r7   r8   r   Úcheck_dist_restrictionÚloggerÚverboser    Údecide_user_installre   r<   ÚosÚpathÚabspathÚexistsÚisdirr#   Úenter_contextrR   Úget_default_sessionr	   Ú_build_package_finderrK   r   Úno_cleanÚget_requirementsr   r   Ú	cache_dirÚpermit_editable_wheelsÚmake_requirement_preparerrp   Úmake_resolverr;   rM   Útrace_basic_infoÚresolver   Úrequirements_to_installr   Úto_dictÚopenÚjsonÚdumpZ#warn_legacy_versions_and_specifiersÚsortedr"   rƒ   r   Úget_requirementÚKeyErrorÚsatisfied_byr!   rD   Úvaluesr&   r   ÚformatÚget_installation_orderÚignore_dependenciesr?   Ú_determine_conflictsr>   r   r=   Úget_lib_location_guessesr   ÚsortÚoperatorÚ
attrgetterr{   Úget_distributionr|   Ú	ExceptionÚappendÚ_warn_about_conflictsÚdetermine_resolver_variantÚOSErrorÚcreate_os_error_messageÚerrorr   ÚAssertionErrorÚ_handle_target_dirrX   r   )*r]   rb   rc   Ú#installing_into_current_environmentr8   Útarget_temp_dirÚtarget_temp_dir_pathrR   rh   ri   ro   rn   Ú	directoryÚreqsrr   Úreqrq   ÚresolverÚrequirement_setÚreportÚfÚwould_install_itemsÚpip_reqr†   Úreqs_to_buildÚ_Úbuild_failuresÚ
to_installÚ	conflictsÚshould_warn_about_conflictsr>   Ú	installedÚlib_locationsÚenvÚitemsÚresultr„   Úinstalled_distÚinstalled_descrÃ   Úshow_tracebackÚmessager_   r_   r`   Úrun	  s†   ÿþüÿþûþýÿ


üý


ù	ö
 ÿ
 þþ


þû
þÿ
ÿ
øû


þ
þ
ý
  ÿzInstallCommand.run)r0   rÇ   r7   r)   c                    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 )NÚ )rŒ   c                 3   s   | ]}|  ˆ ¡V  qd S rŠ   )Ú
startswith)r   Ús©Úddirr_   r`   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›   ÚpurelibÚplatlibru   rš   r�   r¾   Úlistdirrƒ   Úanyr—   ÚwarningÚislinkrž   ÚshutilÚrmtreeÚremoveÚmove)r]   r0   rÇ   r7   Úlib_dir_listÚschemeÚpurelib_dirÚplatlib_dirÚdata_dirÚlib_dirr„   Útarget_item_dirr_   rå   r`   rÅ     sH    


ýû
z!InstallCommand._handle_target_dir)rÕ   r)   c                 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)r]   rÕ   r_   r_   r`   r·   ;  s    
ÿz#InstallCommand._determine_conflicts)Úconflict_detailsr’   r)   c              
   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ƒ   )r]   rú   r’   Úpackage_setÚmissingÚconflictingÚpartsÚproject_namer|   Ú
dependencyrà   rþ   rÿ   rË   r_   r_   r`   r¿   G  sH    ÿÿÿúÿ÷z$InstallCommand._warn_about_conflicts)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusagera   r   r   r   ÚstrÚintrá   r#   ÚboolrÅ   r   r   r   r·   r¿   r_   r_   r_   r`   r(   4   s&    B }  þ7þ þr(   F)r�   rŒ   r‹   r�   r�   r)   c                 C   s    t d| ||||d�}|j|jgS )Nrâ   )r�   rŒ   r‹   r�   r�   )r   rè   ré   )r�   rŒ   r‹   r�   r�   ró   r_   r_   r`   r¸   ~  s    úr¸   )r‹   r�   r)   c                 C   s   t dd„ tt| |d�ƒD ƒƒS )Nc                 s   s   | ]}t |ƒV  qd S rŠ   r   )r   Údr_   r_   r`   r�   ‘  s   ÿz)site_packages_writable.<locals>.<genexpr>©r‹   r�   )ÚallÚsetr¸   r  r_   r_   r`   Úsite_packages_writable�  s    þr  )r3   r6   r0   r5   re   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—   Údebugr   r%   r   rÄ   ÚsiteÚENABLE_USER_SITEr  Úinfo)r3   r6   r0   r5   re   r_   r_   r`   r™   —  s8    
ÿÿ



ÿr™   )rÃ   rß   Úusing_user_siter)   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	¡ tr¼| jtjkr¼| j	r¼t
| j	ƒd
kr¼|  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.
i  zÉHINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
râ   )r¾   r  ÚerrnoÚEACCESr$   ÚextendÚlowerr   ÚENOENTÚfilenameÚlenrƒ   Ústrip)rÃ   rß   r  r  Úuser_option_partÚpermissions_partr_   r_   r`   rÂ   Ô  s>    



ýÿ

ÿ
þýüÿrÂ   )FNNFN)NNNF)Lr  r­   rº   rš   rî   r  Úoptparser   r   Útypingr   r   Úpip._vendor.richr   Ú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.installation_reportr   Ú,pip._internal.operations.build.build_trackerr   Úpip._internal.operations.checkr   r   Úpip._internal.reqr   Zpip._internal.req.req_installr   r   Úpip._internal.utils.compatr   Úpip._internal.utils.filesystemr   Úpip._internal.utils.loggingr   Úpip._internal.utils.miscr   r   r    r!   r"   Úpip._internal.utils.temp_dirr#   Úpip._internal.utils.virtualenvr$   r%   Úpip._internal.wheel_builderr&   r'   r  r—   r(   r  r  r¸   r  r™   rÁ   rÂ   r_   r_   r_   r`   Ú<module>   s‚       O     ûú	    ûú>  þ