a
    6RhM                     @   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  ~}| d| t  J}| d| t   dV  W d   n1 sP0    Y  W d   n1 sn0    Y  W d   n1 s0    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
   O/opt/python-3.9.24/usr/lib/python3.9/site-packages/setuptools/tests/fixtures.pyuser_override   s    


r   c                 c   s2   |   }|V  W d    n1 s$0    Y  d S )N)Zas_cwd)Ztmpdirorigr
   r
   r   
tmpdir_cwd   s    
r   Tsession)Zautousescopec                 C   sL   | j jdsdS tt tjd W d   n1 s>0    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   sD   g d}zt j|t| d W n ty:   td Y n0 | d S )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 }|rN|rN||fW  d    S t|jjd rdJ t	t
jdddt|t|jjg t|jjd rJ t|dt|dfW  d    S 1 s0    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   s
    
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   s
    
r:   c                 C   sd   t  }t| d |_ddg|_t||_tj dd |	 W  d   S 1 sV0    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?   r@   Z
ensure_envr$   rC   r
   r
   r   rD      s
    
rD   c                 C   s.   t  }t| d |_g d|_|  |S )z1Virtual env without any common packages installed	bare_venv)r<   z--no-piprE   z	--no-seedrF   rG   r
   r
   r   rH      s
    
rH   )r   r4   r   r   pathlibr   r   r"   r   r   r   Zfixturer   r   r   r&   r2   r9   r:   r;   rD   rH   r
   r
   r
   r   <module>   s4   





	

	

	