
    .Ph                     ^   d dl m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 ddlmZ dd	lmZ dd
lmZ e
rd dlmZ d dlmZmZmZmZmZ d dlmZ  ej        e          Z  G d de          Z!	 d'd(dZ"	 	 d'd)dZ#d*dZ$ G d  d!          Z%d+d#Z& G d$ d%e          Z'g d&Z(dS ),    )annotationsN)suppress)Path)TYPE_CHECKING)IS_WIN
fs_path_id   )Discover)
PythonInfo)
PythonSpec)ArgumentParser)Callable	GeneratorIterableMappingSequence)AppDatac                  h     e Zd ZU ded<   ded<   ded<   d fdZedd            ZddZddZ xZ	S )BuiltinzSequence[str]python_specr   app_datatry_first_withreturnNonec                (   t                                          |           |j        pt          j        g| _        | j                            d          r$| j        dd          | j        d d         z   | _        |j        | _        |j	        | _	        d S )NVIRTUALENV_PYTHONr	   )
super__init__pythonsys
executabler   _envgetr   r   )selfoptions	__class__s     \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/virtualenv/discovery/builtin.pyr   zBuiltin.__init__   s    !!!">=cn-=9==,-- 	K#/3d6Frr6JJD(%4    parserr   c           
         |                     ddddt          dg d           |                     dd	d
t          dg d           d S )Nz-pz--pythonr   pyappendzinterpreter based on what to create environment (path/identifier) - by default use the interpreter where the tool is installed - first found wins)destmetavartypeactiondefaulthelpz--try-first-withr   py_exez:try first these interpreters before starting the discovery)add_argumentstr)clsr)   s     r'   add_parser_argumentszBuiltin.add_parser_arguments%   sx    ^ 	 
	
 
	
 
	
 	!M 	 	
 	
 	
 	
 	
r(   PythonInfo | Nonec                h    | j         D ])}t          || j        | j        | j                  }||c S *d S N)r   get_interpreterr   r   r"   )r$   r   results      r'   runzBuiltin.run<   sI    + 	 	K$[$2Et}VZV_``F! "tr(   r5   c                |    t          | j                  dk    r| j        d         n| j        }| j        j         d|S )Nr	   r   z discover of python_spec=)lenr   r&   __name__)r$   specs     r'   __repr__zBuiltin.__repr__C   sE    &)$*:&;&;q&@&@t""dFV.)LLDLLLr(   )r   r   )r)   r   r   r   )r   r8   r   r5   )
r@   
__module____qualname____annotations__r   classmethodr7   r=   rB   __classcell__)r&   s   @r'   r   r      s         !!!!5 5 5 5 5 5 
 
 
 [
,   M M M M M M M Mr(   r   r   Iterable[str]r   AppData | NoneenvMapping[str, str] | Noner   r8   c                   t          j        |           }t                              d|           t	                      }|t
          j        n|}t          ||||          D ]x\  }}|j        |f} | |v rt                              d|           |	                    ||          rt          
                    d|           |c S |                    |            yd S )Nzfind interpreter for spec %rzproposed %szaccepted %s)r   from_string_specLOGGERinfosetosenvironpropose_interpreterssystem_executable	satisfiesdebugadd)keyr   r   rK   rA   proposed_pathsinterpreterimpl_must_matchs           r'   r;   r;   H   s     &s++D
KK.555UUN"**C(<T>S[]`(a(a    $_+_<.  M;///  77 	LL44434r(   rA   r   .Generator[tuple[PythonInfo, bool], None, None]c              #    K   |t           j        n|}t                      }|D ]}t           j                            |          }	 t          j        |           t           j                            |          }t          |          }||v ri|                    |           t          j	        |||          dfV  # t          $ r Y w xY w| j        	 t          j        | j                   t           j                            | j                  }t          |          }||vr0|                    |           t          j	        |||          dfV  n# t          $ r | j        r Y nw xY w| j        rd S nt          j        |          }	t          |	j                  }t          |          }||vr|                    |           |	dfV  t          rYddlm}
  |
| ||          D ]E}t          |j                  }t          |          }||v r*|                    |           |dfV  Ft%          |           }t'          t)          |                    D ]\  }}t*                              t/          |||                      ||          D ]c\  }}t          |          }t          |          }||v r(|                    |           t0          	                    ||d|          }|||fV  dd S )N)rK   Tr	   )rT   F)raise_on_errorrK   )rR   rS   rQ   pathabspathlstatr   rX   r   from_exeOSErroris_abscurrent_systemr5   r!   r   windowsrT   path_exe_finder	enumerate	get_pathsrO   rW   LazyPathDumpPathPythonInfo)rA   r   r   rK   tested_exesr3   r`   exe_rawexe_idcurrent_pythonrT   r[   find_candidatesposexer\   s                   r'   rT   rT   [   s      "**CEEK  H Hwv&&
	HHTNNN good++G((F$$OOF###%gxSAAA4GGGGG  	 	 	D	 y
	LHTY
 goodi00G((F[((''' )'8EEEtKKKK  	 	 	{  	 ; 	F	 $28<<n/00G$$$$OOF### $&&&&  		(55555533D(CHH ( (k455#G,,[(('''!4'''''%d++Oy~~.. 
3 
3	T\#tS11222$3OD$9$9 	3 	3 C#hhG((F$$OOF###(11'8TY_b1ccK&!?2222	3
3 
3s$   B==
C
	C
E E+*E+Mapping[str, str]Generator[Path, None, None]c              #    K   |                      dd           }|9	 t          j        d          }n## t          t          f$ r t          j        }Y nw xY w|rt          t          |                    t          j	                            D ]V}t          t                    5  t          |                                d           r|V  d d d            n# 1 swxY w Y   Ud S d S )NPATHCS_PATH)r#   rR   confstrAttributeError
ValueErrordefpathmapr   splitpathsepr   rd   nextiterdir)rK   r`   ps      r'   rj   rj      s)     7764  D|	:i((DD
+ 	 	 	:DDD	 T4::bj1122 	 	A'""  		T** GGG               	 	s!   1 AA'CC	C	c                      e Zd Zdd	ZddZdS )rk   rr   intr`   r   rK   rt   r   r   c                0    || _         || _        || _        d S r:   )rr   r`   rK   )r$   rr   r`   rK   s       r'   r   zLazyPathDump.__init__   s    	r(   r5   c                X   d| j          d| j         }| j                            d          r}|dz  }| j                                        D ]^}	 |                                s&|                                j        t          j	        z  s>n# t          $ r Y nw xY w|dz  }||j        z  }_|S )Nzdiscover PATH[z]=_VIRTUALENV_DEBUGz with => )rr   r`   rK   r#   r   is_dirstatst_moderR   X_OKrd   name)r$   content	file_paths      r'   rB   zLazyPathDump.__repr__   s    :48::ty::8<<+,, 		*z!G!Y..00 * *	 '')) !)..2B2B2JRW2T ! !   D39>)s   :B


BBN)rr   r   r`   r   rK   rt   r   r   rC   )r@   rD   rE   r   rB    r(   r'   rk   rk      s<           
     r(   rk   :Callable[[Path], Generator[tuple[Path, bool], None, None]]c                    |                      t          j        dk              | j        t          j        dk    r dd	fd}|S )
z^Given a spec, return a function that can be called on a path to find all matching files in it.win32)rg   z.exer`   r   r   (Generator[tuple[Path, bool], None, None]c              3     K   | z  }|                                 r|dfV  |                                 D ]@}                    |j                  }|r"|                                |d         dk    fV  Ad S )NFimplr   )existsr   	fullmatchr   absolute)r`   direct_pathrs   matchdirectpats       r'   	path_exesz"path_exe_finder.<locals>.path_exes   s      Vm 	%u$$$$ <<>> 	@ 	@CMM#(++E @llnneFmx&?????		@ 	@r(   )r`   r   r   r   )generate_rer    platformstr_spec)rA   r   r   r   s     @@r'   rh   rh      sr    


3<7#:

;
;C]F
|w@ @ @ @ @ @ @ r(   c                      e Zd ZdZdS )rl   zpython info from path.N)r@   rD   rE   __doc__r   r(   r'   rl   rl      s            r(   rl   )r   rl   r;   )NN)r   rI   r   rJ   rK   rL   r   r8   )
rA   r   r   rI   r   rJ   rK   rL   r   r]   )rK   rt   r   ru   )rA   r   r   r   ))
__future__r   loggingrR   r    
contextlibr   pathlibr   typingr   virtualenv.infor   r   discoverr
   py_infor   py_specr   argparser   collections.abcr   r   r   r   r   virtualenv.app_data.baser   	getLoggerr@   rO   r   r;   rT   rj   rk   rh   rl   __all__r   r(   r'   <module>r      s'   " " " " " "  				 



                         . . . . . . . .                   1''''''PPPPPPPPPPPPPP000000		8	$	$-M -M -M -M -Mh -M -M -Mb jn    ,  $$(	F3 F3 F3 F3 F3R          *   .! ! ! ! !Z ! ! !  r(   