B
    oºˆd2p  ã               @   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^   úP/var/www/html/venv/lib/python3.7/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}y|  !|||
|¡}t"||ƒ t#|j$ƒ}x|D ]}d|_%q€W | j&|||||
|j | j'd}| j(||
|||j |j|j|j)||j*d
}|  +|
¡ |j,||j d}|jrPt-|j.ƒ}|jdkrt/| 0¡ d n2t1|jddd}t2j3| 0¡ |ddd W d Q R X |jrt4dd„ |j.D ƒƒ}|rŒt5dd 6dd„ |D ƒ¡ƒ t7S y| 8d¡}W n t9k
r¸   d}Y nX |j:d k}t;|d dd „ |j< =¡ D ƒ}t>||dg |d!\}}|rt?d" @d# 6d$d„ |D ƒ¡¡ƒ‚| A|¡}d }|jB o8|jC}|rJ|  D|¡}|jE}|js`|jrdd}tF|||j||j||j |jGd%}tH|j ||j|j|jd&} tI| ƒ}!|jJtK Ld'¡d( g }"x^|D ]V}#|#jM}$y(|! N|$¡}%|%d k	rò|$› d|%jO› }$W n tPk
r
   Y nX |" Q|$¡ qÂW |d k	r:| jR||  S|¡d) d 6|"¡}&|&rTt5d*|&ƒ W nJ tTk
r  }' z*| j'd+k}(tU|'|(|j ƒ})tjV|)|(d, tWS d }'~'X Y nX |jrÆ|s´tX‚|  Y|j||j	¡ |jZd-krØt[ƒ  t7S ).Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)Úcheck_targetzUsing %s)r5   r/   r4   Úisolated_modez=Target path exists but is not a directory, will not continue.Útarget)Úkind)ra   ÚsessionÚtarget_pythonrJ   Úinstall)Údeleterf   Úglobally_managed)Útemp_build_dirra   Úbuild_trackerrg   Úfinderr2   Ú	verbosity)
Úpreparerrn   ra   Úwheel_cacher2   r;   rJ   r:   r7   rL   )Ú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 )rs   N)Újoin)r}   Úitemr^   r^   r_   r     s    Úpip)Úmodifying_pipc             S   s   g | ]}t |ƒr|‘qS r^   )r&   )r}   r~   r^   r^   r_   ú
<listcomp>œ  s   z&InstallCommand.run.<locals>.<listcomp>)rq   ÚverifyÚbuild_optionsrQ   zYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, c             s   s   | ]}|j V  qd S )N)rz   )r}   r~   r^   r^   r_   r   ­  s    )ÚrootÚhomeÚprefixr=   r2   Ú	pycompile)Úuserr‰   rˆ   rŠ   Úisolatedrz   )Úkey)Úresolver_variantzSuccessfully installed %sé   )Úexc_infoÚwarn)\r2   r/   r   r*   r?   r4   r5   rO   r   r6   r7   r   Úcheck_dist_restrictionÚloggerÚverboser   Údecide_user_installrd   r;   ÚosÚpathÚabspathÚexistsÚisdirr"   Úenter_contextrQ   Úget_default_sessionr	   Ú_build_package_finderrJ   r   Úno_cleanÚget_requirementsr   r   Ú	cache_dirÚpermit_editable_wheelsÚmake_requirement_preparerro   Úmake_resolverr:   rL   Útrace_basic_infoÚresolver   Úrequirements_to_installr   Úto_dictÚopenÚjsonÚdumpÚsortedr!   r   r   Úget_requirementÚKeyErrorÚsatisfied_byr    rC   Úvaluesr%   r   ÚformatÚget_installation_orderÚignore_dependenciesr>   Ú_determine_conflictsr=   r   r<   Úget_lib_location_guessesr   ÚsortÚoperatorÚ
attrgetterrz   Úget_distributionr{   Ú	ExceptionÚappendÚ_warn_about_conflictsÚdetermine_resolver_variantÚOSErrorÚcreate_os_error_messageÚerrorr   ÚAssertionErrorÚ_handle_target_dirrW   r   )*r\   ra   rb   Ú#installing_into_current_environmentr7   Útarget_temp_dirÚtarget_temp_dir_pathrQ   rg   rh   rn   rm   Ú	directoryÚreqsrq   Úreqrp   Ú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	  sJ   













 














zInstallCommand.run)r/   rÄ   r6   r(   c                sV  t |ƒ g }td|jd}|j}|j}|j}tj |¡rB| |¡ tj |¡r`||kr`| |¡ tj |¡rv| |¡ xÚ|D ]Ò}	xÌt 	|	¡D ]¾}
|	|krÆtj 
||
¡‰ t‡ fdd„|d d… D ƒƒrÆqŒtj 
||
¡}tj |¡r4|sôt d|¡ qŒtj |¡rt d|¡ qŒtj |¡r*t |¡ n
t |¡ t tj 
|	|
¡|¡ qŒW q|W d S )NÚ )r‰   c             3   s   | ]}|  ˆ ¡V  qd S )N)Ú
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Úplatlibrt   r—   rš   r»   Úlistdirr   Úanyr”   ÚwarningÚislinkr›   ÚshutilÚrmtreeÚremoveÚmove)r\   r/   rÄ   r6   Úlib_dir_listÚschemeÚpurelib_dirÚplatlib_dirÚdata_dirÚlib_dirr‚   Útarget_item_dirr^   )râ   r_   rÂ     sD    




z!InstallCommand._handle_target_dir)rÒ   r(   c             C   s,   yt |ƒS  tk
r&   t d¡ 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´   8  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¡ xH|D ]@}|| d }x.|| D ]"}	dj|||	d d}
|  |
¡ qfW qLW x\|D ]T}|| d }xB|| D ]6\}}}d	j||||||dkrÔd
ndd}
|  |
¡ q°W q–W 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   )rz   r{   Úrequirementzg{name} {version} requires {requirement}, but {you} have {dep_name} {dep_version} which is incompatible.Úyouzyou'll)rz   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¼   D  s<    

z$InstallCommand._warn_about_conflicts)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager`   r   r   r   ÚstrÚintrÞ   r"   ÚboolrÂ   r   r   r   r´   r¼   r^   r^   r^   r_   r'   4   s    B z5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 )N)r   )r}   Údr^   r^   r_   r     s   z)site_packages_writable.<locals>.<genexpr>)rˆ   r   )ÚallÚsetrµ   )rˆ   r   r^   r^   r_   Úsite_packages_writable  s    r  )r2   r5   r/   r4   rd   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 disabled)rˆ   r   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)r2   r5   r/   r4   rd   r^   r^   r_   r–   ”  s2    




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¿   Ñ  s0    





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`       L    	   8