
    3i                        d dl m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 e	rd dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ  ej0                  e      Z G d de      Z G d dee      ZddgZy)    )annotationsN)ABC)Path)TYPE_CHECKING)CreatorCreatorMeta)fs_supports_symlink)ArgumentParser)Any)
PythonInfo)AppData)VirtualEnvOptionsc                  D     e Zd Zd fdZedd       Zedd       Z xZS )ViaGlobalRefMetac                b    t         |           d | _        d | _        t	               sd| _        y y )Nz(the filesystem does not supports symlink)super__init__
copy_errorsymlink_errorr	   self	__class__s    W/var/www/opsc/venv/lib/python3.12/site-packages/virtualenv/create/via_global_ref/api.pyr   zViaGlobalRefMeta.__init__   s0    !"$!KD %    c                    | j                    S N)r   r   s    r   can_copyzViaGlobalRefMeta.can_copy    s    ??""r   c                    | j                    S r   )r   r   s    r   can_symlinkzViaGlobalRefMeta.can_symlink$   s    %%%%r   returnNone)r"   bool)__name__
__module____qualname__r   propertyr   r    __classcell__r   s   @r   r   r      s1    L # # & &r   r   c                       e Zd Zd fdZeredd       Zedd       Zedd       Z	e
	 	 	 	 	 	 	 	 	 	 d fd       ZddZddZddZd fd	Zd fd
Z xZS )ViaGlobalRefApic                t    t         |   ||       | j                  |      | _        |j                  | _        y r   )r   r   _should_symlinksymlinkssystem_siteenable_system_site_package)r   optionsinterpreterr   s      r   r   zViaGlobalRefApi.__init__*   s2    +.,,W5*1*=*='r   c                     y r    r   s    r   purelibzViaGlobalRefApi.purelib1   s    #&r   c                     y r   r5   r   s    r   
script_dirzViaGlobalRefApi.script_dir4   s    &)r   c                    t        | dd      t        | dd      }}| j                  d      | j                  d      }}dD ]*  }||k(  r|nd }||k(  r|nd }|du r|du r y|du r y|du s* y y)NcopiesFr/   )clizenv varfiledefaultT)getattr
get_source)r2   r:   r/   copy_srcsym_srclevels_optc_opts           r   r.   zViaGlobalRefApi._should_symlink7   s     #7He<ggz[`>a#..x8':L:LZ:X': 	E '5 0HdE&%/FTE}$}}	 r   c                2   t         |   ||||       |j                  ddddd       |j                  s|j                  sug }|j
                  r|j                  d|j
                          |j                  r|j                  d|j                          d	d
j                  |       }t        |      |j                         }|j                  r|j                  ddddd       |j                  r#|j                  dd|j                   ddd       y y )Nz--system-site-packagesF
store_truer0   zCgive the virtual environment access to the system site-packages dir)r=   actiondesthelpz	symlink: zcopy: z*neither symlink or copy method supported: z, z
--symlinksTr/   zZtry to use symlinks rather than copies, when symlinks are not the default for the platformz--copiesz--always-copyr:   z[try to use copies rather than symlinks, even when symlinks are the default for the platform)r   add_parser_argumentsadd_argumentr    r   r   appendr   joinRuntimeErroradd_mutually_exclusive_group)	clsparserr3   metaapp_dataerrorsmsggroupr   s	           r   rJ   z$ViaGlobalRefApi.add_parser_argumentsH   s(    	$V[$I$V 	 	
 F!!	$*<*<)=>?t&789>tyy?P>QRCs##335#q   == ,,,#r   r   c                $    | j                          y r   )install_patchr   s    r   createzViaGlobalRefApi.createo   s    r   c                
   | j                         }|rq| j                  dz  }t        j                  d|       |j	                  dd       | j                  dz  }t        j                  d|       |j	                  |d       y y )Nz_virtualenv.pthz%create virtualenv import hook file %szimport _virtualenvutf-8encoding_virtualenv.pyz	create %s)env_patch_textr6   LOGGERdebug
write_text)r   textpth	dest_paths       r   rX   zViaGlobalRefApi.install_patchr   sw    ""$,,!22CLL@#FNN/'NB'77ILLi0   8 r   c                z   | j                   j                  t        t              j                  dz        5 }|j                  d      }|j                  dt        t        j                  j                  t        | j                        t        | j                                          cddd       S # 1 sw Y   yxY w)zJPatch the distutils package to not be derailed by its configuration files.r^   r[   r\   z"__SCRIPT_DIR__"N)rS   ensure_extractedr   __file__parent	read_textreplacereprospathrelpathstrr8   r6   )r   resolved_pathrc   s      r   r_   zViaGlobalRefApi.env_patch_text|   s    ]]++DN,A,ADT,TU 	tYf **G*<D<< 2DT__I]_bcgcoco_p9q4rs	t 	t 	ts   A1B11B:c                @    g t         |          d| j                  fS )Nglobal)r   _argsr1   r   s    r   rt   zViaGlobalRefApi._args   s$    NN8T-L-L"MNNr   c                \    t         |           | j                  rdnd| j                  d<   y )Ntruefalsezinclude-system-site-packages)r   set_pyenv_cfgr1   	pyenv_cfgr   s    r   rx   zViaGlobalRefApi.set_pyenv_cfg   s(    CGCbCbho56r   )r2   r   r3   r   r"   r#   )r"   r   )r2   r   r"   r$   )
rQ   r
   r3   r   rR   r   rS   r   r"   r#   r!   )r"   rp   )r"   zlist[tuple[str, Any]])r%   r&   r'   r   r   r(   r6   r8   staticmethodr.   classmethodrJ   rY   rX   r_   rt   rx   r)   r*   s   @r   r,   r,   )   s    >
 	& 
&	) 
)   $#$2<$DT$`g$	$ $L9tOp pr   r,   )
__future__r   loggingrm   abcr   pathlibr   typingr   virtualenv.create.creatorr   r   virtualenv.infor	   argparser
   r   python_discoveryr   virtualenv.app_data.baser   virtualenv.config.cli.parserr   	getLoggerr%   r`   r   r,   __all__r5   r   r   <module>r      so    "  	     : /'+0>			8	$&{ &"_pgs _pF r   