HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/virtualenv/discovery/__pycache__/py_info.cpython-310.pyc
o

3�h�p�
@sfdZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZedgd��Ze�e�Zdd	�Ze�Ze�d
�ZGdd�d�Zed
kr�e	jdd�Zee�dkruedZedd�ZndZee�dkr�edZedd�ZndZe	jdd�ee	_e���Ze	j �!d�"eddd�eeddd�f��dSdS)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
�)�annotationsN)�OrderedDict�
namedtuple)�digits�VersionInfo)�major�minor�micro�releaselevel�serialcCs*tt�dgtj�dd����tj����S)N��PATHEXT)	�listr�fromkeys�os�environ�get�lower�split�pathsep�rr�G/usr/local/lib/python3.10/dist-packages/virtualenv/discovery/py_info.py�_get_path_extensionss*rz\{\w+\}c@s�eZdZdZdLdd�Zedd��Zdd	�Zd
d�Zdd
�Z	edd��Z
edd��Zedd��Z
edd��Zedd��Zedd��Zdejfdd�Zedd��Zedd ��Zed!d"��ZdMd$d%�ZdMd&d'�Zed(d)��ZedNd*d+��Zd,d-�ZdZdZedOd.d/��ZedOdPd0d1��Z d2d3�Z!d4d5�Z"e		6	7	6		dQd8d9��Z#ed:d;��Z$ed<d=��Z%edNd>d?��Z&iZ'dRd@dA�Z(dBdC�Z)edDdE��Z*dFdG�Z+dHdI�Z,dJdK�Z-dS)S�
PythonInfoz.Contains information for a Python interpreter.�return�Nonecs�dd�}tj�_t���_�jdkrttj��_ttj��_t�	d�dkr'dnd�_
t�d��_
tj�_tj�_t�d	�d
k�_|ttdd���_|ttdd���_|ttd
d���_|ttdd���_|ttdd���_|tj��_|�j��_����_ztd�d}Wnty�d}Ynw|�_tj�_t� ��_!ttj"dd��_#t�$�}d|vr�d�_%�fdd�t�&�D��_'i�_(n4tjdd�dkr�d|vr�d�_%�fdd�t�&�D��_'i�_(nd�_%dd�t�&�D��_'��)��*��_(ttdttdd��}dd�d|�ffD��_t+�}�j'�,�D]}|�-d d!�t.�/|�D���q|�0d"�d#d�|D��_1d$tj2v�r@��3�\�_4�_5nd%\�_4�_5�fd&d��j1�6�D�}��7d'|��_8��7d(|��_9ttd)ttd*d���_:dS)+NcSs|durdStj�|�S�N)r�path�abspath)�vrrr�abs_path%sz%PythonInfo.__init__.<locals>.abs_path�PyPy�P�� �@�py_version_nodot�Py_GIL_DISABLED��prefix�base_prefix�real_prefix�base_exec_prefix�exec_prefix�venvTF�encodingc� i|]}|tj|d�jd��qS�F)�expand�scheme��	sysconfig�get_path�sysconfig_scheme��.0�i��selfrr�
<dictcomp>X��z'PythonInfo.__init__.<locals>.<dictcomp>�)��
�
deb_system�posix_prefixcr0r1r4r8r;rrr=br>cSsi|]
}|tj|dd��qS)F)r2)r5r6r8rrrr=i��get_makefile_filename�_get_makefile_filenamecSsi|]\}}|dur||�qSrr�r9�krrrrr=ns
��makefile_filenamecss�|]	}|dd�VqdS)r(���Nr)r9rHrrr�	<genexpr>ys�z&PythonInfo.__init__.<locals>.<genexpr>�PYTHONFRAMEWORKcSsi|]
}|t�|p
d��qS�r)r5�get_config_varr8rrrr=|rD�TCL_LIBRARY�NNc�0i|]\}}||dur|��j�r�jn|�qSr��
startswithr)�
system_prefixrGr;rrr=�����stdlib�
platstdlib�maxsize�maxint);�sys�platform�python_implementation�implementation�tuple�pypy_version_infor�version_info�struct�calcsize�architecturer5rN�
version_nodot�versionr�name�
free_threaded�getattrr)r*r+r,r-�
executable�original_executable�_fast_get_system_executable�system_executable�
__import__�ImportError�has_venvr�getfilesystemencoding�file_system_encoding�stdout�stdout_encoding�get_scheme_namesr7�get_path_names�sysconfig_paths�distutils_install�_distutils_install�copy�set�values�update�_CONF_VAR_RE�findall�add�sysconfig_varsr�_get_tcl_tk_libs�tcl_lib�tk_lib�items�sysconfig_path�
system_stdlib�system_stdlib_platform�max_size)r<r �has�scheme_names�makefile�config_var_keys�element�confsrr;r�__init__$s�


�

�
���	

�zPythonInfo.__init__c	CsHd\}}zddl}WntyY||fSwz|��}|�d�}z|�d�}|r0tj�|�r0nd}Wn|jy?d}Ynw|dur�|�d�}tj�|�}|d�	|�
d�dd��|�
d�dg}|D]'}tj�	|d	|���}tj�|�sxqetj�tj�	|d
��r�|}nqeW||fSW||fSW||fS|jy�Y||fSw)z�
        Detects the tcl and tk libraries using tkinter.

        This works reliably but spins up tkinter, which is heavy if you don't need it.
        rPrNzinfo libraryzset tk_libraryzpackage require Tk�.r?�tkztk.tcl)�tkinterrn�Tcl�evalrr�isdir�TclError�dirname�joinr�exists)	r�r�r��tcl�
tk_version�
tcl_parent�version_variantsre�tk_lib_pathrrrr��sX(�

��
�������zPythonInfo._get_tcl_tk_libscCsp|js|jdur|j|jks|jS|jdurdSttdd�}|dur$dStj|kr+dStj�	|�r3|S|�
|�S)z?Try to get the system executable by just looking at properties.N�_base_executable)r+r*r)rjrhrZrirrr��_try_posix_fallback_executable)r<�base_executablerrrrk�s


z&PythonInfo._fast_get_system_executablec	Cs�|jj|jj}}|jdks||fdkrdStj�|�}d|��d|�d|��g}|jdkr@|�ddd|��d|�d|��g�|D]}tj�||�}tj�	|�rU|SqBdS)	a3
        Try to find a versioned Python binary as fallback for POSIX virtual environments.

        Python may return "python" because it was invoked from the POSIX virtual environment
        however some installs/distributions do not provide a version-less "python" binary in
        the system install location (see PEP 394) so try to fallback to a versioned binary.

        Gate this to Python 3.11 as `sys._base_executable` path resolution is now relative to
        the 'home' key from pyvenv.cfg which often points to the system install location.
        �posix)r@�N�pythonr�r!�pypy�pypy3)
r`rrrrr�r]�extendr�r�)r<r�rr�base_dir�
candidates�	candidate�	full_pathrrrr��s
$�z)PythonInfo._try_posix_fallback_executablecsZ|j�|�}|dur+|j|j|j|jf��fdd�|j��D�}|j||d��	t
j�}|S)Ncs"i|]
\}}||�vr
dn|�qSrMrrG��prefixesrrr=�s"z+PythonInfo.install_path.<locals>.<dictcomp>)�
config_var)rwrr)r-r*r,r�r�r��lstripr�sep)r<�key�resultr�rr�r�install_path�szPythonInfo.install_pathc	s�t���.t�d�zddlm}ddlm}Wnty*iYWd�SwWd�n1s5wY|�ddi�}t	t
d�rIdt
_t���t�d�|jdd	d
��Wd�n1sdwYt
j�_����fdd�|D�S)
N�ignorer)�dist)�SCHEME_KEYS�script_argsz
--no-user-cfg�
_framework�installT)�createcs.i|]}|t�d|���dd��tj��qS)�install_r(N)rhr�rr�)r9r��r:rrr=s.z1PythonInfo._distutils_install.<locals>.<dictcomp>)�warnings�catch_warnings�simplefilter�	distutilsr��distutils.command.installr�rn�Distribution�hasattrrZr��get_command_objrr�r)�finalize_options)r�r��drr�rrx�s*

���


�zPythonInfo._distutils_installcC�d�dd�|jdd�D��S)Nr�cs��|]}t|�VqdSr��strr8rrrrK��z)PythonInfo.version_str.<locals>.<genexpr>rr@�r�r`r;rrr�version_str�zPythonInfo.version_strcCr�)Nr�csr�rr�r8rrrrKr�z1PythonInfo.version_release_str.<locals>.<genexpr>rr?r�r;rrr�version_release_strr�zPythonInfo.version_release_strcCs|j}d|j�d|j��S)Nr�r�)r`rr)r<r`rrr�python_name szPythonInfo.python_namecC�
|jduSr)r+r;rrr�is_old_virtualenv%�
zPythonInfo.is_old_virtualenvcCr�r)r*r;rrr�is_venv)r�zPythonInfo.is_venvNcCsX|j�|�}|durdS|dur|j}n|j��}|�|�|}|jdi|���d|�S)Nr�/r)rvrr�ryr|�format�replace)r<r�r�r��pattern�baserrrr�-s

zPythonInfo.sysconfig_pathcs^��d�fdd��j��D��}tj�|�s-tj��jtj���	d���}tj�|�r-|}|S)N�includecrQrrRrGr;rrr==rUz-PythonInfo.system_include.<locals>.<dictcomp>�headers)
r�r�r�rrr�r�r)r�r�)r<r�fallbackrr;r�system_include9s
��zPythonInfo.system_includecC�|jp|jp|jSr)r+r*r)r;rrrrTI�zPythonInfo.system_prefixcCr�r)r+r,r-r;rrr�system_exec_prefixMr�zPythonInfo.system_exec_prefixr�cCs d�|jjdd�|j��D��S)Nz{}({!r})cSs i|]\}}|�d�s||�qS)�_)rSrGrrrr=Ts z'PythonInfo.__repr__.<locals>.<dictcomp>)r��	__class__�__name__�__dict__r�r;rrr�__repr__Qs�zPythonInfo.__repr__cCs�d�|jjd�dd�d|jf|jdur|j|jkrdnd|jf|j|j|jhvr*dnd|jfd|jfd	|jfd
t	|j
�fd|j�d|j��ffD���S)
Nz{}({})z, css*�|]\}}|dur|�d|��VqdS)N�=rrGrrrrKZs���z%PythonInfo.__str__.<locals>.<genexpr>�spec�system�original�exer[re�encoding_fs_io�-)
r�r�r�r�r�rlrirjr[�reprrerqrsr;rrr�__str__Ws*
�������zPythonInfo.__str__cCs6d�|jd�dd�|jD��|jrd|j�Sd|j�S)Nz	{}{}{}-{}r�csr�rr�r8rrrrKwr�z"PythonInfo.spec.<locals>.<genexpr>�tr)r�r]r�r`rgrcr;rrrr�ss��zPythonInfo.speccCs$ddlm}|||�|j��dS)Nr)�clear)�#virtualenv.discovery.cached_py_infor��_cache_exe_discovery)�cls�app_data�cacher�rrr�clear_cache|s
zPythonInfo.clear_cachecCs |jr=|jtj�|j�krdS|js=tj�|j�}|j}tjdkr7tj�	|�\}}|�
|�r7|dt|��}||kr=dS|rP|jdurP|j�
�|j�
�krPdS|jdur]|j|jkr]dS|jdurj|j|jkrjdSt|jdd�|j|j|jf�D]\}}|dur�|dur�||kr�dSqzdS)zXCheck if a given specification can be satisfied by the this python interpreter instance.T�win32NFrr@)rrirr�is_abs�basenamerjrZr[�splitext�endswith�lenr]rrcrg�zipr`rrr	)r<r��impl_must_matchr��	spec_path�suffix�our�reqrrr�	satisfies�s4

�
(�zPythonInfo.satisfiescCs(|jdur|jtj|dd|d�|_|jS)��
        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_hostr�)�_current�from_exerZri�r�r�r�rrr�current��
�zPythonInfo.currentcCs(|jdur|jtj|dd|d�|_|jS)rNTr)�_current_systemr	rZrir
rrr�current_system�rzPythonInfo.current_systemcCstj|��dd�S)Nr?)�indent)�json�dumps�_to_dictr;rrr�_to_json�r�zPythonInfo._to_jsoncs*�fdd�t��D�}|d��|d<|S)Ncsi|]}|t�|��qSr)rh)r9�varr;rrr=�sz'PythonInfo._to_dict.<locals>.<dictcomp>r`)�vars�_asdict)r<�datarr;rr�szPythonInfo._to_dictTFc
Cs�ddlm}|dur
tjn|}||||||||d�}	t|	t�rM|rMz|	j||	|d�}	W|	StyL}
z|r7�t�	d|	j
|
�d}	WYd}
~
|	Sd}
~
ww|	S)z9Given a path to an executable get the python information.r)r	N)�envr�ignore_cacher��r�z-ignore %s due cannot resolve system due to %r)r�r	rr�
isinstancer�_resolve_to_system�	Exception�LOGGER�inforj)r�r�r�rrrrr��from_exe_cache�proposed�	exceptionrrrr	�s0
�
���zPythonInfo.from_execCst�|�}|�|���Sr)r�loads�
_from_dictry)r��payload�rawrrr�
_from_json�s
zPythonInfo._from_jsoncCs*tdi|d��|d<|�}|��|_|S)Nr`r)rryr�)r�rr�rrrr$�s
zPythonInfo._from_dictcCs|j}t�}|jdurl|jp|jp|j}||vrZt|�dkr)t�d|�|j|_nCt	|�
�dd�D]\}\}}	t�d|||	�q1t�dt|�d||�d�d�
|����}
t|
��|||<|j||d|d�}|jdus|j|jkr{|j|j||d	�}||_|S)
Nr(z$%r links back to itself via prefixes)�startz%d: prefix=%s, info=%rz prefixes are causing a circle {}�|F)r)�exactr�r)rirrlr+r*r)r�rr�	enumerater��errorr�r��keys�RuntimeError�discover_exer	)r�r��targetr��start_executabler�r)�at�pr��msgrrrrs*

�zPythonInfo._resolve_to_systemcCs||f}||jvr|rt�d|||j|�|j|St�d||�|��}|�|�}g}	|dur4tjn|}|D]!}
|D]}|�||
|||	||�}|durX||j|<|Sq<q8|durz|	rz|�|	|�}tj	�
|�}
||j|<t�d||
�|Sd�d�
|�tj	�
|��}t|��)Nz)discover exe from cache %s - exact %s: %rzdiscover exe for %s in %sFzFno exact match found, chosen most similar of %s within base folders %szfailed to detect {} in {}r))
r�r�debug�_find_possible_exe_names�_find_possible_foldersrr�
_check_exe�_select_most_likelyrr�r�r.)r<r�r)r*rr�r��possible_names�possible_folders�
discovered�folderrfr�foldersr4rrrr/s2


��
zPythonInfo.discover_execCs�tj�||�}tj�|�sdS|j||dd||d�}	|	dur dSdD]A}
t|	|
�}t||
�}||krc|
dkrKd�dd�|D��d�dd�|D��}}|	j}
t�d|
|
||�|dur`|�	|	�dSq"|	S)	NF)rrrr�)r]rcr`r`r�csr�rr�r8rrrrKJr�z(PythonInfo._check_exe.<locals>.<genexpr>z2refused interpreter %s because %s differs %s != %s)
rrr�r�r	rhrirr5�append)r<r�r=rfr*r<rr��exe_pathr�item�found�searchedrirrrr87s6�

*
�	zPythonInfo._check_execs"�fdd�}t||dd�}|dS)Ncsx|j�jk|jj�jjk|jj�jjk|j�jk|jj�jjk|jj�jjk|jj�jjkg}tdd�t	t
|��D��S)Ncss$�|]
\}}|rd|>ndVqdS)r(rNr)r9�pos�matchrrrrKds�"zBPythonInfo._select_most_likely.<locals>.sort_by.<locals>.<genexpr>)r]r`rrrcr	r
r�sumr+�reversed)r�matches�r0rr�sort_byXs

�	z/PythonInfo._select_most_likely.<locals>.sort_byT)r��reverser)�sorted)r<r0rJ�sorted_discoveredrrIrr9TszPythonInfo._select_most_likelycCs�t�}t�}d|tj�|j�<d||j<d|tj�|j�<d||j<|D]}tj�|�}|�|j�rC|t	|j�d�}d||�|��<q$d||<dd�|D�S)NcSsg|]
}tj�|�r|�qSr)rrr�r8rrr�
<listcomp>yrDz5PythonInfo._find_possible_folders.<locals>.<listcomp>)
rrr�realpathrirjr�rSr)r�)r<�
inside_folder�candidate_folder�executablesr�r��relativerrrr7is

�z!PythonInfo._find_possible_foldersc

Cs�t�}|��D]F}dD]A}d�dd�|jd|�D��}dg}|jr'|�d�|D]"}d|j��dfD]}tD]}|�|�|�|�|��}	d||	<q7q3q)qqt|�	��S)N)r@r?r(rr�csr�rr�r8rrrrKr�z6PythonInfo._find_possible_exe_names.<locals>.<genexpr>rr�r�)
r�_possible_baser�r`rgr?rc�
EXTENSIONSrr-)
r<�name_candidaterfr2re�mods�mod�arch�extr�rrrr6{s"

����
z#PythonInfo._find_possible_exe_namesccs��t�}tj�tj�|j��d�t�}d||<d||j<d|vr$|d=d|d<|D]$}|�	�}|Vddl
m}|�rN||krC|V|��}||krN|Vq*dS)Nrr�r()�fs_is_case_sensitive)
rrrr�r�ri�rstriprr]rrr[�upper)r<�
possible_baser�r�rr[r]rrrrT�s(� 
��zPythonInfo._possible_base)rr)rr�rrP)rr)NTFTNN)TNN).r��
__module__�__qualname__�__doc__r��staticmethodr�rkr�r�rx�propertyr�r�r�r�r�rr�r�r�rTr�r�r�r��classmethodr�rr
rrrrrr	r'r$rr�r/r8r9r7r6rTrrrrr!s�
g
4	











"�#



r�__main__r(rrJ)#ra�
__future__rr�loggingrr[�rerarZr5r��collectionsrr�stringrr�	getLoggerr�rrrU�compiler}r�argvr��start_cookie�
end_cookierrrr�writer�rrrr�<module>sL


0�