U
    cUh[                     @   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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mZmZ d dlmZ d dlmZmZ d dlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ d d	l,m-Z- d d
l.m/Z/ d dl0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< ddddddddddddddgZ=e>e?Z@e)dZAe'e(eB eBef ZCe'eDeDeDf ZEe'eFe'e$eF e$eF f f ZGeeeeBgef ZHeeeeCgef ZId ZJeFd!d"d#ZKe'eDd$f e'eDeDeDf d%d&d'ZLeFdd(d)dZMeFd!d*dZNe:d+d,d-deFeOe$eH dd/d0dZPedd1d2d3ZQedd1d4d5ZReRd6eee*eCeBf eHdd7d8d9ZSeFeFd(d:dZTdeFeFeFd<d=dZUeFe eF eFd>d?d@ZVeFddAdBdCZWeFe eF eFd>dDdZXeFeFdAdEdFZYeFeFdAdGdHZZeFeDdIdJdKZ[e\eFdLdMdZ]e e e  e'e"eF e"eD f dNdOdPZ^eFeOd(dQdZ_eJfeeDee`ddf dRdSdTZadeFeOeFdVdWdZbeFe'eFeFf d(dXdZceFeFddYdZdZdeFeOd(d[d\Zeeedd]d^d_ZfG d`da daeZgeee(e dbdcddZheFe$eD eFdedfdgZideFeFeFdidjdkZjeFe'e$eF e$eD f dldmdnZkeFeGdldodpZleFeFdldqdrZmeFeeFge'ed$f f e'eFeGf dsdtduZneFeGdldvdwZoeFe'eF dldxdyZpeFe'eFeFe'e$eF e$eF f f dzd{d|ZqeFeFdzd}dZreFeFdzd~dZse-eFdddZtedUdG dd dZueFeudddZveFeudzddZweOddddZxdd!ddZyeOd!ddZzdeFeDe'eeDf dddZ{e e e!e'eef  dddZ|eeAgeOf e eA e'e eA e eA f dddZ}G dd de/Z~dd!ddZdS )    N)	dataclass)partial)StringIO)filterfalseteezip_longest)Path)FunctionTypeTracebackType)AnyBinaryIOCallable	GeneratorIterableIteratorListMappingOptionalSequenceTextIOTupleTypeTypeVarUnioncast)Requirement)BuildBackendHookCaller)__version__)CommandErrorExternallyManagedEnvironment)get_major_minor_version)WINDOWS)retry)running_under_virtualenvrmtreedisplay_path
backup_dirasksplitextformat_sizeis_installable_dirnormalize_pathrenamesget_prog
ensure_dirremove_auth_from_urlcheck_externally_managed ConfiguredBuildBackendHookCallerT   returnc                  C   s>   t jt jtdd} t j| } dt d|  dt  dS )Nz..zpip z from z	 (python ))ospathjoindirname__file__abspathr   r    )Zpip_pkg_dir r=   X/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pip/_internal/utils/misc.pyget_pip_versionL   s    r?   .)py_version_infor5   c                 C   sD   t | dk r"| dt |  d 7 } nt | dkr:| dd } td| S )ax  
    Convert a tuple of ints representing a Python version to one of length
    three.

    :param py_version_info: a tuple of ints representing a Python version,
        or None to specify no version. The tuple can have any length.

    :return: a tuple of length three if `py_version_info` is non-None.
        Otherwise, return `py_version_info` unchanged (i.e. None).
       )r   NVersionInfo)lenr   )r@   r=   r=   r>   normalize_version_infoS   s
    rD   )r8   r5   c              
   C   sP   zt |  W n< tk
rJ } z|jtjkr:|jtjkr: W 5 d}~X Y nX dS )z os.path.makedirs without EEXIST.N)r7   makedirsOSErrorerrnoEEXISTZ	ENOTEMPTY)r8   er=   r=   r>   r.   f   s
    c               
   C   sR   z2t jtjd } | dkr*tj dW S | W S W n tttfk
rL   Y nX dS )Nr   )z__main__.pyz-cz -m pippip)	r7   r8   basenamesysargv
executableAttributeError	TypeError
IndexError)progr=   r=   r>   r-   p   s    
rA   g      ?)Zstop_after_delaywaitF)dirignore_errorsonexcr5   c                 C   sL   |rt }|d krt}tt|d}tjdkr:tj| |d ntj| |d d S )NrV   )rA      )onerror)_onerror_ignore_onerror_reraiser   rmtree_errorhandlerrL   version_infoshutilr$   )rT   rU   rV   handlerr=   r=   r>   r$   }   s    
)_argsr5   c                  G   s   d S Nr=   r`   r=   r=   r>   rZ      s    rZ   c                   G   s    d S ra   r=   rb   r=   r=   r>   r[      s    r[   rW   )funcr8   exc_inforV   r5   c                C   s   zt |j}W n tk
r&   Y dS X |tj@ szt ||tjB  W n tk
r\   Y n&X z| | W dS  tk
r   Y nX t|ts|\}}}|| || dS )a1  
    `rmtree` error handler to 'force' a file remove (i.e. like `rm -f`).

    * If a file is readonly then it's write flag is set and operation is
      retried.

    * `onerror` is the original callback from `rmtree(... onerror=onerror)`
      that is chained at the end if the "rm -f" still fails.
    N)r7   statst_moderF   S_IWRITEchmod
isinstanceBaseException)rc   r8   rd   rV   rf   _r=   r=   r>   r\      s"    


r\   c                 C   sF   t jt j| } | t  t jj rBd| tt  d  } | S )zTGives the display value for a given path, making it relative to cwd
    if possible..N)r7   r8   normcaser<   
startswithgetcwdseprC   r8   r=   r=   r>   r%      s    .bak)rT   extr5   c                 C   s6   d}|}t j| | r.|d7 }|t| }q| | S )z\Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)   )r7   r8   existsstr)rT   rs   n	extensionr=   r=   r>   r&      s    )messageoptionsr5   c                 C   s2   t jdd D ]}||kr|  S qt| |S )NZPIP_EXISTS_ACTION )r7   environgetsplitr'   )ry   rz   actionr=   r=   r>   ask_path_exists   s    
r   )ry   r5   c                 C   s   t jdrtd|  dS )z&Raise an error if no input is allowed.ZPIP_NO_INPUTz5No input was expected ($PIP_NO_INPUT set); question: N)r7   r|   r}   	Exceptionry   r=   r=   r>   _check_no_input   s    r   c                 C   sF   t |  t| }|  }||kr<td|d| q |S q dS )z@Ask the message interactively, with the given possible responsesz>Your response ({!r}) was not one of the expected responses: {}z, N)r   inputstriplowerprintformatr9   )ry   rz   Zresponser=   r=   r>   r'      s     c                 C   s   t |  t| S )zAsk for input interactively.)r   r   r   r=   r=   r>   	ask_input   s    r   c                 C   s   t |  t| S )z!Ask for a password interactively.)r   getpassr   r=   r=   r>   ask_password   s    r   )valr5   c                 C   s2   |   } | dkrdS | dkr dS td| dS )zConvert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    )yyesttrueon1rt   )rw   noffalseoff0r   zinvalid truth value N)r   
ValueError)r   r=   r=   r>   	strtobool   s    r   )bytesr5   c                 C   s`   | dkr| d d ddS | dkr6t | d  dS | dkrN| d ddS t |  dS d S )	Ni@B g     @@i  z.1fz MBi'  z kBz bytes)int)r   r=   r=   r>   r)     s    )rowsr5   c                    s@   dd | D } dd t | ddiD   fdd| D }| fS )zReturn a list of formatted rows and a list of column sizes.

    For example::

    >>> tabulate([['foobar', 2000], [0xdeadbeef]])
    (['foobar     2000', '3735928559'], [10, 4])
    c                 S   s   g | ]}t tt|qS r=   )tuplemaprv   .0rowr=   r=   r>   
<listcomp>  s     ztabulate.<locals>.<listcomp>c                 S   s   g | ]}t tt|qS r=   )maxr   rC   )r   colr=   r=   r>   r      s     	fillvaluer{   c                    s$   g | ]}d  ttj|  qS ) )r9   r   rv   ljustrstripr   sizesr=   r>   r   !  s     )r   )r   tabler=   r   r>   tabulate  s    r   c                 C   sH   t j| sdS t jt j| dr*dS t jt j| drDdS dS )at  Is path is a directory containing pyproject.toml or setup.py?

    If pyproject.toml exists, this is a PEP 517 project. Otherwise we look for
    a legacy setuptools layout by identifying setup.py. We don't check for the
    setup.cfg because using it without setup.py is only available for PEP 517
    projects, which are already covered by the pyproject.toml check.
    Fzpyproject.tomlTzsetup.py)r7   r8   isdirisfiler9   rq   r=   r=   r>   r*   %  s    )filesizer5   c                 c   s   |  |}|sq|V  q dS )z7Yield pieces of data from a file-like object until EOF.N)read)r   r   chunkr=   r=   r>   read_chunks6  s    
r   T)r8   resolve_symlinksr5   c                 C   s6   t j| } |rt j| } nt j| } t j| S )zN
    Convert a path to its canonical, case-normalized, absolute version.

    )r7   r8   
expanduserrealpathr<   rm   )r8   r   r=   r=   r>   r+   A  s
    c                 C   s@   t | \}}| dr8|dd | }|dd }||fS )z,Like os.path.splitext, but take off .tar tooz.tarN)	posixpathr(   r   endswith)r8   basers   r=   r=   r>   r(   N  s
    )oldnewr5   c                 C   sz   t j|\}}|r.|r.t j|s.t | t| | t j| \}}|rv|rvzt | W n tk
rt   Y nX dS )z7Like os.renames(), but handles renaming across devices.N)	r7   r8   r~   ru   rE   r^   move
removedirsrF   )r   r   headtailr=   r=   r>   r,   W  s    
c                 C   s   t  s
dS | ttjS )z
    Return True if path is within sys.prefix, if we're running in a virtualenv.

    If we're not in a virtualenv, all paths are considered "local."

    Caution: this function assumes the head of path has been normalized
    with normalize_path.
    T)r#   rn   r+   rL   prefixrq   r=   r=   r>   is_localh  s    	r   )msgargsr5   c                 G   s   t j| f|  d S ra   )loggerinfo)r   r   r=   r=   r>   write_outputv  s    r   c                   @   s<   e Zd ZU eed< eed dddZeedddZ	dS )	StreamWrapperorig_stream)r   r5   c                 C   s   |  }||_ |S ra   )r   )clsr   retr=   r=   r>   from_stream}  s    zStreamWrapper.from_streamr4   c                 C   s   | j jS ra   )r   encodingselfr=   r=   r>   r     s    zStreamWrapper.encodingN)
__name__
__module____qualname__r   __annotations__classmethodr   propertyrv   r   r=   r=   r=   r>   r   z  s
   
r   )
sequentialnamedr5   c                  O   s@   t t| tt| f|}dd | D }||d< tdd|S )Nc                 S   s   i | ]\}}||qS r=   r=   )r   keyvaluer=   r=   r>   
<dictcomp>  s      zenum.<locals>.<dictcomp>Zreverse_mappingEnumr=   )dictziprangerC   itemstype)r   r   Zenumsreverser=   r=   r>   enum  s    r   )hostportr5   c                 C   s.   |dkr| S d| kr d|  d} |  d| S )z.
    Build a netloc from a host-port pair
    N:[]r=   )r   r   r=   r=   r>   build_netloc  s
    r   https)netlocschemer5   c                 C   s8   |  ddkr*d| kr*d| kr*d|  d} | d|  S )z)
    Build a full URL from a netloc.
    r      @r   r   z://)count)r   r   r=   r=   r>   build_url_from_netloc  s    r   )r   r5   c                 C   s    t | }tj|}|j|jfS )z2
    Return the host-port pair from a netloc.
    )r   urllibparseurlparsehostnamer   )r   urlparsedr=   r=   r>   parse_netloc  s    r   c                 C   st   d| kr| dfS |  dd\}} d}d|kr>|dd\}}n
|d }}tj|}|dk	rhtj|}| ||ffS )zp
    Parse out and remove the auth information from a netloc.

    Returns: (netloc, (username, password)).
    r   )NNrt   Nr   )rsplitr~   r   r   unquote)r   authpwuserr=   r=   r>   split_auth_from_netloc  s    
r   c                 C   sP   t | \} \}}|dkr| S |dkr.d}d}ntj|}d}| | d|  S )z
    Replace the sensitive data in a netloc with "****", if it exists.

    For example:
        - "user:pass@example.com" returns "user:****@example.com"
        - "accesstoken@example.com" returns "****@example.com"
    N****r{   z:****r   )r   r   r   quote)r   r   passwordr=   r=   r>   redact_netloc  s    r   )r   transform_netlocr5   c                 C   sJ   t j| }||j}|j|d |j|j|jf}t j|}|t	d|fS )aR  Transform and replace netloc in a url.

    transform_netloc is a function taking the netloc and returning a
    tuple. The first element of this tuple is the new netloc. The
    entire tuple is returned.

    Returns a tuple containing the transformed url as item 0 and the
    original tuple returned by transform_netloc as item 1.
    r   NetlocTuple)
r   r   urlsplitr   r   r8   queryfragment
urlunsplitr   )r   r  ZpurlZnetloc_tupleZ
url_piecesZsurlr=   r=   r>   _transform_url  s
    
r  c                 C   s   t | S ra   )r   r   r=   r=   r>   _get_netloc  s    r	  c                 C   s
   t | fS ra   )r   r  r=   r=   r>   _redact_netloc  s    r
  )r   r5   c                 C   s   t | t\}\}}|||fS )z
    Parse a url into separate netloc, auth, and url with no auth.

    Returns: (url_without_auth, netloc, (username, password))
    r  r	  )r   Zurl_without_authr   r   r=   r=   r>   split_auth_netloc_from_url  s    r  c                 C   s   t | td S )z7Return a copy of url with 'username:password@' removed.r   r  r   r=   r=   r>   r/   
  s    c                 C   s   t | td S )z.Replace the password in a given url with ****.r   )r  r
  r  r=   r=   r>   redact_auth_from_url  s    r  )reqr5   c                 C   s&   | j st| S t| | j t| j S )z:Replace the password in a given requirement url with ****.)r   rv   replacer  )r  r=   r=   r>   redact_auth_from_requirement  s    r  )frozenc                   @   sJ   e Zd ZU eed< eed< edddZedddZeedd	d
Z	dS )
HiddenTextsecretredactedr4   c                 C   s   dt | dS )Nz<HiddenText >)rv   r   r=   r=   r>   __repr__"  s    zHiddenText.__repr__c                 C   s   | j S ra   r  r   r=   r=   r>   __str__%  s    zHiddenText.__str__)otherr5   c                 C   s    t | t |k	rdS | j|jkS )NF)r   r  )r   r  r=   r=   r>   __eq__)  s    zHiddenText.__eq__N)
r   r   r   rv   r   r  r  r   boolr  r=   r=   r=   r>   r    s
   
r  )r   r5   c                 C   s   t | ddS )Nr   r  )r  )r   r=   r=   r>   
hide_value2  s    r  c                 C   s   t | }t| |dS )Nr  )r  r  )r   r  r=   r=   r>   hide_url6  s    r  )modifying_pipr5   c                 C   s|   ddt jj dt jj dt jj g}| oDtoDtjt jd |k}|rxt j	ddgt jdd  }t
dd|dS )	zProtection of pip.exe from modification on Windows

    On Windows, any operation modifying pip should be run as:
        python -m pip ...
    rJ   rl   r   z-mrt   Nz3To modify pip, please run the following command:
{}r   )rL   r]   majorminorr!   r7   r8   rK   rM   rN   r   r   r9   )r  Z	pip_namesZshould_show_use_python_msgZnew_commandr=   r=   r>   (protect_pip_from_modification_on_windows;  s    r"  c                  C   s<   t  r
dS tjtdd} tj| s.dS t| dS )zCheck whether the current environment is externally managed.

    If the ``EXTERNALLY-MANAGED`` config file is found, the current environment
    is considered externally managed, and an ExternallyManagedEnvironment is
    raised.
    NstdlibzEXTERNALLY-MANAGED)	r#   r7   r8   r9   	sysconfigZget_pathr   r   Zfrom_config)markerr=   r=   r>   r0   U  s    c                   C   s   t jdk	ot j S )zIs this console interactive?N)rL   stdinisattyr=   r=   r=   r>   is_console_interactived  s    r(  )r8   	blocksizer5   c              	   C   sR   t  }d}t| d.}t||dD ]}|t|7 }|| q$W 5 Q R X ||fS )z5Return (hash, length) for path using hashlib.sha256()r   rb)r   )hashlibZsha256openr   rC   update)r8   r)  hlengthr   blockr=   r=   r>   	hash_filei  s    r1  )iterabler5   c                 C   s   t | } t| | S )zb
    Return paired elements.

    For example:
        s -> (s0, s1), (s2, s3), (s4, s5), ...
    )iterr   )r2  r=   r=   r>   pairwiseu  s    r4  )predr2  r5   c                 C   s    t |\}}t| |t| |fS )z
    Use a predicate to partition entries into false entries and true entries,
    like

        partition(is_odd, range(10)) --> 0 2 4 6 8   and  1 3 5 7 9
    )r   r   filter)r5  r2  t1t2r=   r=   r>   	partition  s    	r9  c                       sx  e Zd Zdeeeee eed  ee d fddZdeeeeef  ee ed fddZ	deeeeef  ed	 fd
dZ
deeeeef  ee ed fddZdeeeef  ee d fddZd eeeef  ee d fddZd!eeeef  ee d fddZd"eeeeef  eed fddZd#eeeeef  eee d fddZ  ZS )$r1   N).N)config_holder
source_dirbuild_backendbackend_pathrunnerpython_executablec                    s   t  ||||| || _d S ra   )super__init__r:  )r   r:  r;  r<  r=  r>  r?  	__class__r=   r>   rA    s    	    z)ConfiguredBuildBackendHookCaller.__init__)wheel_directoryconfig_settingsmetadata_directoryr5   c                    s   | j j}t j|||dS N)rE  rF  )r:  rE  r@  build_wheelr   rD  rE  rF  csrB  r=   r>   rH    s      z,ConfiguredBuildBackendHookCaller.build_wheel)sdist_directoryrE  r5   c                    s   | j j}t j||dS N)rE  )r:  rE  r@  build_sdist)r   rK  rE  rJ  rB  r=   r>   rM    s    z,ConfiguredBuildBackendHookCaller.build_sdistc                    s   | j j}t j|||dS rG  )r:  rE  r@  build_editablerI  rB  r=   r>   rN    s      z/ConfiguredBuildBackendHookCaller.build_editable)rE  r5   c                    s   | j j}t j|dS rL  )r:  rE  r@  get_requires_for_build_wheelr   rE  rJ  rB  r=   r>   rO    s    z=ConfiguredBuildBackendHookCaller.get_requires_for_build_wheelc                    s   | j j}t j|dS rL  )r:  rE  r@  get_requires_for_build_sdistrP  rB  r=   r>   rQ    s    z=ConfiguredBuildBackendHookCaller.get_requires_for_build_sdistc                    s   | j j}t j|dS rL  )r:  rE  r@  get_requires_for_build_editablerP  rB  r=   r>   rR    s    z@ConfiguredBuildBackendHookCaller.get_requires_for_build_editableT)rF  rE  _allow_fallbackr5   c                    s   | j j}t j|||dS N)rF  rE  rS  )r:  rE  r@   prepare_metadata_for_build_wheelr   rF  rE  rS  rJ  rB  r=   r>   rU    s    zAConfiguredBuildBackendHookCaller.prepare_metadata_for_build_wheelc                    s   | j j}t j|||dS rT  )r:  rE  r@  #prepare_metadata_for_build_editablerV  rB  r=   r>   rW    s    zDConfiguredBuildBackendHookCaller.prepare_metadata_for_build_editable)NNN)NN)N)NN)N)N)N)NT)NT)r   r   r   r   rv   r   r   rA  r   rH  rM  rN  r   rO  rQ  rR  r  rU  rW  __classcell__r=   r=   rB  r>   r1     s      
        	    c                   C   sN   t  r
dS ttdsdS tjdks,tjdkr0dS t dkr@dS td dS )zOutput a warning for sudo users on Unix.

    In a virtual environment, sudo pip still writes to virtualenv.
    On Windows, users may run pip as Administrator without issues.
    This warning only applies to Unix root users outside of virtualenv.
    Ngetuidwin32cygwinr   ab  Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.)r#   hasattrr7   rL   platformrY  r   warningr=   r=   r=   r>   warn_if_run_as_root  s    
r_  )FN)rr   )T)r   )r3   )rG   r   r+  loggingr7   r   r^   re   rL   r$  urllib.parser   dataclassesr   	functoolsr   ior   	itertoolsr   r   r   pathlibr   typesr	   r
   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z"pip._vendor.packaging.requirementsr   Zpip._vendor.pyproject_hooksr   rJ   r   pip._internal.exceptionsr   r   pip._internal.locationsr    pip._internal.utils.compatr!   Zpip._internal.utils.retryr"   Zpip._internal.utils.virtualenvr#   __all__	getLoggerr   r   r2   rj   ZExcInfor   rB   rv   r  ZOnExcZOnErrZFILE_CHUNK_SIZEr?   rD   r.   r-   r  r$   rZ   r[   r\   r%   r&   r   r   r'   r   r   r   floatr)   r   r*   r   r   r+   r(   r,   r   r   r   r   r   r   r   r   r   r  r	  r
  r  r/   r  r  r  r  r  r"  r0   r(  r1  r4  r9  r1   r_  r=   r=   r=   r>   <module>   s   H
"

     	
)	( 	
 	 
  Z