
    yIfJ                    "   d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZmZ ddlmZmZ ddlmZmZmZ  G d	 d
          Z G d d          Z G d de          Z G d dee          Z G d de          Z G d dee          Zg dZdS )aG  
Virtual environments in the traditional sense are built as reference to the host python. This file allows declarative
references to elements on the file system, allowing our system to automatically detect what modes it can support given
the constraints: e.g. can the file system symlink, can the files be read, executed, etc.
    )annotationsN)ABCabstractmethod)OrderedDict)S_IXGRPS_IXOTHS_IXUSR)fs_is_case_sensitivefs_supports_symlink)copymake_exesymlinkc                      e Zd ZdZdZdZdS )RefMustNAr   r   N)__name__
__module____qualname__r   COPYSYMLINK     `/var/www/piapp/venv/lib/python3.11/site-packages/virtualenv/create/via_global_ref/builtin/ref.pyr   r      s        	BDGGGr   r   c                      e Zd ZdZdZdZdS )RefWhenANYr   r   N)r   r   r   r   r   r   r   r   r   r   r      s        
CDGGGr   r   c                      e Zd ZdZ e            Z e            Zej	        e
j        fddZddZed             Zed             Zed	             Zed
             Zd ZdS )PathRefzABase class that checks if a file reference can be symlink/copied.returnNonec                    || _         || _        || _        	 |                                | _        n# t          $ r
 d| _        Y nw xY w| j        rd nd| _        | j        rd nd| _        | j        rd nd| _        d S NF)mustwhensrcexistsOSError	_can_read	_can_copy_can_symlink)selfr%   r#   r$   s       r   __init__zPathRef.__init__$   s    			 **,,DKK 	  	  	 DKKK	 !%7%!%7%$(K:DDUs   1 AAstrc                0    | j         j         d| j         dS )N(src=))	__class__r   r%   r+   s    r   __repr__zPathRef.__repr__0   s     .);;;;;;r   c                `   | j         | j                                        rR	 | j                            d          5  d| _         d d d            n# 1 swxY w Y   nM# t          $ r
 d| _         Y n:w xY wt          j        t          | j                  t
          j                  | _         | j         S )NrbTF)	r(   r%   is_fileopenr'   osaccessr-   R_OKr2   s    r   can_readzPathRef.can_read3   s    >!x!! C+t,, . .)-. . . . . . . . . . . . . . . + + +%*DNNN+ "$3tx=="'!B!B~s4   A AA AA AA A0/A0c                z    | j         .| j        t          j        k    r| j        | _         n| j        | _         | j         S N)r)   r#   r   r   can_symlinkr;   r2   s    r   can_copyzPathRef.can_copy@   s6    >!yGO++!%!1!%~r   c                    | j         5| j        t          j        k    r| j        | _         n| j        o| j        | _         | j         S r=   )r*   r#   r   r   r?   FS_SUPPORTS_SYMLINKr;   r2   s    r   r>   zPathRef.can_symlinkI   sB    $yGL(($(M!!$($<$N!  r   c                    t           r=   )NotImplementedError)r+   creatorsymlinkss      r   runzPathRef.runR   s    !!r   c                    | j         t          j        k    rt          S | j         t          j        k    rt
          S |rt          nt
          S r=   )r#   r   r   r   r   r   )r+   rE   s     r   methodzPathRef.methodV   s9    9''N9$$K",ww,r   Nr   r    r   r-   )r   r   r   __doc__r   rA   r
   FS_CASE_SENSITIVEr   r   r   r   r,   r3   propertyr;   r?   r>   r   rF   rH   r   r   r   r   r      s        KK--//,,..!('+ 
; 
; 
; 
; 
;< < < < 
 
 X
   X ! ! X! " " ^"- - - - -r   r   c                  j     e Zd ZdZej        ej        fd fdZe	d             Z
e	d             Z xZS )
ExePathRefzJBase class that checks if a executable can be references via symlink/copy.r   r    c                \    t                                          |||           d | _        d S r=   )superr,   _can_run)r+   r%   r#   r$   r1   s       r   r,   zExePathRef.__init__a   s*    dD)))r   c                "    | j         r| j        S dS r"   )rA   can_runr2   s    r   r>   zExePathRef.can_symlinke   s    # 	 <ur   c                    | j         I| j                                        j        }t          t
          t          fD ]}||z  rd| _          nd| _         | j         S )NTF)rR   r%   statst_moder	   r   r   )r+   modekeys      r   rT   zExePathRef.can_runk   sY    = 8==??*D'2 & &#: )$(DM %}r   rI   )r   r   r   rK   r   r   r   r   r,   rM   r>   rT   __classcell__r1   s   @r   rO   rO   ^   s        TT!('+          X
 	 	 X	 	 	 	 	r   rO   c                  D     e Zd ZdZej        ej        fd fdZd Z	 xZ
S )PathRefToDestzLink a path on the file system.r   r    c                \    t                                          |||           || _        d S r=   )rQ   r,   dest)r+   r%   r_   r#   r$   r1   s        r   r,   zPathRefToDest.__init__{   s*    dD)))			r   c                0   |                      || j                  }|                     |          }t          |t                    r|n|f}|j                                        s|j                            dd           |D ]} || j        |           d S )NT)parentsexist_ok)r_   r%   rH   
isinstancelistparentr&   mkdir)r+   rD   rE   r_   rH   dest_iterabledsts          r   rF   zPathRefToDest.run   s    yy$(++X&& *4 6 6CTG{!!## 	;KdT:::  	" 	"CF48S!!!!	" 	"r   rI   )r   r   r   rK   r   r   r   r   r,   rF   rZ   r[   s   @r   r]   r]   x   s`        ))'.z       " " " " " " "r   r]   c                  B    e Zd ZdZej        ej        fd	dZd Z	d
dZ
dS )ExePathRefToDestz#Link a exe path on the file system.r   r    c                @   t                               | |||           t                              | ||||           | j        s8t	          t          d |D                                                                 }|d         | _        |dd          | _        || _	        d S )Nc              3  B   K   | ]}|                                 d fV  d S r=   )lower).0is     r   	<genexpr>z,ExePathRefToDest.__init__.<locals>.<genexpr>   s/      &J&JQ		4'8&J&J&J&J&J&Jr   r      )
rO   r,   r]   rL   rd   r   keysbasealiasesr_   )r+   r%   targetsr_   r#   r$   s         r   r,   zExePathRefToDest.__init__   s    D#tT222tS$d;;;% 	S;&J&J'&J&J&JJJOOQQRRGAJ	qrr{			r   c                   |                      || j                  j        }|| j        z  }|                     |          } || j        |           |st          |           | j        D ]r}||z  }|                                r|                                 |r|	                    | j                   nt          | j        |           |st          |           sd S r=   )r_   r%   re   rs   rH   r   rt   r&   unlink
symlink_tor   )r+   rD   rE   bin_dirr_   rH   extra	link_files           r   rF   zExePathRefToDest.run   s    ))GTX..5"X&&tx 	TNNN\ 		$ 		$E%I!! #  """ *$$TY////TXy))) $###		$ 		$r   r-   c                @    | j         j         d| j         d| j         dS )Nr/   z, alias=r0   )r1   r   r%   rt   r2   s    r   r3   zExePathRefToDest.__repr__   s*    .)QQQQ$,QQQQr   NrI   rJ   )r   r   r   rK   r   r   r   r   r,   rF   r3   r   r   r   rj   rj      se        --07
     $ $ $$R R R R R Rr   rj   )rO   rj   r   r]   r   r   )rK   
__future__r   r8   abcr   r   collectionsr   rV   r   r   r	   virtualenv.infor
   r   virtualenv.util.pathr   r   r   r   r   r   rO   r]   rj   __all__r   r   r   <module>r      s    # " " " " " 				 # # # # # # # # # # # # # # * * * * * * * * * * E E E E E E E E 8 8 8 8 8 8 8 8 8 8              =- =- =- =- =-c =- =- =-@    #   4" " " " "G " " ""R R R R R}j R R RD  r   