a
    h,Me                     @  sf   d Z ddlmZ ddlZddlZddlm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.    )annotationsN)suppressc                   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 rB||d  qB|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 :/var/www/webapp/lib/python3.9/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  sH  |t v rD| jd u rDt| jdkr@dd l}| }| j| ddlm} ddl	m
} | jd  || _z|||}|d urt|jd}	|	rdnd}
t|j|
}|	r| jn| j}||urtt$ t|j|
||| W d    n1 s0    Y  |W d | _W  d    S W d | _nd | _0 W d    n1 s:0    Y  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   r   AttributeErrorsetattr)r   r   r	   targetr!   r    r   r   specZ
is_new_apiZ	func_nameoldfuncr   r   r   r   5   s0    


20z_Finder.find_specc                 C  s   | | |j tv rt| d S N__name__r   r   )r*   moduler   r   r   r   X   s    
z_Finder.exec_modulec                 C  s   | |}|j tv 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   )r3   Z
__future__r   r   r   Z
contextlibr   r	   join__file__r   r   r   r   	meta_pathinsertr   r   r   r   <module>   s   ;