o
    ZhM                     @   s   d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZddlm	Z	m
Z
 ejdd Zejdd Zejd	d
ddd Zejdd Zdd Zejd
ddd Zejd
ddd Zejdd Zejdd Zejdd ZdS )    N)Path   )contextsenvironmentc              
   c   s    t  H}| d| t  %}| d| t   dV  W d   n1 s)w   Y  W d   n1 s8w   Y  W d   dS W d   dS 1 sPw   Y  dS )za
    Override site.USER_BASE and site.USER_SITE with temporary directories in
    a context.
    zsite.USER_BASEzsite.USER_SITEN)r   tempdirsetattrZsave_user_site_setting)Zmonkeypatch	user_base	user_site r
   P/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/tests/fixtures.pyuser_override   s   


"r   c                 c   s6    |   }|V  W d    d S 1 sw   Y  d S )N)Zas_cwd)Ztmpdirorigr
   r
   r   
tmpdir_cwd   s   
"r   Tsession)Zautousescopec                 C   sN   | j jds	dS tt tjd W d   dS 1 s w   Y  dS )z
    Workaround pytest-dev/pytest-xdist#376

    ``pytest-xdist`` tends to inject '' into ``sys.path``,
    which may break certain isolation expectations.
    Remove the entry so the import
    machinery behaves the same irrespective of xdist.
    ZxdistN )	configZpluginmanagerZ
has_plugin
contextlibsuppress
ValueErrorsyspathremove)requestr
   r
   r   workaround_xdist_376!   s
   
"r   c                 C   sH   g d}zt j|t| d W | d S  ty#   td Y | d S w )z<
    Clone the 'sampleproject' and return a path to it.
    )gitclonez%https://github.com/pypa/sampleproject)cwdzUnable to clone sampleprojectZsampleproject)
subprocess
check_callstr	Exceptionpytestskip)tmp_pathcmdr
   r
   r   sample_project2   s   r&   c              
   C   s   t || d]}t|dd }t|dd }|r'|r'||fW  d    S t|jjd r2J t	t
jdddt|t|jjg t|jjd rOJ t|dt|dfW  d    S 1 sgw   Y  d S )NZ
dist_buildz*.tar.gzz*.whlzbuild/lib/buildz-mbuildz--outdir)r   Zsession_locked_tmp_dirnextglobr   r   rootdirexistsr   check_outputr   
executabler    )tmp_path_factoryr   tmpsdistwheelr
   r
   r   _build_distributionsG   s*   	

$r2   )r   c                 C   s8   t d}|rt j|rt| S t| |\}}|S )NZPRE_BUILT_SETUPTOOLS_SDISTosgetenvr   r+   r   resolver2   )r.   r   prebuiltr0   _r
   r
   r   setuptools_sdistb   
   
r9   c                 C   s8   t d}|rt j|rt| S t| |\}}|S )NZPRE_BUILT_SETUPTOOLS_WHEELr3   )r.   r   r7   r8   r1   r
   r
   r   setuptools_wheell   r:   r;   c                 C   sd   t  }t| d |_ddg|_t||_tj dd |	 W  d   S 1 s+w   Y  dS )z?Virtual env with the version of setuptools under test installedvenv--no-setuptoolsz--wheel=bundleN)
PYTHONPATH)
r   
VirtualEnvr   r   rootcreate_optsr    reqr   create)r$   r;   envr
   r
   r   r<   v   s   

$r<   c                 C   s.   t  }t| d |_ddg|_|  |S )z7Virtual env without any version of setuptools installedvenv_without_setuptoolsr=   
--no-wheelr   r?   r   r   r@   rA   Z
ensure_envr$   rD   r
   r
   r   rE      
   
rE   c                 C   s.   t  }t| d |_g d|_|  |S )z1Virtual env without any common packages installed	bare_venv)r=   z--no-piprF   z	--no-seedrG   rH   r
   r
   r   rJ      rI   rJ   )r   r4   r   r   pathlibr   r   r"   r   r   r   Zfixturer   r   r   r&   r2   r9   r;   r<   rE   rJ   r
   r
   r
   r   <module>   s6    






	
	

	