o
    !gM                     @   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setattrsave_user_site_setting)monkeypatch	user_base	user_site r   X/root/parts/websockify/install/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)as_cwd)tmpdirorigr   r   r   
tmpdir_cwd   s   
"r   Tsession)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.
    xdistN )	configpluginmanager
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 sampleproject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 )N
dist_buildz*.tar.gzz*.whlzbuild/lib/buildz-mbuildz--outdir)r   session_locked_tmp_dirnextglobr   r   rootdirexistsr'   check_outputr   
executabler)   )tmp_path_factoryr!   tmpsdistwheelr   r   r   _build_distributionsG   s*   	

$r=   )r   c                 C   s8   t d}|rt j|rt| S t| |\}}|S )NPRE_BUILT_SETUPTOOLS_SDISTosgetenvr   r6   r   resolver=   )r9   r!   prebuiltr;   _r   r   r   setuptools_sdistb   
   
rE   c                 C   s8   t d}|rt j|rt| S t| |\}}|S )NPRE_BUILT_SETUPTOOLS_WHEELr?   )r9   r!   rC   rD   r<   r   r   r   setuptools_wheell   rF   rH   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-   rH   envr   r   r   rI   v   s   

$rI   c                 C   s.   t  }t| d |_ddg|_|  |S )z7Virtual env without any version of setuptools installedvenv_without_setuptoolsrJ   
--no-wheelr   rL   r   r   rM   rN   
ensure_envr-   rQ   r   r   r   rR      
   
rR   c                 C   s.   t  }t| d |_g d|_|  |S )z1Virtual env without any common packages installed	bare_venv)rJ   z--no-piprS   z	--no-seedrT   rV   r   r   r   rX      rW   rX   )r   r@   r'   r   pathlibr   r   r+   r   r   r   fixturer   r   r"   r/   r=   rE   rH   rI   rR   rX   r   r   r   r   <module>   s6    






	
	

	