
    wiir              
         d Z 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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g d          Z ej        e          Zd Z e            Z ej        d	          Z G d
 d          Zedk    re	j        dd         Z ee          dk    red         Zedd         ZndZ ee          dk    red         Zedd         ZndZe	j        dd         ez   e	_         e                                            Ze	j         !                    d"                    eddd         eeddd         f                     dS 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
    )annotationsN)OrderedDict
namedtuple)digitsVersionInfo)majorminormicroreleaselevelserialc            	         t          t          j        dgt          j                            dd                                                              t          j                                      S )N PATHEXT)	listr   fromkeysosenvirongetlowersplitpathsep     l/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/virtualenv/discovery/py_info.py_get_path_extensionsr      sQ    $b%c2:>>)R+H+H+N+N+P+P+V+VWYWa+b+b%cddeeer   z\{\w+}c                  L   e Zd ZdZd+dZed             Zd Zd Zd Z	ed	             Z
ed
             Zed             Zed             Zed             Zed             Zdej        fdZd,dZed             Zed             Zed             Zd-dZd-dZed             Zed             Zd ZdZdZed.d            Z ed.d/d            Z!d Z"d Z#e	 	 	 	 	 d0d!            Z$ed"             Z%ed#             Z&ed$             Z'i Z(d1d%Z)d& Z*ed'             Z+d( Z,d) Z-d* Z.dS )2
PythonInfoz.Contains information for a Python interpreter.returnNonec           	     	    d }t           j         _        t          j                     _         j        dk    rt	          t           j                   _        t          t           j          _        t          j	        d          dk    rdnd _
        t          j        d           _        t           j         _        t          j         _        t          j        d          d	k     _         |t%          t           d
d                      _         |t%          t           dd                      _         |t%          t           dd                      _         |t%          t           dd                      _         |t%          t           dd                      _         |t           j                   _         | j                   _                                          _        	 t9          d           d}n# t:          $ r d}Y nw xY w| _        t           j         _        t          j                      _!        t%          t           j"        dd            _#        t          j$                    }d|v r3d _%         fdt          j&                    D              _'        i  _(        nt           j        d d         dk    r7d|v r3d _%         fdt          j&                    D              _'        i  _(        nTd  _%        d t          j&                    D              _'         )                                *                                 _(        t%          t          dt%          t          dd                     }d d |            ffD              _        tW                      } j'        ,                                D ]9}|-                    d t\          /                    |          D                        :|0                    d           d  |D              _1        d!t          j2        v r" 3                                \   _4         _5        nd"\   _4         _5         fd# j1        6                                D             } 7                    d$|           _8         7                    d%|           _9        t%          t           d&t%          t           d'd                      _:        d  _;        d S )(Nc                H    | d nt           j                            |           S N)r   pathabspath)vs    r   abs_pathz%PythonInfo.__init__.<locals>.abs_path%   s    944"'//!*<*<<r   PyPyP       @   py_version_nodotPy_GIL_DISABLED   prefixbase_prefixreal_prefixbase_exec_prefixexec_prefixvenvTFencodingc                J    i | ]}|t          j        |d j                   S F)expandscheme	sysconfigget_pathsysconfig_scheme.0iselfs     r   
<dictcomp>z'PythonInfo.__init__.<locals>.<dictcomp>X   =     $ $ $YZ9%ad>STTT$ $ $r      )   
   
deb_systemposix_prefixc                J    i | ]}|t          j        |d j                   S r7   r:   r>   s     r   rB   z'PythonInfo.__init__.<locals>.<dictcomp>b   rC   r   c                <    i | ]}|t          j        |d           S )F)r8   )r;   r<   r?   r@   s     r   rB   z'PythonInfo.__init__.<locals>.<dictcomp>i   s*    #o#o#oqAy'9!E'J'J'J#o#o#or   get_makefile_filename_get_makefile_filenamec                    i | ]
\  }}|||S r"   r   r?   kr%   s      r   rB   z'PythonInfo.__init__.<locals>.<dictcomp>n   s/     
 
 
1 } q
 }}r   makefile_filenamec              3  *   K   | ]}|d d         V  dS )r.   Nr   )r?   rP   s     r   	<genexpr>z&PythonInfo.__init__.<locals>.<genexpr>y   s*      "R"Rq1QrT7"R"R"R"R"R"Rr   PYTHONFRAMEWORKc                <    i | ]}|t          j        |pd           S r   )r;   get_config_varrK   s     r   rB   z'PythonInfo.__init__.<locals>.<dictcomp>|   s)    ]]]q)":17"C"C]]]r   TCL_LIBRARYNNc                b    i | ]+\  }}||!|                     j                  rj        n|,S r"   
startswithr/   system_prefixr?   rP   r%   rA   s      r   rB   z'PythonInfo.__init__.<locals>.<dictcomp>   sN     
 
 
1 amT[8Q8Qm""WX
 
 
r   stdlib
platstdlibmaxsizemaxint)<sysplatformpython_implementationimplementationtuplepypy_version_infor   version_infostructcalcsizearchitecturer;   rX   version_nodotversionr   namefree_threadedgetattrr/   r0   r1   r2   r3   
executableoriginal_executable_fast_get_system_executablesystem_executable
__import__ImportErrorhas_venvr#   getfilesystemencodingfile_system_encodingstdoutstdout_encodingget_scheme_namesr=   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	_creators)rA   r&   hasscheme_namesmakefileconfig_var_keyselementconfss   `       r   __init__zPythonInfo.__init__$   s   	= 	= 	= &<>>&((%*3+@%A%AD" ()9: #)/#"6"6!";";BB '56HII{'&56GHHAM hwsHd;;<<#8GC$E$EFF#8GC$E$EFF !)6H$)O)O P P#8GC$E$EFF"(3>22#+8DO#<#< !%!A!A!C!C	vCC 	 	 	CCC	H	$'$=$?$?!&sz:tDD 133\!!$*D!$ $ $ $^g^v^x^x$ $ $D  &(D"" bqb!W,,1M1M$2D!$ $ $ $^g^v^x^x$ $ $D  &(D""$(D!#o#oT]TlTnTn#o#o#oD %)%<%<%>%>%C%C%E%ED" 9&=wyRjlp?q?qrr
 
 %hhjj1
 
 
 %%+2244 	S 	SG"""R"RL4H4H4Q4Q"R"R"RRRRR-...]]_]]]BJ&&(,(=(=(?(?%DL$++(2%DL$+
 
 
 
+1133
 
 
 "005AA&*&9&9,&N&N#YXt0L0LMMs   %G7 7HHc                 f   d\  } }	 ddl }	 |                                }|                    d          } 	 |                    d          }|r t          j                            |          rnd}n# |j        $ r d}Y nw xY w|	|                    d          }t          j                            |           }|d                    |	                    d          dd                   |	                    d          d         g}|D ]}t          j                            |d	|           }t          j                            |          sEt          j        
                    t          j                            |d
                    r|} nn # |j        $ r Y nw xY w# t          $ r Y nw xY w| |fS )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.
        rZ   r   Nzinfo libraryzset tk_libraryzpackage require Tk.rD   tkztk.tcl)tkinterTclevalr   r#   isdirTclErrordirnamejoinr   existsrx   )	r   r   r   tcl
tk_version
tcl_parentversion_variantsro   tk_lib_paths	            r   r   zPythonInfo._get_tcl_tk_libs   s    %)	    $ffhh((>22" XX&677F &"'--"7"7 &!%{ " " "!FFF" >!$*>!?!?J!#!9!9J #!1!1#!6!6rr!:;;"((--a0($ $4 " "&(gll:~G~~&N&N!w}}[99 %$7>>"',,{H*M*MNN "%0F!E" ;   M  	 	 	D	R sF   F )F 9A0 /F 0A?<F >A??DF 
FF
F,+F,c                "   | j         s| j        | j        | j        k    s| j        S | j         dS t	          t
          dd          }|dS t
          j        |k    rdS t          j        	                    |          r|S | 
                    |          S )z?Try to get the system executable by just looking at properties.N_base_executable)r1   r0   r/   rt   rr   rd   rs   r   r#   r   _try_posix_fallback_executable)rA   base_executables     r   ru   z&PythonInfo._fast_get_system_executable   s       	,T%5%AdFVZ^ZeFeFe++ '4!#'94@@"4 >_,,4 7>>/** 	#"" 22?CCCr   c           	        | j         j        | j         j        }}| j        dk    s||fdk     rdS t          j                            |          }d| d| d| g}| j        dk    r"|                    ddd| d| d| g           |D ]E}t          j                            ||          }t          j        	                    |          r|c S FdS )	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)rE      Npythonr   r'   pypypypy3)
rj   r   r	   r   r#   r   rg   extendr   r   )rA   r   r   r	   base_dir
candidates	candidate	full_paths           r   r   z)PythonInfo._try_posix_fallback_executable   s    (.0A0Gu7g%'!9!94 7???33&u&&(@(@(@(@(@A
&((vwu@Vu@V@Vu@V@VWXXX# 	! 	!IXy99Iw~~i(( !    ! tr   c                &   | j                             |          }|s| j        | j        | j        | j        ffd| j                                        D             }|                     ||          	                    t          j                  }|S )Nc                (    i | ]\  }}||v rd n|S rW   r   )r?   rP   r%   prefixess      r   rB   z+PythonInfo.install_path.<locals>.<dictcomp>   s+    ```DAq!1==RRa```r   )
config_var)r   r   r/   r3   r0   r2   r   r   r   lstripr   sep)rA   keyresultr   r   s       @r   install_pathzPythonInfo.install_path   s    '++C00>{D$4d6FH]]H````DDWD]D]D_D_```J(((DDKKBFSSFr   c                 ^   t          j                    5  t          j        d           	 ddlm}  ddlm} n# t          $ r i cY cd d d            S w xY w	 d d d            n# 1 swxY w Y   |                     ddi          }t          t          d          rd t          _        t          j                    5  t          j        d           |                    dd	
          d d d            n# 1 swxY w Y   t          j        _                                         fd|D             S )Nignorer   )dist)SCHEME_KEYSscript_argsz--no-user-cfg
_frameworkinstallT)createc                    i | ];}|t          d |           dd                             t          j                  <S )install_r.   N)rr   r   r   r   )r?   r   r@   s     r   rB   z1PythonInfo._distutils_install.<locals>.<dictcomp>  sG    ^^^3ga!1C!1!1221226>>rvFF^^^r   )warningscatch_warningssimplefilter	distutilsr   distutils.command.installr   rx   Distributionhasattrrd   r   get_command_objr   r   r/   finalize_options)r   r   dr@   s      @r   r   zPythonInfo._distutils_install   s   
 $&& 	 	!(+++******AAAAAAA   			 	 	 	 	 	 	 	
 B		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 }o>??3%% 	"!CN$&& 	: 	:!(+++!!)D!99A	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 6	^^^^R]^^^^sC   A#8A#AA#AA##A'*A'9,C11C58C5c                Z    d                     d | j        dd         D                       S )Nr   c              3  4   K   | ]}t          |          V  d S r"   strrK   s     r   rT   z)PythonInfo.version_str.<locals>.<genexpr>  (      ??1A??????r   r   rE   r   rj   rA   s    r   version_strzPythonInfo.version_str  /    xx??(9!A#(>??????r   c                Z    d                     d | j        dd         D                       S )Nr   c              3  4   K   | ]}t          |          V  d S r"   r   rK   s     r   rT   z1PythonInfo.version_release_str.<locals>.<genexpr>  r   r   r   rD   r   r   s    r   version_release_strzPythonInfo.version_release_str  r   r   c                4    | j         }d|j         d|j         S )Nr   r   )rj   r   r	   )rA   rj   s     r   python_namezPythonInfo.python_name!  s&    (A*AA\-?AAAr   c                    | j         d uS r"   )r1   r   s    r   is_old_virtualenvzPythonInfo.is_old_virtualenv&      t++r   c                    | j         d uS r"   )r0   r   s    r   is_venvzPythonInfo.is_venv*  r   r   Nc                    | j                             |          }|dS || j        }n0| j                                        }|                    |           |} |j        di |                    d|          S )Nr   /r   )r   r   r   r   r   formatreplace)rA   r   r   r   patternbases         r   r   zPythonInfo.sysconfig_path.  s    &**3//?2,JJ&++--DKK
###Jw~++
++33C===r   Fc                f    | j         |du r ddlm} |                    |           | _         | j         S )NTr   )CreatorSelector)r   virtualenv.run.plugin.creatorsr   for_interpreter)rA   refreshr   s      r   creatorszPythonInfo.creators:  sA    >!W__FFFFFF,<<TBBDN~r   c                                          d fd j                                        D                       }t          j                            |          svt          j                             j        t          j                             	                    d                              }t          j                            |          r|}|S )Nincludec                b    i | ]+\  }}||!|                     j                  rj        n|,S r"   r\   r_   s      r   rB   z-PythonInfo.system_include.<locals>.<dictcomp>E  sN       Aq !-ALL<U<U-D&&[\  r   headers)
r   r   r   r   r#   r   r   r/   r   r   )rA   r#   fallbacks   `  r   system_includezPythonInfo.system_includeA  s    ""    /5577  
 
 w~~d## 	 w||DKARARS\A]A]1^1^__Hw~~h''  r   c                ,    | j         p| j        p| j        S r"   )r1   r0   r/   r   s    r   r^   zPythonInfo.system_prefixQ  s    B4#3Bt{Br   c                ,    | j         p| j        p| j        S r"   )r1   r2   r3   r   s    r   system_exec_prefixzPythonInfo.system_exec_prefixU  s    L4#8LD<LLr   r   c                    d                     | j        j        d | j                                        D                       S )Nz{}({!r})c                D    i | ]\  }}|                     d           ||S )_)r]   rO   s      r   rB   z'PythonInfo.__repr__.<locals>.<dictcomp>\  s/    MMMda1<<;L;LMQMMMr   )r   	__class____name____dict__r   r   s    r   __repr__zPythonInfo.__repr__Y  sA      N#MMdm1133MMM
 
 	
r   c                z   d                     | j        j        d                    d d| j        f| j        | j        | j        k    rdnd | j        f| j        | j        | j        hvrdnd | j        fd| j        fd| j        fd	t          | j
                  fd
| j         d| j         ffD                                 S )Nz{}({})z, c              3  .   K   | ]\  }}|| d| V  d S )N=r   rO   s      r   rT   z%PythonInfo.__str__.<locals>.<genexpr>b  sB        Aq& =) 

q

( !===+ r   specsystemoriginalexere   ro   encoding_fs_io-)r   r  r  r   r	  rv   rs   rt   re   reprro   r{   r}   r   s    r   __str__zPythonInfo.__str___  s   N#II   TY'  1=$BX\`\kBkBk !!.	  3D<RTXTc;ddd #
!0	 DO,/T\ 2 23%$*C'\'\dFZ'\'\]#    
 
 	
r   c                    d                     | j        d                    d | j        D                       | j        rdnd| j                  S )Nz	{}{}{}-{}r   c              3  4   K   | ]}t          |          V  d S r"   r   rK   s     r   rT   z"PythonInfo.spec.<locals>.<genexpr>  s(      77SVV777777r   tr   )r   rg   r   rj   rq   rm   r   s    r   r	  zPythonInfo.spec{  sV    !!HH77T%677777%-CC2	
 
 	
r   c                Z    ddl m}  ||           | j                                         d S )Nr   )clear)#virtualenv.discovery.cached_py_infor  _cache_exe_discovery)clsapp_datar  s      r   clear_cachezPythonInfo.clear_cache  s>     	>=====h &&(((((r   c                    |j         r| j        t          j                             |j                   k    rdS |j        st          j                             | j                  }|j         }t          j        dk    rOt          j         	                    |          \  }}|
                    |          r|dt          |                    }||k    rdS |r=|j        6|j                                        | j                                        k    rdS |j        |j        | j        k    rdS |j        |j        | j        k    rdS |j        t| j        }|j         d|j         d|j         }|j        dk    r-ddd	d
                    |j                  }|| | |j         }|j                            |          sdS t3          | j        dd         |j        |j        |j        f          D ]\  }}	|	|	||	k    r dS dS )zXCheck if a given specification can be satisfied by the this python interpreter instance.Twin32NFr   finalabrc)alphabetar   r   rE   )r#   rs   r   r$   is_absbasenamert   rd   re   splitextendswithlenrg   r   rm   rq   version_specifierrj   r   r	   r
   r   r   r   containszip)
rA   r	  impl_must_matchr$  	spec_pathsuffixrj   releaseourreqs
             r   	satisfieszPythonInfo.satisfies  s6   9 	!"'//$)"<"<<<t; 	!7++D,DEE I	<7**')w'7'7'A'A$Hf ))&11 >$-nVn$=	y(( 5 	#/#))++t/B/H/H/J/JJJ5(T->$BS-S-S5)d.@DDV.V.V5!-,L%+WWl.@WW<CUWWG(G33 !%  #l/00	 
 %!(G&G,2EGGG)227;; uD-ac2TZTZ4XYY 	 	HC3?sczzuutr   c                n    | j         (|                     t          j        |dd          | _         | j         S )
        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   rs   r  r  s     r   currentzPythonInfo.current  s3     <<<QUgl<mmCL|r   c                n    | j         (|                     t          j        |dd          | _         | j         S )r3  NTr4  )_current_systemr8  rd   rs   r9  s     r   current_systemzPythonInfo.current_system  s6     &"%,,s~xX\nr,"s"sC""r   c                R    t          j        |                                 d          S )NrD   )indent)jsondumps_to_dictr   s    r   _to_jsonzPythonInfo._to_json  s    z$--//!4444r   c                x      fdt                     D             }|d                                         |d<   |S )Nc                B    i | ]}||d k    rt          |          ndS )r   N)rr   )r?   varrA   s     r   rB   z'PythonInfo._to_dict.<locals>.<dictcomp>  s4    ```cC;,>,>gdC(((D```r   rj   )vars_asdict)rA   datas   ` r   rB  zPythonInfo._to_dict  sF    ````UYZ^U_U_```#N3;;==^r   Tc                ,   ddl m} |t          j        n|} || |||||          }t	          |t
                    rW|rU	 |                    ||          }n=# t          $ r0}	|r t          	                    d|j
        |	           d}Y d}	~	nd}	~	ww xY w|S )z9Given a path to an executable get the python information.r   )r8  N)envr5  ignore_cachez-ignore %s due cannot resolve system due to %r)r  r8  r   r   
isinstancer   _resolve_to_system	ExceptionLOGGERinfort   )
r  r  r  r5  rL  r6  rK  r8  proposed	exceptions
             r   r8  zPythonInfo.from_exe  s     	A@@@@@KbjjS8C3Ceqrrrh
++ 	  	  #66xJJ      ! KXMiktuuu	 
 s    A 
B!&BBc                x    t          j        |          }|                     |                                          S r"   )r@  loads
_from_dictr   )r  payloadraws      r   
_from_jsonzPythonInfo._from_json  s-     j!!~~chhjj)))r   c                v    t          di |d         |d<    |             }|                                |_        |S )Nrj   r   )r   r   r  )r  rI  r   s      r   rV  zPythonInfo._from_dict  s>    *BBT.-ABB^))++r   c                   |j         }t                      }|j        8|j        p|j        p|j        }||v rt          |          dk    r(t                              d|           |j         |_        nt          |
                                d          D ]%\  }\  }}t                              d|||           &t                              dt          |          dz   ||           d                    d                    |                                                    }	t          |	          |||<   |                    ||d          }|j        8|j         |j        k    r|                     |j        |          }||_         |S )	Nr.   z$%r links back to itself via prefixes)startz%d: prefix=%s, info=%rz prefixes are causing a circle {}|F)r/   exact)rs   r   rv   r1   r0   r/   r'  rP  rQ  	enumerater   errorr   r   keysRuntimeErrordiscover_exer8  )
r  r  targetstart_executabler   r/   atpr  msgs
             r   rN  zPythonInfo._resolve_to_system  s~   !,==&.'N6+=NF!!x==A%%KK FOOO/5/@F,"+HNN,<,<A"F"F"F E EJBALL!92q!DDDD5s8}}q7H&RXYYY8??@Y@YZZ"3'''%HV((&(NNF &.  888\\&":HEEF,r   c           
        ||f}|| j         v r7|r5t                              d||| j         |                    | j         |         S t                              d| |           |                                 }|                     |          }g }|t
          j        n|}|D ]3}	|D ].}
|                     ||	|
|||          }||| j         |<   |c c S /4|du r_|r]|                     ||           }t
          j	        
                    |          }|| j         |<   t                              d||           |S d                    d
                    |          t
          j	        
                    |                    }t          |          )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  rP  debug_find_possible_exe_names_find_possible_foldersr   r   
_check_exe_select_most_likelyr   r   r   rb  )rA   r  r/   r^  rK  r   possible_namespossible_folders
discoveredfolderrp   rQ  foldersrh  s                 r   rc  zPythonInfo.discover_exe  s   em$++++LLDfeUYUnorUsttt,S110$???668866v>>
KbjjS& 	  	 F&    xujRUVV#59D-c2KKKKK $ 
 E>>j>++J==Djoo&677G-1D%c*LLacgipqqqK)00.1I1I2:??[kKlKlmm3r   c                &   t           j                            ||          }t           j                            |          sd S |                     ||dd|          }|d S dD ]}	t          ||	          }
t          | |	          }|
|k    r|	dk    r>d                    d |
D                       d                    d |D                       }}
|j        }t                              d||	|
|           |du r|	                    |            n|S d S )	NF)r6  r5  rK  )rg   rm   rj   rj   r   c              3  4   K   | ]}t          |          V  d S r"   r   rK   s     r   rT   z(PythonInfo._check_exe.<locals>.<genexpr>E  s(      .E.E!s1vv.E.E.E.E.E.Er   c              3  4   K   | ]}t          |          V  d S r"   r   rK   s     r   rT   z(PythonInfo._check_exe.<locals>.<genexpr>E  s-      OiOi[\PSTUPVPVOiOiOiOiOiOir   z2refused interpreter %s because %s differs %s != %s)
r   r#   r   r   r8  rr   rs   rP  rj  append)rA   r  rr  rp   r^  rq  rK  exe_pathrQ  itemfoundsearchedrs   s                r   rm  zPythonInfo._check_exe9  s5   7<<--w~~h'' 	4}}XxW\be}ff<4F 	 	DD$''EtT**H  >))&)hh.E.Eu.E.E.E&E&EsxxOiOi`hOiOiOiGiGi8E!_
QS]_cejltuuuE>>%%d+++ ! Ktr   c                B    fd}t          | |d          }|d         S )Nc                   | 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 t          t          |                    D                       S )Nc              3  .   K   | ]\  }}|rd |z  ndV  dS )r.   r   Nr   )r?   posmatchs      r   rT   zBPythonInfo._select_most_likely.<locals>.sort_by.<locals>.<genexpr>_  s3      aajc5E0Sqaaaaaar   )rg   rj   r   r	   rm   r
   r   r   sumr_  reversed)rQ  matchesrd  s     r   sort_byz/PythonInfo._select_most_likely.<locals>.sort_byS  s     #v'<<!'6+>+DD!'6+>+DD!V%88!'6+>+DD!.&2E2RR!(F,?,FFG aaIhW^N_N_D`D`aaaaaar   T)r   reverser   )sorted)rq  rd  r  sorted_discovereds    `  r   rn  zPythonInfo._select_most_likelyO  sC    	b 	b 	b 	b 	b #:7DIII ##r   c                   t                      }t                      }d |t          j                            | j                  <   d || j        <   d |t          j                            | j                  <   d || j        <   |D ]`}t          j                            |          }|                    | j                  r%|t          | j                  d          }d || | <   ad ||<   d |D             S )Nc                P    g | ]#}t           j                            |          !|$S r   )r   r#   r   rK   s     r   
<listcomp>z5PythonInfo._find_possible_folders.<locals>.<listcomp>t  s+    AAAarw~~a/@/@AAAAr   )
r   r   r#   realpathrs   rt   r   r]   r/   r'  )rA   inside_foldercandidate_folderexecutablesr  r   relatives          r   rl  z!PythonInfo._find_possible_foldersd  s    &==!mm9=BG$$T_556'+DO$BFBG$$T%=>>?04D,- 	F 	FC7??3''Dt{++ FDK 0 0 2 23AE M!=8!=!=> +/'AA+AAAAr   c           
        t                      }|                                 D ]}dD ]|}d                    d | j        d |         D                       }dg}| j        r|                    d           |D ],}d| j         dfD ]}t          D ]}| | | | | }	d ||	<   -}t          |	                                          S )N)rE   rD   r.   r   r   c              3  4   K   | ]}t          |          V  d S r"   r   rK   s     r   rT   z6PythonInfo._find_possible_exe_names.<locals>.<genexpr>z  s(      "J"Ja3q66"J"J"J"J"J"Jr   r   r  r  )
r   _possible_baser   rj   rq   rw  rm   
EXTENSIONSr   ra  )
rA   name_candidaterp   rf  ro   modsmodarchextr   s
             r   rk  z#PythonInfo._find_possible_exe_namesv  s   $'')) 
	= 
	=D" 	= 	=(("J"J43DSbS3I"J"J"JJJt% %KK$$$ = =C!8T%6!8!8" = = =#- = =C+/(J(J#(Jt(JS(J(JI8<N955===	= N''))***r   c              #    K   t                      }t          j                            t          j                            | j                            d                             t                    }d ||<   d || j        <   d|v r|d= d |d<   |D ]R}|	                                }|V  ddl
m}  |            r(||k    r|V  |                                }||k    r|V  Sd S )Nr   r   )fs_is_case_sensitive)r   r   r#   r%  r$  rs   rstripr   rg   r   virtualenv.infor  upper)rA   possible_baser$  r   r   r  r  s          r   r  zPythonInfo._possible_base  s     #7##BG$4$4T_$E$EFFqIPPQWXX"&h-1d)*}$$h'"&h! 
	  
	 DJJLLEKKK<<<<<<##%%  5==JJJ

D==KKK
	  
	 r   )r   r   )F)r   r   r"   )r   r   )NTFTN)TN)/r  
__module____qualname____doc__r   staticmethodr   ru   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r^   r   r  r  r	  classmethodr  r1  r<  r7  r:  r=  rC  rB  r8  rY  rV  rN  r  rc  rm  rn  rl  rk  r  r   r   r   r   r   !   s       88f f f fP 2 2 \2hD D D4  8   _ _ \_0 @ @ X@ @ @ X@ B B XB , , X, , , X, .2rv 
> 
> 
> 
>      X C C XC M M XM
 
 
 

 
 
 
8 
 
 X
 ) ) [). . .` OH   [ # # # # [#5 5 5       [4 * * [*
   [   [.        4  , $ $ \$(B B B$+ + +         r   r   __main__r.   r   rS   )#r  
__future__r   r@  loggingr   re   rerk   rd   r;   r   collectionsr   r   stringr   r   	getLoggerr  rP  r   r  compiler   r   argvr'  start_cookie
end_cookierC  rQ  r|   writer   r   r   r   <module>r     s#    # " " " " "   				  				  



      / / / / / / / /      j(](](]^^		8	$	$f f f "!##
rz)$$w	  w	  w	  w	  w	  w	  w	  w	 t z 8ABB<D
s4yyA~~AwABBx
s4yyA~~!W
ABBx
x|d"CH:<<  ""DJRWWl44R40$
44R48HIJJKKKKK) r   