o
    f}”e  ã                   @   sÐ   d Z ddlZddlZej e¡Zdd„ ZdZej	dkr?ddl
mZ ddlmZ dd	lmZ G d
d„ deƒZej deƒ ¡ dS ddlmZ ddlmZmZ G dd„ deeƒZG dd„ deeƒZej eƒ ¡ dS )z>Patches that are applied at runtime to the virtual environmenté    Nc                    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                    sj   ˆ | g|¢R i |¤Ž}|   d¡}d|v rttj tj¡f|d< dD ]}d |¡}||v r2| |d ¡ q!|S )NÚinstallÚprefix)ZpurelibZplatlibZheadersZscriptsÚdataz
install_{})	Zget_option_dictÚVIRTUALENV_PATCH_FILEÚosÚpathÚabspathÚsysr   ÚformatÚpop)ÚselfÚargsÚkwargsÚresultr   ÚbaseÚkey©Zold_parse_config_files© úT/Users/abhinavbhinder/Documents/map/venv/lib/python3.10/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.dist)é   é   )Úpartial)ÚMetaPathFinder)Ú	find_specc                   @   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 )
Ú_FinderzFA meta path finder that allows patching the imported distutils modulesNc              	   C   s"  |t v r�| jd u r�t| jƒdkrdd l}| ¡ }| j |¡ | jd �` || _zOt||ƒ}|d urrt|j	dƒ}|r;dnd}t
|j	|ƒ}	|rH| jn| j}
|	|
urezt|j	|t|
|	ƒƒ W n	 tyd   Y nw |W d | _W  d   ƒ S W d | _nd | _w W d   ƒ d S 1 s†w   Y  d S d S d S )Nr   Úexec_moduleÚload_module)Ú_DISTUTILS_PATCHÚfullnameÚlenÚlockÚ	threadingZLockÚappendr   ÚhasattrÚloaderÚgetattrr   r   Úsetattrr   ÚAttributeError)r   r    r   Útargetr#   r"   ÚspecZ
is_new_apiZ	func_nameÚoldÚfuncr   r   r   r   6   s6   
ÿï"ïóz_Finder.find_specc                 C   s"   | |ƒ |j tv rt|ƒ d S d S ©N©Ú__name__r   r   )r,   Úmoduler   r   r   r   W   s   
ÿz_Finder.exec_modulec                 C   s   | |ƒ}|j tv rt|ƒ |S r.   r/   )r,   Únamer1   r   r   r   r   ]   s   
z_Finder.load_moduler.   )
r0   Ú
__module__Ú__qualname__Ú__doc__r    r"   r   Ústaticmethodr   r   r   r   r   r   r   ,   s    
!
r   )Úfind_module)ÚImpImporterÚ	ImpLoaderc                   @   s    e Zd Zddd„Zddd„ZdS )Ú_VirtualenvImporterNc                 C   s   t  | ¡ t | |¡ d S r.   )ÚobjectÚ__init__r8   )r   r   r   r   r   r<   k   s   
z_VirtualenvImporter.__init__c                 C   sD   |t v r zt|gt| d¡d |ƒ¢R Ž W S  ty   Y d S w d S )NÚ.éÿÿÿÿ)r   Ú_VirtualenvLoaderr7   ÚsplitÚImportError)r   r    r   r   r   r   r7   o   s   "þz_VirtualenvImporter.find_moduler.   )r0   r3   r4   r<   r7   r   r   r   r   r:   j   s    
r:   c                       s$   e Zd Zdd„ Z‡ fdd„Z‡  ZS )r?   c                 C   s    t  | ¡ t | ||||¡ d S r.   )r;   r<   r9   )r   r    ÚfileÚfilenameZetcr   r   r   r<   x   s   
z_VirtualenvLoader.__init__c                    s"   t t| ƒ |¡}t|ƒ d |_|S r.   )Úsuperr?   r   r   Ú
__loader__)r   r    r1   ©Ú	__class__r   r   r   |   s   z_VirtualenvLoader.load_module)r0   r3   r4   r<   r   Ú__classcell__r   r   rF   r   r?   w   s    r?   )r5   r   r	   r   ÚjoinÚ__file__r   r   r   Úversion_infoZ	functoolsr   Zimportlib.abcr   Zimportlib.utilr   r   Ú	meta_pathÚinsertZimpr7   Zpkgutilr8   r9   r;   r:   r?   r$   r   r   r   r   Ú<module>   s"    
8