
    9
gM                        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        Zej                  d        Z ej                  dd	      d
        Zej                  d        Zd Z ej                  d      d        Z ej                  d      d        Zej                  d        Zej                  d        Zej                  d        Zy)    N)Path   )contextsenvironmentc              #   R  K   t        j                         5 }| j                  d|       t        j                         5 }| j                  d|       t        j                         5  d ddd       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY ww)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_sites      Y/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/setuptools/tests/fixtures.pyuser_overrider      s      
			y,i89 0)<002 3   
	 32   
	sK   B''B'B%B*B2B:	B'BBB	BB$ B'c              #   ^   K   | j                         5 }| d d d        y # 1 sw Y   y xY ww)N)as_cwd)tmpdirorigs     r   
tmpdir_cwdr      s     	D
 
s   -!	-*-Tsession)autousescopec                     | j                   j                  j                  d      syt        j                  t
              5  t        j                  j                  d       ddd       y# 1 sw Y   yxY w)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)requests    r   workaround_xdist_376r%   !   sI     >>''227;			Z	( 
)	(	(s     A))A2c                     g d}	 t        j                  |t        |              | dz  S # t        $ r t	        j
                  d       Y | dz  S w xY 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cmds     r   sample_projectr3   2   sY    
 DC5cs8}5 o%%  534o%%5s    + AAc                    t        j                  || d      5 }t        |j                  d      d       }t        |j                  d      d       }|r|r||fcd d d        S t	        |j
                  j                  d      j                         rJ t        j                  t        j                  dddt        |      t        |j
                  j                        g       t	        |j
                  j                  d      j                         rJ t        |j                  d            t        |j                  d            fcd d d        S # 1 sw Y   y xY w)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wheels        r   _build_distributionsrB   G   s   		(	(!<
	SXXj)40SXXg&-U5>
 
 ..0ABIIKKKNNH&&'!
 	 ..0ABIIKKKCHHZ()40A+BB/
 
 
s   >E C"EE)r   c                     t        j                  d      }|r8t         j                  j                  |      rt	        |      j                         S t        | |      \  }}|S )NPRE_BUILT_SETUPTOOLS_SDISTosgetenvr"   r;   r   resolverB   )r>   r$   prebuiltr@   _s        r   setuptools_sdistrK   b   sL    yy56HBGGNN8,H~%%''#$4g>HE1L    c                     t        j                  d      }|r8t         j                  j                  |      rt	        |      j                         S t        | |      \  }}|S )NPRE_BUILT_SETUPTOOLS_WHEELrE   )r>   r$   rI   rJ   rA   s        r   setuptools_wheelrO   l   sL    yy56HBGGNN8,H~%%''#$4g>HAuLrL   c                    t        j                         }t        j                  | dz        |_        ddg|_        t        |      |_        t        j                   d      5  |j                         cddd       S # 1 sw Y   yxY w)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)r1   rO   envs      r   rQ   rQ   v   sf     
 
 
"CyyF*+CH(*:;CO"#CG 
			.zz| 
/	.	.s   !A;;Bc                     t        j                         }t        j                  | dz        |_        ddg|_        |j                          |S )z7Virtual env without any version of setuptools installedvenv_without_setuptoolsrR   
--no-wheelr   rT   r"   r   rU   rV   
ensure_envr1   rY   s     r   r[   r[      sC     
 
 
"Cyy$==>CH(,7CONNJrL   c                     t        j                         }t        j                  | dz        |_        g d|_        |j                          |S )z1Virtual env without any common packages installed	bare_venv)rR   z--no-pipr\   z	--no-seedr]   r_   s     r   ra   ra      s=     
 
 
"CyyK/0CHPCONNJrL   )r   rF   r+   r!   pathlibr   r"   r/   r   r   r   fixturer   r   r%   r3   rB   rK   rO   rQ   r[   ra    rL   r   <module>re      s    	  
    # 
 
  
 I. /  	& 	&(C6 i  ! i  !  *    rL   