
    ?wg;.                        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Zdd	lm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)UnixCCompiler)_clear_cached_macosx_ver   )support)EnvironmentVarGuardT)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    e/var/www/horilla/myenv/lib/python3.12/site-packages/setuptools/_distutils/tests/test_unixccompiler.pysave_valuesr      sJ    Z6	#3Y5M5MN	#4i6O6OP    c                 N     G d dt               } |       | 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   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      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.   r/   )r/   r.   )r/   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!   )r6   r7   r5   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   )
r6   env_macosx_verexpected_flagenvmsgold_gcvold_env_macosx_verr5   r8   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r2   r!   vs    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv{       r   z+sc                      y)Ngccr!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rM   r   z-Wl,+sc                      y)Nzg++r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rM   r   barc                     | dk(  ry| dk(  ryy )NCCrO   GNULDyesr!   rK   s    r   r7   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 )NrS   zgcc -pthread -B /barrT   rU   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dy-g r   c                     | dk(  ry| dk(  ryy )NrS   rO   rT   nor!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   z
-Wl,-R/fooc                     | dk(  ry| dk(  ryy )NrS   zx86_64-pc-linux-gnu-gcc-4.4.2rT   rU   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dy6g r   c                     | dk(  ry| dk(  ryy )NrS   r$   rT   rU   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s    Dyg r   c                     | dk(  ry| dk(  ryy )NrS   r$   rT   rX   r!   rK   s    r   r7   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_casesrH   macosx_versrC   r6   rB   rF   r7   r5   r8   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!   rK   s    r   r7   z9TestUnixCCompiler.test_cc_overrides_ldshared.<locals>.gcv       JCr   _origc                 Z    |r#t        t        t        j                  |            S  |        S Nlistmapr   r   ri   argss     r   gcvsz:TestUnixCCompiler.test_cc_overrides_ldshared.<locals>.gcvs   $    C	 8 8$?@@7Nr   my_ccrS   rd   r   r   r   r   r
   customize_compilerr$   	linker_sor   r7   rq   rD   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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	)
Nrd   re   LDCXXSHAREDz*g++-4.2 -bundle -undefined dynamic_lookup CXXzg++-4.2rS   rf   rI   r!   rK   s    r   r7   zKTestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly.<locals>.gcv  s.    JCm#Ce d r   rh   c                 Z    |r#t        t        t        j                  |            S  |        S rk   rl   ro   s     r   rq   zLTestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly.<locals>.gcvs  rr   r   spawnN)return_value
_need_linkTmkpathzccache my_ccrS   my_cxxr}   rd   r      ccachers   za.outzc++)target_lang)r   z-bundlez
-undefineddynamic_lookup   )r   r   r   mockpatchobjectr$   r
   ru   rv   link	call_args)r   r7   rq   
mock_spawnrD   r   expecteds          r   ,test_cc_overrides_ldshared_for_cxx_correctlyz>TestUnixCCompiler.test_cc_overrides_ldshared_for_cxx_correctly   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rc   r!   rK   s    r   r7   z5TestUnixCCompiler.test_explicit_ldshared.<locals>.gcv(  rg   r   rh   c                 Z    |r#t        t        t        j                  |            S  |        S rk   rl   ro   s     r   rq   z6TestUnixCCompiler.test_explicit_ldshared.<locals>.gcvs-  rr   r   rs   rS   zmy_ld -bundle -dynamicrd   r   my_ldrt   rw   s       r   test_explicit_ldsharedz(TestUnixCCompiler.test_explicit_ldshared#  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_function:  s4     '
 W%r   c                 J   t               }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 rk   r!   )dirs    r   <lambda>z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>D  s    S r   existsc                 
    d| v S )Nexistingr!   ds    r   r   z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>E  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>U  s    jAoI$!)I8I r   z/foo/bar/existing/libabc.a)
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_fileB  s4    ?!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    r@   markskipifr`   rx   usefixturesr   r   r   r   r!   r   r   r(   r(   "   s    [[67{3 8{3z [[67/ 8/* [[67[[:;(- < 8(-T [[67/ 8/,&
r   r(   )__doc__r<   r   unittest.mockr   	distutilsr   distutils.compatr   distutils.errorsr   distutils.unixccompilerr   distutils.utilr   r@   rI   r	   compat.py39r
   fixturer   r&   TempdirManagerr(   r!   r   r   <module>r      s}    ( 	 
   4 3 1 3   , Q Q , ,|
.. |
r   