U
    £@Ûf[  ã                   @  sZ   d Z ddlmZ ddlZddlZej e¡Zdd„ Z	dZ
G dd„ dƒZej deƒ ¡ dS )	z?Patches that are applied at runtime to the virtual environment.é    )ÚannotationsNc                   s    | j j‰ ‡ fdd„}|| j _dS )a  
    Distutils allows user to configure some arguments via a configuration file:
    https://docs.python.org/3/install/index.html#distutils-configuration-files.

    Some of this arguments though don't make sense in context of the virtual environment files, let's fix them up.
    c                   sd   ˆ | f|ž|Ž}|   d¡}d|kr8ttj tj¡f|d< dD ]"}d|› �}||kr<| |d ¡ q<|S )NÚinstallÚprefix)ZpurelibZplatlibZheadersZscriptsÚdataZinstall_)Zget_option_dictÚVIRTUALENV_PATCH_FILEÚosÚpathÚabspathÚsysr   Úpop)ÚselfÚargsÚkwargsÚresultr   ÚbaseÚkey©Zold_parse_config_files© úE/var/www/html/chatgpt/venv/lib/python3.8/site-packages/_virtualenv.pyÚparse_config_files   s    

z&patch_dist.<locals>.parse_config_filesN)ZDistributionr   )Zdistr   r   r   r   Ú
patch_dist   s    r   )zdistutils.distzsetuptools.distc                   @  s:   e Zd ZdZdZg Zd	dd„Zedd„ ƒZedd„ ƒZ	dS )
Ú_FinderzGA meta path finder that allows patching the imported distutils modules.Nc              
   C  s  |t k�r| jd k�rt| jƒdkr@dd l}| ¡ }| j |¡ ddlm} ddl	m
} | jd �ª || _z”|||ƒ}|d k	rüt|jdƒ}	|	r’dnd}
t|j|
ƒ}|	r¬| jn| j}||k	rèzt|j|
|||ƒƒ W n tk
ræ   Y nX |W ¢W  5 Q R £ S W 5 d | _X W 5 Q R X d S )Nr   )Úpartial)Ú	find_specÚexec_moduleÚload_module)Ú_DISTUTILS_PATCHÚfullnameÚlenÚlockÚ	threadingZLockÚappendZ	functoolsr   Zimportlib.utilr   ÚhasattrÚloaderÚgetattrr   r   ÚsetattrÚAttributeError)r   r   r   Útargetr    r   r   r   ÚspecZ
is_new_apiZ	func_nameÚoldÚfuncr   r   r   r   4   s0    
z_Finder.find_specc                 C  s   | |ƒ |j tkrt|ƒ d S ©N©Ú__name__r   r   )r)   Úmoduler   r   r   r   Y   s    
z_Finder.exec_modulec                 C  s   | |ƒ}|j tkrt|ƒ |S r+   r,   )r)   Únamer.   r   r   r   r   _   s    
z_Finder.load_module)N)
r-   Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ústaticmethodr   r   r   r   r   r   r   *   s   
%
r   )r2   Z
__future__r   r   r
   r   ÚjoinÚ__file__r   r   r   r   Ú	meta_pathÚinsertr   r   r   r   Ú<module>   s   =