
    ϶vg@.                        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dS )z"Tests for distutils.unixccompiler.    N)	sysconfig)consolidate_linker_args)DistutilsPlatformError)UnixCCompiler)_clear_cached_macosx_ver   )support)EnvironmentVarGuardT)autousec                     |                      t          dt          j                   |                      t          dt          j                   |                      t          dt          j                   d S )Nplatformget_config_varget_config_vars)setattrsysr   r   r   r   )monkeypatchs    k/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/_distutils/tests/test_unixccompiler.pysave_valuesr      sZ    Z666	#3Y5MNNN	#4i6OPPPPP    c                 T     G d dt                     } |            | j        _        d S )Nc                       e Zd Zd ZdS ))compiler_wrapper.<locals>.CompilerWrapperc                 ,    |                      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&      sG    ; ; ; ; ;- ; ; ; */++Gr   c                   r   e Zd Zej                            d          d             Zej                            d          d             Zej                            d          ej                            d          d                         Z	ej                            d          d             Z
d Zd Zd	S )
TestUnixCCompilerzplatform.system == "Windows"c                     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 ]F\  }}|\  }} ||||           | |d||           | ||d|           || |dd|           Gt          j        }	dt           _        d }
|
t          _         j                                        ddgk    sJ d }
|
t          _         j                                        ddgk    sJ d }
|
t          _         j                                        ddgk    sJ |	t          _        dt           _        d }
|
t          _         j                                        t          ddg          k    sJ d }
|
t          _         j                                        t          ddg          k    sJ dt           _        d }
|
t          _         j                                        dk    sJ dt           _        d  }
|
t          _         j                                        t          ddg          k    sJ dt           _        d! }
|
t          _         j                                        t          ddg          k    sJ dt           _        d" }
|
t          _         j                                        dk    sJ d S )#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 dS Nxxxr!   )vardarwin_ver_varsyscfg_macosx_vers    r   gcvzRTestUnixCCompiler.test_runtime_libdir_option.<locals>.make_darwin_gcv.<locals>.gcvC   s    .((,,ur   r!   )r6   r7   r5   s   ` r   make_darwin_gcvzETestUnixCCompiler.test_runtime_libdir_option.<locals>.make_darwin_gcvB   s)         
 Jr   c                 d   t           j        }d| d|d}t          j        }|                              }t                        |           t          _        |||<   n|v r|                               |(	j                                        |k    s
J |            nOt          j
        t          dz             5  	j                                         d d d            n# 1 swxY w Y   |||<   n|v r|                               |t          _        t                       d S )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^^>^^^C  .G!$!8!8 %&&&'67H'I'II$)&4N##3&&''' (w((**m;;;S;;;;]*.<2O   ( ( G%%'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "-&8N##3&&''''.I$$&&&&&s   C**C.1C. zhp-uxc                     dS r2   r!   vs    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv{       5r   z+sc                     dS )Ngccr!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rM   r   z-Wl,+sc                     dS )Nzg++r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   rM   r   barc                 &    | dk    rdS | dk    rdS d S )NCCrO   GNULDyesr!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s%    Dyyugu r   z-Wl,--enable-new-dtagsc                 &    | dk    rdS | dk    rdS d S )NrS   zgcc -pthread -B /barrT   rU   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s&    Dyy--gu r   c                 &    | dk    rdS | dk    rdS d S )NrS   rO   rT   nor!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s%    Dyyugt r   z
-Wl,-R/fooc                 &    | dk    rdS | dk    rdS d S )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&    Dyy66gu r   c                 &    | dk    rdS | dk    rdS d S )NrS   r$   rT   rU   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s%    Dyytgu r   c                 &    | dk    rdS | dk    rdS d S )NrS   r$   rT   rX   r!   rK   s    r   r7   z9TestUnixCCompiler.test_runtime_libdir_option.<locals>.gcv   s%    Dyytgt 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 		6&K0;-~N,nmLLL (r>=AAA%0"mDDD (^-Cr2}555* 	 	 	 $'	 w  ""tX&66666	 	 	 $'	 w  ""x&:::::	 	 	 $'	 w  ""x&:::::#*	  	 	 	 $'	 w  ""&=$?
 ' '    
	 	 	 $'	 w  ""&=$?
 ' '     	 	 	 $'	 w  ""l2222 	 	 	 $'	 w  ""&=$?
 ' '     	 	 	 $'	 w  ""&=$?
 ' '     	 	 	 $'	 w  ""l222222r   c                    d }t           j        dd}|t           _        |t           _        t                      5 }d|d<   |d= t          j        | j                   d d d            n# 1 swxY w Y   | j        j        d         dk    sJ d S )Nc                     | dk    rdS dS 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C9r   _origc                 h    |r't          t          t          j        |                    S  |             S Nlistmapr   r   ri   argss     r   gcvsz:TestUnixCCompiler.test_cc_overrides_ldshared.<locals>.gcvs   1     AC	 8$??@@@577Nr   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 	 	 	 	 	
 $'	 $(	! "" 	2cCIJ(111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 w #w......s   "A((A,/A,disable_macos_customizationc           
      4   d }t           j        dd}|t           _        |t           _        t          j                            | j        dd          5 }t          j                            | j        dd          5  t          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        
                    dg dd           |j        d         d         }g d}|dd         |k    sJ 	 ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z
        Ensure that setting CC env variable also changes default linker
        correctly when building C++ extensions.

        pypa/distutils#126
        c                 F    | dk    rdS | dk    rdS | dk    rdS | dk    rdS d	S )
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  sC    JCCm##CCe yd y2r   rh   c                 h    |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 	 	 	 	 	
 $'	 $(	!ZGW4  
 
 	-**G\ + 
 
	- 	- :GXD  
 
		- 	-   	- %(&CI!CJJ(1117$QqS)h-@@@@@GLLr7L>>>",Q/2ILLLHRaR=H,,,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   (F;(E5#E2BE	;EEEEEE5E""E5%E"&E5)F5E9	9F<E9	=FFFc                    d }t           j        dd}|t           _        |t           _        t                      5 }d|d<   d|d<   t          j        | j                   d d d            n# 1 swxY w Y   | j        j        d         d	k    sJ d S )
Nc                     | dk    rdS dS rc   r!   rK   s    r   r7   z5TestUnixCCompiler.test_explicit_ldshared.<locals>.gcv)  rg   r   rh   c                 h    |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 	 	 	 	 	
 $'	 $(	! "" 	2cCI6C
O(111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 w #w......s   $A**A.1A.c                     d| j         _        t          j        |                                            | j                             d           d S )Nscratchabort)r$   
output_dirr<   chdirmkdtemphas_functionr   s    r   test_has_functionz#TestUnixCCompiler.test_has_function;  sB     '
   W%%%%%r   c                    t                      }d |_        |                    t          j        dd            t
          j        dk    rdnd}d}|                    |d                              d	d
          d| k    sJ |                    t          |          d                              d	d
          d| k    sJ |                    t          j        dd            |                    |d                              d	d
          dk    sJ |                    t          |          d                              d	d
          dk    sJ d S )Nc                     | S rk   r!   )dirs    r   <lambda>z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>E  s    S r   existsc                 
    d| v S )Nexistingr!   ds    r   r   z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>F  s
    q r   cygwinzlibabc.dylibz
cygabc.dll)z/foo/bar/missingz/foo/bar/existingabc\/z/foo/bar/existing/c                     d| v od| v od| vS )Nr   z.az.dll.ar!   r   s    r   r   z:TestUnixCCompiler.test_find_library_file.<locals>.<lambda>V  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_fileC  s    ??!0BGX/H/HIII$'LH$<$<..,8&&tU33;;D#FF-G--. . . . &&x~~u==EEdCPP-G--. . . . 	GII	
 	
 	
 &&tU33;;D#FF+, , , , &&x~~u==EEdCPP+, , , , , ,r   N)r   r   r    r@   markskipifr`   rx   usefixturesr   r   r   r   r!   r   r   r(   r(   "   s       [677{3 {3 87{3z [677/ / 87/* [677[:;;)- )- <; 87)-V [677/ / 87/,& & &
 
 
 
 
r   r(   )__doc__r<   r   unittest.mockr   	distutilsr   distutils.compatr   distutils.errorsr   distutils.unixccompilerr   distutils.utilr   r@   rI   r	   compat.py38r
   fixturer   r&   TempdirManagerr(   r!   r   r   <module>r      sP   ( ( 				 



             4 4 4 4 4 4 3 3 3 3 3 3 1 1 1 1 1 1 3 3 3 3 3 3        , , , , , , Q Q Q , , ,}
 }
 }
 }
 }
. }
 }
 }
 }
 }
r   