<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    aV[                 @   s   d Z ddlmZ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	Z	ddl
Z
ddlZddlmZmZ ddlmZ edddd	d
dgZdd Ze ZedZG dd deZedkree   dS )z
The PythonInfo contains information about a concrete instance of a Python interpreter

Note: this file is also used to query target interpreters, so can only use standard library methods
    )absolute_importprint_functionN)OrderedDict
namedtuple)digitsVersionInfomajorminormicroreleaselevelserialc               C   s*   t tdgtjdd tj S )N PATHEXT)	listr   fromkeysosenvirongetlowersplitpathsep r   r   M/opt/alt/python37/lib/python3.7/site-packages/virtualenv/discovery/py_info.py_get_path_extensions   s    r   z\{\w+\}c               @   s  e Zd ZdZdd Zdd Zdd Zedd	 Ze	d
d Z
e	dd Ze	dd Ze	dd Ze	dd ZdejfddZdIddZe	dd Ze	dd Ze	dd Zd d! Zd"d# Zd$d% Ze	d&d' Zed(d) Zd*d+ ZdZdZedJd,d-ZedKd.d/Z d0d1 Z!d2d3 Z"edLd5d6Z#ed7d8 Z$ed9d: Z%ed;d< Z&i Z'dMd=d>Z(d?d@ Z)edAdB Z*dCdD Z+dEdF Z,dGdH Z-dS )N
PythonInfoz-Contains information for a Python interpreterc                s  dd dd }t j _t  _ jdkrNtfddt jD  _ttfddt jD   _t j	d	krzd
nd _
t j _tj _|tt dd  _|tt dd  _|tt dd  _|tt dd  _|tt dd  _|t j _| j _   _ytd d}W n tk
rZ   d}Y nX | _fddt jD  _t   _tt jdd  _dt ! krd _"fddt # D  _$i  _%n:d  _"fddt # D  _$fdd & ' D  _%tt dtt dd }fddd| fgD  _ t( }x@ j$) D ]2}x*t*+|D ]}|,|dd   qZW qJW |,d! fd"d|D  _- jdkrt jj.d#krd$ j-d%<  fd&d j-' D } /d'| _0 /d(| _1tt d)tt d*d  _2d  _3d S )+Nc             S   s   t | tr| dS | S )Nzutf-8)
isinstancebytesdecode)vr   r   r   u"   s    zPythonInfo.__init__.<locals>.uc             S   s   | d krd S t j| S )N)r   pathabspath)r   r   r   r   abs_path%   s    z%PythonInfo.__init__.<locals>.abs_pathPyPyc             3   s   | ]} |V  qd S )Nr   ).0i)r   r   r   	<genexpr>,   s    z&PythonInfo.__init__.<locals>.<genexpr>c             3   s   | ]} |V  qd S )Nr   )r$   r%   )r   r   r   r&   /   s    l        @       prefixbase_prefixreal_prefixbase_exec_prefixexec_prefixvenvTFc                s   g | ]} |qS r   r   )r$   r%   )r   r   r   
<listcomp>H   s    z'PythonInfo.__init__.<locals>.<listcomp>encodingc                s&   i | ]} t j|d dd |qS )Fr.   )expandscheme)	sysconfigget_path)r$   r%   )r   r   r   
<dictcomp>N   s   z'PythonInfo.__init__.<locals>.<dictcomp>c                s$   i | ]} t j|d d |qS )F)r1   )r3   r4   )r$   r%   )r   r   r   r5   U   s    c                s   i | ]\}} | |qS r   r   )r$   kr   )r   r   r   r5   V   s    get_makefile_filenameZ_get_makefile_filenamec                s&   i | ]\}}|d k	r | |qS )Nr   )r$   r6   r   )r   r   r   r5   Z   s   Zmakefile_filename   PYTHONFRAMEWORKc                s$   i | ]} t |pd  |qS )r   )r3   get_config_var)r$   r%   )r   r   r   r5   i   s       pythonZimplementation_lowerc                s(   i | ] \}}|  jr jn||qS r   )
startswithr)   system_prefix)r$   r6   r   )selfr   r   r5   m   s    stdlib
platstdlibmaxsizeZmaxint)4sysplatformpython_implementationimplementationtupleZpypy_version_infor   r   version_inforC   architectureversionr   namegetattrr)   r*   r+   r,   r-   
executableoriginal_executable_fast_get_system_executablesystem_executable
__import__ImportErrorZhas_venvr    getfilesystemencodingfile_system_encodingstdoutstdout_encodingr3   get_scheme_namesZsysconfig_schemeget_path_namessysconfig_pathsdistutils_install_distutils_installitemssetvalues_CONF_VAR_REfindalladdsysconfig_varsr   sysconfig_pathZsystem_stdlibZsystem_stdlib_platformmax_size	_creators)r@   r"   ZhasmakefileZconfig_var_keyselementr6   Zconfsr   )r@   r   r   __init__!   sf    




"

zPythonInfo.__init__c             C   sR   | j s| jdk	rL| j| jkrL| j dkrHttdd}|dk	rHtj|krH|S dS | jS )z>Try to get the system executable by just looking at propertiesN_base_executable)r+   r*   r)   rM   rD   rN   rO   )r@   Zbase_executabler   r   r   rP   s   s    

z&PythonInfo._fast_get_system_executablec                sZ   | j |}|d krV| j| j| j| jf  fdd| j D }| j||d	t
j}|S )Nc                s"   i | ]\}}| krd n||qS )r   r   )r$   r6   r   )prefixesr   r   r5      s    z+PythonInfo.install_path.<locals>.<dictcomp>)
config_var)r[   r   r)   r-   r*   r,   rc   r]   rd   lstripr   sep)r@   keyresultrl   r   )rk   r   install_path   s    zPythonInfo.install_pathc           	      s   t  B t d yddlm}  ddlm} W n tk
rD   i S X W d Q R X | ddi}t	t
drnd t
_t   t d |jdd	d
 W d Q R X tj _    fdd|D }|S )Nignorer   )dist)SCHEME_KEYSscript_argsz--no-user-cfg
_frameworkinstallT)createc                s.   i | ]&}t  d |dd tj|qS )z
install_{}r8   N)rM   formatrm   r   rn   )r$   ro   )r%   r   r   r5      s    z1PythonInfo._distutils_install.<locals>.<dictcomp>)warningscatch_warningssimplefilter	distutilsrs   distutils.command.installrt   rS   DistributionhasattrrD   rv   get_command_objr   rn   r)   finalize_options)rs   rt   drp   r   )r%   r   r\      s"    




zPythonInfo._distutils_installc             C   s   d dd | jdd D S )N.c             s   s   | ]}t |V  qd S )N)str)r$   r%   r   r   r   r&      s    z)PythonInfo.version_str.<locals>.<genexpr>r      )joinrI   )r@   r   r   r   version_str   s    zPythonInfo.version_strc             C   s   d dd | jdd D S )Nr   c             s   s   | ]}t |V  qd S )N)r   )r$   r%   r   r   r   r&      s    z1PythonInfo.version_release_str.<locals>.<genexpr>r   r<   )r   rI   )r@   r   r   r   version_release_str   s    zPythonInfo.version_release_strc             C   s   | j }d|j|jS )Nzpython{}.{})rI   ry   r   r	   )r@   rI   r   r   r   python_name   s    zPythonInfo.python_namec             C   s
   | j d k	S )N)r+   )r@   r   r   r   is_old_virtualenv   s    zPythonInfo.is_old_virtualenvc             C   s   | j d k	o| jjdkS )Nr   )r*   rI   r   )r@   r   r   r   is_venv   s    zPythonInfo.is_venvNc             C   sP   | j | }|d kr| j}n"dd | j D }|| |}|jf |d|S )Nc             S   s   i | ]\}}||qS r   r   )r$   r6   r   r   r   r   r5      s    z-PythonInfo.sysconfig_path.<locals>.<dictcomp>/)rZ   rc   r]   updatery   replace)r@   ro   rl   rn   patternbaser   r   r   rd      s    

zPythonInfo.sysconfig_pathFc             C   s0   | j d ks|dkr*ddlm} || | _ | j S )NTr   )CreatorSelector)rf   Zvirtualenv.run.plugin.creatorsr   Zfor_interpreter)r@   Zrefreshr   r   r   r   creators   s    zPythonInfo.creatorsc                s^     d fdd j D }tj|sZtj jtj 	d}tj|rZ|}|S )Nincludec                s(   i | ] \}}|  jr jn||qS r   )r>   r)   r?   )r$   r6   r   )r@   r   r   r5      s    z-PythonInfo.system_include.<locals>.<dictcomp>headers)
rd   rc   r]   r   r    existsr   r)   dirnamerq   )r@   r    fallbackr   )r@   r   system_include   s    zPythonInfo.system_includec             C   s   | j p| jp| jS )N)r+   r*   r)   )r@   r   r   r   r?      s    zPythonInfo.system_prefixc             C   s   | j p| jp| jS )N)r+   r,   r-   )r@   r   r   r   system_exec_prefix   s    zPythonInfo.system_exec_prefixc             C   s    t | }tjdkr|d}|S )Nr<   zutf-8)reprrD   rI   r   )r@   contentr   r   r   __unicode__   s    

zPythonInfo.__unicode__c             C   s    d | jjdd | j D S )Nz{}({!r})c             S   s    i | ]\}}| d s||qS )_)r>   )r$   r6   r   r   r   r   r5      s    z'PythonInfo.__repr__.<locals>.<dictcomp>)ry   	__class____name____dict__r]   )r@   r   r   r   __repr__   s    zPythonInfo.__repr__c             C   s   d | jjddd d| jf| jd k	r6| j| jkr6dnd | jf| j| jkrZ| j| jkrZdnd | jfd| jfd	| jfd
t	| j
fdd | j| jffD }|S )Nz{}({})z, c             s   s&   | ]\}}|d k	rd ||V  qd S )Nz{}={})ry   )r$   r6   r   r   r   r   r&      s   z%PythonInfo.__str__.<locals>.<genexpr>specsystemoriginalexerE   rK   Zencoding_fs_ioz{}-{})ry   r   r   r   r   rQ   rN   rO   rE   r   rK   rU   rW   )r@   r   r   r   r   __str__   s"    zPythonInfo.__str__c             C   s$   d | jddd | jD | jS )Nz{}{}-{}r   c             s   s   | ]}t |V  qd S )N)r   )r$   r%   r   r   r   r&     s    z"PythonInfo.spec.<locals>.<genexpr>)ry   rG   r   rI   rJ   )r@   r   r   r   r     s    zPythonInfo.specc             C   s"   ddl m} || | j  d S )Nr   )clear)#virtualenv.discovery.cached_py_infor   _cache_exe_discovery)clsapp_datar   r   r   r   clear_cache  s    zPythonInfo.clear_cachec             C   s  |j rz| jtj |j krdS |jsztj | j}|j }tjdkrntj 	|\}}|
|rn|dt|  }||krzdS |r|jdk	r|j | j krdS |jdk	r|j| jkrdS xHt| jdd |j|j|jfD ]$\}}|dk	r|dk	r||krdS qW dS )zWcheck if a given specification can be satisfied by the this python interpreter instanceTwin32NFr   r   )r    rN   r   r!   Zis_absbasenamerO   rD   rE   splitextendswithlenrG   r   rJ   ziprI   r   r	   r
   )r@   r   Zimpl_must_matchr   Z	spec_pathsuffixZourreqr   r   r   	satisfies  s*    

*zPythonInfo.satisfiesc             C   s&   | j dkr | jtj|ddd| _ | j S )z
        This locates the current host interpreter information. This might be different than what we run into in case
        the host python has been upgraded from underneath us.
        NTF)raise_on_errorresolve_to_host)_currentfrom_exerD   rN   )r   r   r   r   r   current7  s    
zPythonInfo.currentc             C   s&   | j dkr | jtj|ddd| _ | j S )z
        This locates the current host interpreter information. This might be different than what we run into in case
        the host python has been upgraded from underneath us.
        NT)r   r   )_current_systemr   rD   rN   )r   r   r   r   r   current_systemA  s    
zPythonInfo.current_systemc             C   s   t j|  ddS )Nr<   )indent)jsondumps_to_dict)r@   r   r   r   _to_jsonK  s    zPythonInfo._to_jsonc                s*    fddt  D }|d  |d< |S )Nc                s$   i | ]}|d krt  |nd|qS ))rf   N)rM   )r$   var)r@   r   r   r5   P  s    z'PythonInfo._to_dict.<locals>.<dictcomp>rI   )vars_asdict)r@   datar   )r@   r   r   O  s    zPythonInfo._to_dictTc       
   
   C   s   ddl m} |dkrtjn|}|| |||||d}t|tr|ry|||}W n> tk
r }	 z |rj|	t	d|j
|	 d}W dd}	~	X Y nX |S )z8Given a path to an executable get the python informationr   )r   N)envr   ignore_cachez-ignore %s due cannot resolve system due to %r)r   r   r   r   r   r   _resolve_to_system	ExceptionlogginginforO   )
r   r   r   r   r   r   r   r   Zproposed	exceptionr   r   r   r   U  s    zPythonInfo.from_exec             C   s"   t |}| dd | D S )Nc             S   s   i | ]\}}||qS r   r   )r$   r6   r   r   r   r   r5   l  s    z)PythonInfo._from_json.<locals>.<dictcomp>)r   loads
_from_dictr]   )r   payloadrawr   r   r   
_from_jsonh  s    
zPythonInfo._from_jsonc             C   s0   t f |d |d< |  }dd | D |_|S )NrI   c             S   s   i | ]\}}||qS r   r   )r$   r6   r   r   r   r   r5   r  s    z)PythonInfo._from_dict.<locals>.<dictcomp>)r   r]   r   )r   r   rp   r   r   r   r   n  s    zPythonInfo._from_dictc       	      C   s   |j }t }x|jd kr|jp(|jp(|j}||krt|dkrTtd| |j |_P x0t	|
 ddD ]\}\}}td||| qfW tdt|d || tdd| |||< |j||dd}qW |j |jkr| |j|}||_ |S )	Nr8   z$%r links back to itself via prefixes)startz%d: prefix=%s, info=%rz prefixes are causing a circle {}|F)r)   exact)rN   r   rQ   r+   r*   r)   r   r   r   	enumerater]   errorRuntimeErrorry   r   keysdiscover_exer   )	r   r   targetZstart_executablerk   r)   atptr   r   r   r   u  s&    zPythonInfo._resolve_to_systemc          
   C   s  ||f}|| j kr6|r6td||| j |  | j | S td| | |  }| |}g }|d krhtjn|}xD|D ]<}	x6|D ].}
| ||	|
|||}|d k	r||| j |< |S q|W qrW |dkr|r| || }tj	
|}|| j |< td|| |S dd
|tj	
|}t|d S )Nz)discover exe from cache %s - exact %s: %rzdiscover exe for %s in %sFzFno exact match found, chosen most similar of %s within base folders %szfailed to detect {} in {}r   )r   r   debug_find_possible_exe_names_find_possible_foldersr   r   
_check_exe_select_most_likelyr   r   ry   r   )r@   r   r)   r   r   ro   Zpossible_namesZpossible_folders
discoveredfolderrL   r   Zfoldersmsgr   r   r   r     s.    





zPythonInfo.discover_exec             C   s   t j||}t j|sd S | j||dd|d}|d kr>d S xdD ]~}	t||	}
t| |	}|
|krD|	dkrddd |
D ddd |D  }
}|j}td||	|
| |dkr|	| P qDW |S d S )	NF)r   r   r   )rG   rJ   rI   rI   r   c             s   s   | ]}t |V  qd S )N)r   )r$   r%   r   r   r   r&     s    z(PythonInfo._check_exe.<locals>.<genexpr>z2refused interpreter %s because %s differs %s != %s)
r   r    r   r   r   rM   rN   r   r   append)r@   r   r   rL   r   r   r   Zexe_pathr   itemfoundZsearchedrN   r   r   r   r     s&    


*
zPythonInfo._check_exec                s&    fdd}t | |dd}|d }|S )Nc                s|   | j  j k| jj jjk| jj jjk| j jk| jj jjk| jj jjk| jj jjkg}tdd t	t
|D }|S )Nc             s   s"   | ]\}}|rd |> ndV  qdS )r8   r   Nr   )r$   posmatchr   r   r   r&     s    zBPythonInfo._select_most_likely.<locals>.sort_by.<locals>.<genexpr>)rG   rI   r   r	   rJ   r
   r   r   sumr   reversed)r   matchespriority)r   r   r   sort_by  s    

z/PythonInfo._select_most_likely.<locals>.sort_byT)ro   reverser   )sorted)r   r   r   Zsorted_discoveredZmost_likelyr   )r   r   r     s    zPythonInfo._select_most_likelyc             C   s   t  }t  }d |tj| j< d || j< d |tj| j< d || j< xJ| D ]>}tj|}|| j	rN|t
| j	d  }d |d||< qNW d ||< tdd | D S )Nz{}{}c             s   s   | ]}t j|r|V  qd S )N)r   r    r   )r$   r%   r   r   r   r&     s    z4PythonInfo._find_possible_folders.<locals>.<genexpr>)r   r   r    realpathrN   rO   r   r   r>   r)   r   ry   r   )r@   Zinside_folderZcandidate_folderexecutablesr   r   Zrelativer   r   r   r     s    

z!PythonInfo._find_possible_foldersc          
   C   s   t  }x||  D ]p}xjdD ]b}ddd | jd | D }x>d| jdgD ]*}x$tD ]}d||||}d ||< qXW qNW qW qW t| S )N)r   r<   r8   r   r   c             s   s   | ]}t |V  qd S )N)r   )r$   r%   r   r   r   r&     s    z6PythonInfo._find_possible_exe_names.<locals>.<genexpr>z-{}r   z{}{}{}{})	r   _possible_baser   rI   ry   rJ   
EXTENSIONSr   r   )r@   Zname_candidaterL   r   rK   archext	candidater   r   r   r     s    

z#PythonInfo._find_possible_exe_namesc             c   s   t  }tjtj| jd t}d ||< d || j< d|krF|d= d |d< xP|D ]H}|	 }|V  ddl
m} | rT||kr|V  | }||krT|V  qTW d S )Nr   r=   )fs_is_case_sensitive)r   r   r    r   r   rN   rstripr   rG   r   Zvirtualenv.infor   upper)r@   Zpossible_baser   r   r   r   r   r   r   r   r     s"     

zPythonInfo._possible_base)F)N)N)NTFTN)TN).r   
__module____qualname____doc__ri   rP   rq   staticmethodr\   propertyr   r   r   r   r   r   rn   rd   r   r   r?   r   r   r   r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      sR   R	

 		
r   __main__)r   
__future__r   r   r   r   r   rE   rerD   r3   rz   collectionsr   r   stringr   r   r   r   compiler`   objectr   r   printr   r   r   r   r   <module>   s*   
   m