
    Oh29                        d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ ddlZd	d
lmZ  ej(                  d      d        Z ej(                  d      d        Z G d dej.                        Zy)z"Tests for distutils.unixccompiler.    N)	sysconfig)consolidate_linker_args)DistutilsPlatformError)support)EnvironmentVarGuard)_clear_cached_macosx_ver   )unixT)autousec                     | j                  t        dt        j                         | j                  t        dt        j                         | j                  t        dt        j
                         y )Nplatformget_config_varget_config_vars)setattrsysr   r   r   r   )monkeypatchs    /mnt/c/Users/Administrator/Desktop/help_/test_env/lib/python3.12/site-packages/setuptools/_distutils/compilers/C/tests/test_unix.pysave_valuesr      sJ    Z6	#3Y5M5MN	#4i6O6OP    c                 b     G d dt         j                        } |       | j                  _        y )Nc                       e Zd Zd Zy))compiler_wrapper.<locals>.CompilerWrapperc                 $    | j                  d      S )Nz/foo)runtime_library_dir_optionselfs    r   	rpath_fooz3compiler_wrapper.<locals>.CompilerWrapper.rpath_foo   s    226::r   N)__name__
__module____qualname__r    r   r   CompilerWrapperr      s    	;r   r"   )r
   Compilerinstancecc)requestr"   s     r   compiler_wrapperr'      s%    ;$-- ; *+Gr   c                      e Zd Zej                  j                  d      d        Zej                  j                  d      d        Zej                  j                  d      d        Zej                  j                  d      ej                  j                  d      d               Z
ej                  j                  d      d        Zd Zd	 Zy
)TestUnixCCompilerzplatform.system == "Windows"c                 V    dt         _        dd}d}d|fd|fd|fd|fd	|fd
|fd|fd|fd|fd|fd|fdg}fd fd}|D ]<  \  }}|\  }} ||||       |
 |d||       |
 ||d|       |0|3 |dd|       > t        j                  }	dt         _        d }
|
t        _         j                  j                         ddgk(  sJ d }
|
t        _         j                  j                         ddgk(  sJ d }
|
t        _         j                  j                         ddgk(  sJ |	t        _        dt         _        d }
|
t        _         j                  j                         t        ddg      k(  sJ d }
|
t        _         j                  j                         t        ddg      k(  sJ dt         _        d }
|
t        _         j                  j                         dk(  sJ dt         _        d  }
|
t        _         j                  j                         t        ddg      k(  sJ dt         _        d! }
|
t        _         j                  j                         t        ddg      k(  sJ dt         _        d" }
|
t        _         j                  j                         dk(  sJ y )#NdarwinMACOSX_DEPLOYMENT_TARGETz-Wl,-rpath,/fooz-L/foo)NN)N11)10N)10.3N)z10.3.1N)10.5N)z10.5.1N)r/   r/   )r/   r0   )r0   r/   )r0   r-   ))z10.4r.   Nc                       fd}|S )Nc                     | k(  rS yNxxxr!   )vardarwin_ver_varsyscfg_macosx_vers    r   gcvzRTestUnixCCompiler.test_runtime_libdir_option.<locals>.make_darwin_gcv.<locals>.gcvC   s    .(,,r   r!   )r7   r8   r6   s   ` r   make_darwin_gcvzETestUnixCCompiler.test_runtime_libdir_option.<locals>.make_darwin_gcvB   s    
 Jr   c                 4   t         j                  }d| d|d}t        j                  }|j	                        }t                 |       t        _        |||<   n|v r|j                         |$	j                  j                         |k(  sHJ |       t        j                  t        dz         5  	j                  j                          d d d        |||<   n|v r|j                         |t        _        t                y # 1 sw Y   <xY w)NzmacOS version = (sysconfig=z, env=)z	 mismatch)match)osenvironr   r   getr   popr%   r   pytestraisesr   )
r7   env_macosx_verexpected_flagenvmsgold_gcvold_env_macosx_verr6   r9   r   s
          r   do_darwin_testzDTestUnixCCompiler.test_runtime_libdir_option.<locals>.do_darwin_testJ   s   **C/0A/DF>J\\]^C  ..G!$!8 %&'67H'II$)&4N#3&' (ww((*m;@S@;]]*.<2O ( GG%%'( "-&8N#3&''.I$$&( (s   8DD zhp-uxc                      yr3   r!   vs    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv{       r   z+sc                      y)Ngccr!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rN   r   z-Wl,+sc                      y)Nzg++r!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rN   r   barc                     | dk(  ry| dk(  ryy )NCCrP   GNULDyesr!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   z-Wl,--enable-new-dtagsc                     | dk(  ry| dk(  ryy )NrT   zgcc -pthread -B /barrU   rV   r!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dy-g r   c                     | dk(  ry| dk(  ryy )NrT   rP   rU   nor!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   z
-Wl,-R/fooc                     | dk(  ry| dk(  ryy )NrT   zx86_64-pc-linux-gnu-gcc-4.4.2rU   rV   r!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dy6g r   c                     | dk(  ry| dk(  ryy )NrT   r%   rU   rV   r!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   c                     | dk(  ry| dk(  ryy )NrT   r%   rU   rY   r!   rL   s    r   r8   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   )r   r   r   r   r%   r   r   )r   darwin_rpath_flagdarwin_lib_flagdarwin_test_casesrI   macosx_versrD   r7   rC   rG   r8   r6   r9   s   `          @@r   test_runtime_libdir_optionz,TestUnixCCompiler.test_runtime_libdir_option#   s+     3-" ?+,-?+_-/./01/01/./"
		'B +< 		6&K0;-~,nmL (r>=A%0"mD (^-Cr2}5		6 ** 	 $'	 ww  "tX&6666	 $'	 ww  "x&::::	 $'	 ww  "x&::::#*	  	 $'	 ww  "&=$?
 '  	 
	 $'	 ww  "&=$?
 '  	  	 $'	 ww  "l222 	 $'	 ww  "&=$?
 '  	  	 $'	 ww  "&=$?
 '  	  	 $'	 ww  "l222r   c                 &   d }t         j                  dd}|t         _        |t         _        t               5 }d|d<   |d= t        j                  | j
                         d d d        | j
                  j                  d   dk(  sJ y # 1 sw Y   (xY w)Nc                     | dk(  ryyNLDSHARED*gcc-4.2 -bundle -undefined dynamic_lookup gcc-4.2r!   rL   s    r   r8   z9TestUnixCCompiler.test_cc_overrides_ldshared.<locals>.gcv       JCr   _origc                 Z    |r#t        t        t        j                  |            S  |        S Nlistmapr   r   rj   argss     r   gcvsz:TestUnixCCompiler.test_cc_overrides_ldshared.<locals>.gcvs   $    C	 8 8$?@@7Nr   my_ccrT   re   r   r   r   r   r   customize_compilerr%   	linker_sor   r8   rr   rE   s       r   test_cc_overrides_ldsharedz,TestUnixCCompiler.test_cc_overrides_ldshared   s    	
 (77 	
 $'	 $(	! " 	2cCIJ((1	2 ww  #w...		2 	2s   (BBc           
          d }t         j                  dd}|t         _        |t         _        t        j                  j                  | j                  dd       5 }t        j                  j                  | j                  dd      5  t        j                  j                  | j                  dd       5  t               5 }|d	= |d
= t        j                  | j                         | j                  j                  dd ddgk(  sJ | j                  j                  dd ddgk(  sJ | j                  j                  d g dd       |j                  d   d   }g d}|d d |k(  sJ | j                  j                  g dd       |j                  d   d   }ddd| j                  j                  d      g}|d d |k(  sJ d|d
<   d|d	<   t        j                  | j                         | j                  j                  dd ddgk(  sJ | j                  j                  dd ddgk(  sJ | j                  j                  d g dd       |j                  d   d   }g d}|d d |k(  sJ | j                  j                  g dd       |j                  d   d   }ddd| j                  j                  d      g}|d d |k(  sJ 	 d d 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   *xY w# 1 sw Y   y xY w)Nc                 4    | dk(  ry| dk(  ry| dk(  ry| dk(  ryy	)
Nre   z0ccache gcc-4.2 -bundle -undefined dynamic_lookupLDCXXSHAREDz0ccache g++-4.2 -bundle -undefined dynamic_lookupCXXzccache g++-4.2rT   zccache gcc-4.2rJ   r!   rL   s    r   r8   zATestUnixCCompiler.test_cxx_commands_used_are_correct.<locals>.gcv   s.    JIm#Ie'd'r   ri   c                 Z    |r#t        t        t        j                  |            S  |        S rl   rm   rp   s     r   rr   zBTestUnixCCompiler.test_cxx_commands_used_are_correct.<locals>.gcvs  rs   r   spawnreturn_value
_need_linkTmkpathr}   r|   r   r	   ccacheg++-4.2a.outc++target_lang)r   r   -bundle
-undefineddynamic_lookup   z-o   z1wrapper g++-4.2 -bundle -undefined dynamic_lookupzwrapper g++-4.2wrapper)r   r   r   r   r   )r   r   r   mockpatchobjectr%   r   rv   linker_so_cxxlinker_exe_cxxlink	call_argslink_executableexecutable_filenamer   r8   rr   
mock_spawnrE   r   expecteds          r   "test_cxx_commands_used_are_correctz4TestUnixCCompiler.test_cxx_commands_used_are_correct   s   		 (77 	
 $'	 $(	!JJdggwTB)	-FPJJdgg|$G)	- JJdggxdC)	-  !	)	- &) E
M"((177((1-(I1FFFF77))!A.8Y2GGGGGGLLr7L>",,Q/2IWHRa=H,,,GG##BU#C",,Q/2I )T4773N3Nw3WXHRa=H,,,!TC*CJ((177((1-)Y1GGGG77))!A.9i2HHHHGGLLr7L>",,Q/2IXHRa=H,,,GG##BU#C",,Q/2I++G4	H Ra=H,,,S)	- )	- )	- )	- )	- )	- )	- )	- )	- )	- )	- )	-sU   -L-K84K,?G?K 	?K,K8L K)%K,,K51K88L	=LLdisable_macos_customizationc           
      :   d }t         j                  dd}|t         _        |t         _        t        j                  j                  | j                  dd      5 }t        j                  j                  | j                  dd      5  t        j                  j                  | j                  d	d      5  t               5 }d
|d<   d|d<   |d= t        j                  | j                         | j                  j                  dd ddgk(  sJ | j                  j                  dg dd       |j                  d   d   }g d}|dd |k(  sJ 	 dd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   *xY w# 1 sw Y   yxY w)z
        Ensure that setting CC env variable also changes default linker
        correctly when building C++ extensions.

        pypa/distutils#126
        c                 4    | dk(  ry| dk(  ry| dk(  ry| dk(  ryy	)
Nre   rf   r|   z*g++-4.2 -bundle -undefined dynamic_lookup r}   r   rT   rg   rJ   r!   rL   s    r   r8   zKTestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly.<locals>.gcv@  s.    JCm#Ce d r   ri   c                 Z    |r#t        t        t        j                  |            S  |        S rl   rm   rp   s     r   rr   zLTestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly.<locals>.gcvsK  rs   r   r   Nr   r   Tr   zccache my_ccrT   my_cxxr}   re   r   r	   r   rt   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r%   r   rv   rw   r   r   r   s          r   ,test_cc_overrides_ldshared_for_cxx_correctlyz>TestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly6  s{   		 (77 	
 $'	 $(	!JJdggwTB	-FPJJdgg|$G	- JJdggxdC	-  !		- &)&CI!CJJ((177$$Qq)h-@@@@GGLLr7L>",,Q/2ILHRa=H,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-sU   -F-F4E9?BE-	E9FF-E62E99F>FF	
FFc                 *   d }t         j                  dd}|t         _        |t         _        t               5 }d|d<   d|d<   t        j                  | j
                         d d d        | j
                  j                  d   d	k(  sJ y # 1 sw Y   (xY w)
Nc                     | dk(  ryyrd   r!   rL   s    r   r8   z5TestUnixCCompiler.test_explicit_ldshared.<locals>.gcvg  rh   r   ri   c                 Z    |r#t        t        t        j                  |            S  |        S rl   rm   rp   s     r   rr   z6TestUnixCCompiler.test_explicit_ldshared.<locals>.gcvsl  rs   r   rt   rT   zmy_ld -bundle -dynamicre   r   my_ldru   rx   s       r   test_explicit_ldsharedz(TestUnixCCompiler.test_explicit_ldsharedb  s    
	
 (77 	
 $'	 $(	! " 	2cCI6C
O((1	2 ww  #w...		2 	2s   *B		Bc                     d| j                   _        t        j                  | j	                                | j                   j                  d       y )Nscratchabort)r%   
output_dirr=   chdirmkdtemphas_functionr   s    r   test_has_functionz#TestUnixCCompiler.test_has_functiony  s4     '
 W%r   c                 ^   t        j                         }d |_        |j                  t        j
                  dd        t        j                  dk7  rdnd}d}|j                  |d      j                  d	d
      d| k(  sJ |j                  t        |      d      j                  d	d
      d| k(  sJ |j                  t        j
                  dd        |j                  |d      j                  d	d
      dk(  sJ |j                  t        |      d      j                  d	d
      dk(  sJ y )Nc                     | S rl   r!   )dirs    r   <lambda>z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>  s    S r   existsc                 
    d| v S )Nexistingr!   ds    r   r   z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>  s
    q r   cygwinzlibabc.dylibz
cygabc.dll)z/foo/bar/missingz/foo/bar/existingabc\/z/foo/bar/existing/c                 "    d| v xr
 d| v xr d| vS )Nr   z.az.dll.ar!   r   s    r   r   z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>  s    jAoI$!)I8I r   z/foo/bar/existing/libabc.a)r
   r#   _library_rootr   r=   pathr   r   find_library_filereplacereversed)r   r   compilerlibnamedirss        r   test_find_library_filez(TestUnixCCompiler.test_find_library_file  s8   ==?!0BGGX/HI$'LLH$<.,8&&tU3;;D#F#G9-.	
. &&x~u=EEdCP#G9-.	
. 	GGI	
 &&tU3;;D#F+,	
, &&x~u=EEdCP+,	
,r   N)r   r   r    rA   markskipifra   ry   r   usefixturesr   r   r   r   r!   r   r   r)   r)   "   s    [[67{3 8{3z [[67/ 8/* [[67<- 8<-| [[67[[:;(- < 8(-T [[67/ 8/,&
r   r)   )__doc__r=   r   unittest.mockr   	distutilsr   distutils.compatr   distutils.errorsr   distutils.testsr   distutils.tests.compat.py39r   distutils.utilr   rA   rJ   r
   fixturer   r'   TempdirManagerr)   r!   r   r   <module>r      s}    ( 	 
   4 3 # ; 3   Q Q , ,{
.. {
r   