a
    e0h                      @   s^  d dl m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 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 d dlmZ erd dlmZ d dlmZ d dlm Z m!Z!m"Z" d dl#m$Z$ e%e&Z'dd Z(dd Z)dd Z*dd Z+dd Z,dd Z-dd Z.dd  Z/d!d" Z0d#d$ Z1d%d& Z2G d'd( d(eZ3dS ))    )absolute_importN)pkg_resources)where)__file__)
cmdoptions)Command)make_target_python)SUCCESS)
indent_log)get_pip_version)MYPY_CHECK_RUNNING)Values)
ModuleType)DictListOptional)Configurationc                 C   s   t d| | d S )Nz%s: %s)loggerinfo)namevalue r   J/var/www/auris/lib/python3.9/site-packages/pip/_internal/commands/debug.py
show_value   s    r   c                  C   sZ   t d ttdr"tj} | j}nd}t  td| W d    n1 sL0    Y  d S )Nzsys.implementation:implementation r   )r   r   hasattrsysr   r   r
   r   )r   implementation_namer   r   r   show_sys_implementation$   s    

r   c                  C   sd   t jt jtdd} t| "}dd | D }W d    n1 sH0    Y  tdd |D S )N_vendorz
vendor.txtc                 S   s(   g | ] }d |v r|  ddd qS )==    r   )stripsplit.0liner   r   r   
<listcomp><   s   
z)create_vendor_txt_map.<locals>.<listcomp>c                 s   s   | ]}| d dV  qdS )r!   r#   Nr%   r&   r   r   r   	<genexpr>@       z(create_vendor_txt_map.<locals>.<genexpr>)ospathjoindirnamepip_locationopen	readlinesdict)Zvendor_txt_pathflinesr   r   r   create_vendor_txt_map1   s    

$r7   c                  C   s*   dd t tjjD } tdd | D S )Nc                 S   s   g | ]}|qS r   r   )r'   fnr   r   r   r)   D   r,   z+create_debundle_txt_map.<locals>.<listcomp>c                 s   s*   | ]"}| d d | d d fV  qdS )-r   r#   Nr*   )r'   wheelr   r   r   r+   F   r,   z*create_debundle_txt_map.<locals>.<genexpr>)r-   listdirpipr    	WHEEL_DIRr4   )wheelsr   r   r   create_debundle_txt_mapB   s    r?   c                 C   s:   |   } | dkrd} td| t t dd ttj| S )N
setuptoolsr   zpip._vendor.{}r   )level)lower
__import__formatglobalslocalsgetattrr<   r    )module_namer   r   r   get_module_from_module_nameH   s    rI   c                 C   sP   t | }t|dd }|sLttj|jg}|tj	
| }t|dd }|S )N__version__version)rI   rG   r   
WorkingSetr-   r.   r0   r   findRequirementparse)rH   modulerK   Zpkg_setpackager   r   r   get_vendor_version_from_moduleY   s    rR   c                 C   sR   |   D ]D\}}d}t|}|s*d}|}n||kr<d|}td||| qdS )z{Log the actual version and print extra info if there is
    a conflict or if the actual version could not be imported.
    r   zM (Unable to locate actual module version, using vendor.txt specified version)z5 (CONFLICT: vendor.txt suggests version should be {})z%s==%s%sN)itemsrR   rD   r   r   )vendor_txt_versionsrH   Zexpected_versionZextra_messageZactual_versionr   r   r   show_actual_vendor_versionsm   s    rU   c                  C   sB   t d t } t  t|  W d    n1 s40    Y  d S )Nzvendored library versions:)r   r   r7   r
   rU   )rT   r   r   r   show_vendor_versions   s    
rV   c               	   C   sd   t d t } t|  D ]B\}}t $ t dj||d W d    q1 sT0    Y  qd S )Nzdebundled wheel versions:z{name}=={actual})r   actual)r   r   r?   sortedrS   r
   rD   )Zdebundle_txt_versionsrH   installed_versionr   r   r   show_debundled_versions   s    
rZ   c           	      C   s   d}t | }| }| }d}|r.d|}dt||}t| | jdk rpt||krpd}|d | }nd}t B |D ]}tt	| q|rdj|d	}t| W d    n1 s0    Y  d S )
N
   r   z (target: {})zCompatible tags: {}{}r#   TFz?...
[First {tag_limit} tags shown. Pass --verbose to show all.])	tag_limit)
r   get_tagsformat_givenrD   lenr   r   verboser
   str)	optionsr\   target_pythontagsZformatted_targetsuffixmsgZtags_limitedtagr   r   r   	show_tags   s,    

rh   c                    sr   t  }|  D ]\}}||dd  q|s4dS g d  fdd|D }|sVdS d|v rh|d d|S )	N.r   zNot specified)installr:   downloadc                    s   g | ]}| v r|qS r   r   )r'   rA   Zlevels_that_override_globalr   r   r)      s   z"ca_bundle_info.<locals>.<listcomp>globalz, )setrS   addr%   remover/   )configlevelskey_Zglobal_overriding_levelr   rl   r   ca_bundle_info   s    

ru   c                   @   s(   e Zd ZdZdZdZdd Zdd ZdS )	DebugCommandz$
    Display debug information.
    z
      %prog <options>Tc                 C   s,   t | j | jd| j | jj  d S )Nr   )r   add_target_python_optionscmd_optsparserinsert_option_grouprq   load)selfr   r   r   add_options   s    zDebugCommand.add_optionsc                 C   s   t d tdt  tdtj tdtj tdt  tdt  tdt	
  tdtj t  td	t| jj td
tjd
 tdtjd tdt  tdtjj tjjst  ntdtjj t  t| tS )NzThis command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.zpip versionzsys.versionzsys.executablezsys.getdefaultencodingzsys.getfilesystemencodingzlocale.getpreferredencodingzsys.platformz'cert' config valueREQUESTS_CA_BUNDLECURL_CA_BUNDLEzpip._vendor.certifi.where()zpip._vendor.DEBUNDLEDzpip._vendor.WHEEL_DIR)r   warningr   r   r   rK   
executablegetdefaultencodinggetfilesystemencodinglocalegetpreferredencodingplatformr   ru   ry   rq   r-   environgetr   r<   r    	DEBUNDLEDrV   r=   rZ   rh   r	   )r|   rb   argsr   r   r   run   s0    zDebugCommand.runN)__name__
__module____qualname____doc__usageignore_require_venvr}   r   r   r   r   r   rv      s
   rv   )4
__future__r   r   loggingr-   r   pip._vendorr<   r   Zpip._vendor.certifir   r   r1   Zpip._internal.clir   pip._internal.cli.base_commandr   Zpip._internal.cli.cmdoptionsr   pip._internal.cli.status_codesr	   pip._internal.utils.loggingr
   pip._internal.utils.miscr   pip._internal.utils.typingr   optparser   typesr   typingr   r   r   pip._internal.configurationr   	getLoggerr   r   r   r   r7   r?   rI   rR   rU   rV   rZ   rh   ru   rv   r   r   r   r   <module>   sB   
"