o
    IBe                     @   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,G dd d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 L/home/www/facesmatcher.com/frenv/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)      c                   @   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 rt| jdkrdd l}| }| j| ddlm} ddl	m
} | jd ` || _zO|||}|d ur~t|jd}	|	rGdnd}
t|j|
}|	rT| jn| j}||urqzt|j|
||| W n	 typ   Y nw |W d | _W  d    S W d | _nd | _w W d    d S 1 sw   Y  d S d S 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   3   s:   
"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+   namer0   r   r   r   r   ]   s   
z_Finder.load_moduler-   )
r/   
__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__r7   )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   _VirtualenvLoaderr6   splitImportError)r   r   r   r   r   r   r6   o   s   "z_VirtualenvImporter.find_moduler-   )r/   r2   r3   r;   r6   r   r   r   r   r9   j   s    
r9   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;   r8   )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   r0   	__class__r   r   r   |   s   z_VirtualenvLoader.load_module)r/   r2   r3   r;   r   __classcell__r   r   rE   r   r>   w   s    r>   )r4   r   r	   r   join__file__r   r   r   version_infor   	meta_pathinsertZimpr6   Zpkgutilr7   r8   r:   r9   r>   r#   r   r   r   r   <module>   s    
;