o
    f                     @  s~   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	m
Z
 d dlmZ G dd de
ZG d	d
 d
e	eZd
dgZdS )    )annotationsN)ABC)Path)CreatorCreatorMeta)fs_supports_symlinkc                      s6   e Zd Zd	 fddZedd Zedd Z  ZS )
ViaGlobalRefMetareturnNonec                   s*   t    d | _d | _t sd| _d S d S )Nz(the filesystem does not supports symlink)super__init__
copy_errorsymlink_errorr   self	__class__ Z/var/www/html/dev/env/lib/python3.10/site-packages/virtualenv/create/via_global_ref/api.pyr      s   

zViaGlobalRefMeta.__init__c                 C     | j  S N)r   r   r   r   r   can_copy      zViaGlobalRefMeta.can_copyc                 C  r   r   )r   r   r   r   r   can_symlink   r   zViaGlobalRefMeta.can_symlinkr	   r
   )__name__
__module____qualname__r   propertyr   r   __classcell__r   r   r   r   r      s    
r   c                      sj   e Zd Zd fddZedd Ze fddZd	d
 Zdd Z	dd Z
 fddZ fddZ  ZS )ViaGlobalRefApir	   r
   c                   s&   t  || | || _|j| _d S r   )r   r   _should_symlinksymlinkssystem_siteenable_system_site_package)r   optionsinterpreterr   r   r   r      s   zViaGlobalRefApi.__init__c                 C  s   t | ddt | dd}}| d| d}}dD ]+}||kr"|nd }||kr*|nd }|du r7|du r7 dS |du r> dS |du rE dS qdS )NcopiesFr"   )clizenv varfiledefaultT)getattr
get_source)r%   r'   r"   copy_srcsym_srclevels_optc_optr   r   r   r!   #   s   zViaGlobalRefApi._should_symlinkc                   s   t  |||| |jdddddd |js|jsd}t|| }|jr0|jdd	dd
dd |jrB|jdd|j dddd d S d S )Nz--system-site-packagesF
store_truer#   zCgive the virtual environment access to the system site-packages dir)r*   actiondesthelpz(neither symlink or copy method supportedz
--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   RuntimeErroradd_mutually_exclusive_group)clsparserr&   metaapp_datamsggroupr   r   r   r6   4   s<   
z$ViaGlobalRefApi.add_parser_argumentsc                 C  s   |    d S r   )install_patchr   r   r   r   createT   s   zViaGlobalRefApi.createc                 C  s\   |   }|r,| jd }td| |jddd | jd }td| |j|dd d S d S )Nz_virtualenv.pthz%create virtualenv import hook file %szimport _virtualenvutf-8encoding_virtualenv.pyz	create %s)env_patch_textpurelibloggingdebug
write_text)r   textpth	dest_pathr   r   r   r@   W   s   

zViaGlobalRefApi.install_patchc              
   C  sl   | j ttjd !}|jdd}|dttj	
t| jt| jW  d   S 1 s/w   Y  dS )zJPatch the distutils package to not be derailed by its configuration files.rE   rB   rC   z"__SCRIPT_DIR__"N)r=   ensure_extractedr   __file__parent	read_textreplacereprospathrelpathstr
script_dirrG   )r   resolved_pathrK   r   r   r   rF   a   s   $$zViaGlobalRefApi.env_patch_textc                   s   g t   d| jfS )Nglobal)r   _argsr$   r   r   r   r   r[   g   s   zViaGlobalRefApi._argsc                   s"   t    | jr
dnd| jd< d S )Ntruefalsezinclude-system-site-packages)r   set_pyenv_cfgr$   	pyenv_cfgr   r   r   r   r^   j   s   
zViaGlobalRefApi.set_pyenv_cfgr   )r   r   r   r   staticmethodr!   classmethodr6   rA   r@   rF   r[   r^   r   r   r   r   r   r       s    

r    )
__future__r   rH   rT   abcr   pathlibr   virtualenv.create.creatorr   r   virtualenv.infor   r   r    __all__r   r   r   r   <module>   s    S