3
gl                 @   sH  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l/m0Z0 d dl1m2Z2 d dl3m4Z4 d dl5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; d dl<m=Z=m>Z> d dl?m@Z@mAZAmBZB e4eCZDe#e@dddZEG dd deZFd/eGeeH eeH eGeeH e
eH d d!d"ZIeeH eGeGd#d$d%ZJd0eeG eeH eeH eeH eGeGd&d'd(ZKe
e* ee
eH  dd)d*d+ZLeMeGeGeHd,d-d.ZNdS )1    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)WINDOWS)parse_distutils_args)test_writable_dir)	getLogger)
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_command)format_controlreturnc                s   t td fdd}|S )N)reqr)   c                s    t | jp
d} j|}d|kS )N binary)r   nameget_allowed_formats)r*   canonical_nameZallowed_formats)r(    \/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/commands/install.pycheck_binary_allowed5   s    
z6get_check_binary_allowed.<locals>.check_binary_allowed)r   bool)r(   r2   r0   )r(   r1   get_check_binary_allowed4   s    r4   c               @   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)r)   c             C   sj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jddddd dd tj| 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 jtj
  | 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 jtj  | j jtj  | j jtj  | j jtj  | j jtj  | j jtj  | 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 jtj  | j jtj  | j jtj  | j jtj  | j jtj  tjtj| j}| jjd3| | jjd3| j  d S )4Nz-tz--target
target_dirdirzInstall 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_truezInstall 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.))r8   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upgradezUpgrade 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).)r8   r:   choicesr;   z--force-reinstallforce_reinstallz;Reinstall all packages even if they are already up-to-date.z-Iz--ignore-installedignore_installedzIgnore 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>   r8   r:   r;   z--no-compilez.Do not compile Python source files to bytecode)r>   r8   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   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)selfZ
index_optsr0   r0   r1   add_optionsQ   s    
zInstallCommand.add_options)optionsargsr)   c       )         s8  |j r|jd k	rtdtj| d}|jr2|j}tj|dd |jpHg }t	j
dt  t|j |j|j|j|jd|_ d }d }|jrd|_tjj|j|_tjj|jrtjj|j rtdtdd	}|j}| j| |jpg }| j|}t|}	| j|||	|jd
}
t|j|j}| jt  }t|j! ddd}y| j"|||
|}x|D ]}d|_#qPW t$||j | j%|||||
|j d}| j&||
|||j |j|j|j'||j(d
}| j)|
 |j*||j d}y|j+d}W n t,k
r   d}Y nX |j-d k}t.|d t/|
j  fdd|j0j1 D }t2||dg g d\}}dd |D }|rft3dj4dj5|x|D ]}|j(sld|_6qlW |j7|}d }|j8 o|j9}|r| j:|}|j;}|js|jrd}t<||||j||j||j |j=d	}t>|j ||j|j|jd}t?|} |j@tAjBdd g }!x^|D ]V}"|"jC}#y(| jD|#}$|$d k	r\|# d|$jE }#W n tFk
rt   Y nX |!jG|# q,W |d k	r| jH|| jI|d d j5|!}%|%rtJd!|% W nH tKk
r }& z*| jLd"k}'tM|&|'|j }(t	jN|(|'d# tOS d }&~&X nX |jr.|stP| jQ|j||j tR  tSS )$Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)check_targetzUsing %s)rA   r6   r@   isolated_modez=Target path exists but is not a directory, will not continue.target)kind)rd   sessiontarget_pythonrS   install)deleteri   globally_managed)Ztemp_build_dirrd   req_trackerrj   finderr<   )
preparerrp   rd   wheel_cacher<   rF   rS   rE   rC   rU   )Zcheck_supported_wheelspipF)modifying_pipc                s   g | ]}t | r|qS r0   )r'   ).0r)r2   r0   r1   
<listcomp>c  s   z&InstallCommand.run.<locals>.<listcomp>)rr   verifybuild_optionsrX   c             S   s   g | ]}|j r|jqS r0   )rU   r-   )ru   rv   r0   r0   r1   rw   s  s    zYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, i   )roothomeprefixrH   r<   Z	pycompile)userr{   rz   r|   isolatedr-   )key-)resolver_variant zSuccessfully installed %s   )exc_info)Tr<   r6   r   r	   check_install_build_globalrB   rC   check_dist_restrictionrW   loggerverboser   decide_user_installrA   r@   rg   rF   ospathabspathexistsisdirr"   enter_contextrX   Zget_default_sessionr
   Z_build_package_finderrS   r   	cache_dirr(   r   no_cleanZget_requirementsZpermit_editable_wheels'reject_location_related_install_optionsZmake_requirement_preparerZmake_resolverrE   rU   Ztrace_basic_inforesolveZget_requirementKeyErrorZsatisfied_byr    r4   rL   valuesr&   r   formatjoinZlegacy_install_reasonZget_installation_orderignore_dependenciesrI   _determine_conflictsrH   r   rG   get_lib_location_guessesr   sortoperator
attrgetterr-   get_distributionversion	Exceptionappend_warn_about_conflictsZdetermine_resolver_variantr!   OSError	verbositycreate_os_error_messageerrorr   AssertionError_handle_target_dirr   r   ))rb   rd   re   rC   rW   target_temp_dirZtarget_temp_dir_pathrX   rj   rk   rp   rr   ro   	directoryreqsr*   rq   ZresolverZrequirement_setZpip_reqrt   Zreqs_to_build_Zbuild_failuresZpep517_build_failure_namesrv   
to_installZ	conflictsZshould_warn_about_conflictsrH   	installedZlib_locationsenvitemsresultitemZinstalled_distZinstalled_descr   show_tracebackmessager0   )r2   r1   run   s*   




























zInstallCommand.run)r6   r   rB   r)   c                sV  t | g }td|jd}|j}|j}|j}tjj|rB|j| tjj|r`||kr`|j| tjj|rv|j| x|D ]}	xtj	|	D ]}
|	|krtjj
||
 t fdd|d d D rqtjj
||
}tjj|r4|stjd| qtjj|rtjd| qtjj|r*tj| n
tj| tjtjj
|	|
| qW q|W d S )	Nr+   )r{   c             3   s   | ]}|j  V  qd S )N)
startswith)ru   s)ddirr0   r1   	<genexpr>  s    z4InstallCommand._handle_target_dir.<locals>.<genexpr>r   zKTarget directory %s already exists. Specify --upgrade to force replacement.zTarget 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)rb   r6   r   rB   Zlib_dir_listschemeZpurelib_dirZplatlib_dirZdata_dirlib_dirr   Ztarget_item_dirr0   )r   r1   r     sD    




z!InstallCommand._handle_target_dir)r   r)   c             C   s,   yt |S  tk
r&   tj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)rb   r   r0   r0   r1   r     s    z#InstallCommand._determine_conflicts)conflict_detailsr   r)   c          
   C   s  |\}\}}| r| rd S g }|dkr4|j d n|dks@t|j d xH|D ]@}|| d }x.|| D ]"}	dj|||	d d}
|j |
 qjW qPW x\|D ]T}|| d }xB|| D ]6\}}}d	j||||||dkrd
ndd}
|j |
 qW qW tjdj| d S )NZlegacyzpip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.z2020-resolverzpip'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   )rb   r   r   Zpackage_setmissingZconflictingpartsproject_namer   
dependencyr   r   r   r*   r0   r0   r1   r     s<    

z$InstallCommand._warn_about_conflicts)__name__
__module____qualname____doc__usagerc   r   r   r   strintr   r"   r3   r   r   r   r   r   r   r0   r0   r0   r1   r5   =   s      g5r5   F)r}   r{   rz   r~   r|   r)   c             C   s    t d| ||||d}|j|jgS )Nr+   )r}   r{   rz   r~   r|   )r   r   r   )r}   r{   rz   r~   r|   r   r0   r0   r1   r   O  s    r   )rz   r~   r)   c             C   s   t dd tt| |dD S )Nc             s   s   | ]}t |V  qd S )N)r   )ru   dr0   r0   r1   r   c  s   z)site_packages_writable.<locals>.<genexpr>)rz   r~   )allsetr   )rz   r~   r0   r0   r1   site_packages_writablea  s    r   )r<   rA   r6   r@   rg   r)   c             C   s   | dk	r|  rt jd dS | rH|r,tdt r:tdt jd dS | dksTt|s\|rjt jd dS tjs~t jd	 dS t||d
rt jd dS t j	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)rz   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)r<   rA   r6   r@   rg   r0   r0   r1   r   h  s2    




r   )rL   rd   r)   c             C   s   t t tt ddd}g }x8| D ]0}|j}t|}|r"|jdj||j | q"W |r~t|}|r~|jdj||j  |sdS tdjdj	|dS )	zIf any location-changing --install-option arguments were passed for
    requirements or on the command-line, then show a deprecation warning.
    )option_namesr)   c             S   s   dd | D S )Nc             S   s   g | ]}d j |jddqS )z--{}r   r   )r   replace)ru   r-   r0   r0   r1   rw     s    zSreject_location_related_install_options.<locals>.format_options.<locals>.<listcomp>r0   )r   r0   r0   r1   format_options  s    z?reject_location_related_install_options.<locals>.format_optionsz{!r} from {}z{!r} from command lineNzLocation-changing options found in --install-option: {}. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.z; )
r   r   r   rW   r   r   r   keysr   r   )rL   rd   r   Z	offendersr   rW   Zlocation_optionsr0   r0   r1   r     s&    
r   )r   r   using_user_siter)   c             C   s   g }|j d |s,|j d |j t|  n
|j d |d  d7  < | jtjkrd}d}t  r~| r~|j|d|j g n
|j | |j d	 tr| jtjkr| j	rt
| j	d
kr|j d dj|j 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  zHINT: 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   r   errnoEACCESr#   extendlowerr   ENOENTfilenamelenr   strip)r   r   r   r   Zuser_option_partZpermissions_partr0   r0   r1   r     s0    




r   )FNNFN)NNNF)Or   r   r   r   r   optparser   r   typingr   r   r   pip._vendor.packaging.utilsr   Zpip._internal.cacher   Zpip._internal.clir	   Zpip._internal.cli.cmdoptionsr
   Z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   Zpip._internal.operations.checkr   r   Zpip._internal.reqr   Zpip._internal.req.req_installr   Zpip._internal.req.req_trackerr   pip._internal.utils.compatr   Z"pip._internal.utils.distutils_argsr   pip._internal.utils.filesystemr   pip._internal.utils.loggingr   pip._internal.utils.miscr   r   r    r!   pip._internal.utils.temp_dirr"   pip._internal.utils.virtualenvr#   r$   Zpip._internal.wheel_builderr%   r&   r'   r   r   r4   r5   r3   r   r   r   r   r   r   r   r0   r0   r0   r1   <module>   sf   	        	   8&