
    G/Ph,                        d dl Z d dlZd dlZd dlmZmZ d dlmZmZ d dl	Z
d dlmZ d dlmZmZmZ d dlmZmZ d dlmZmZmZ d dlmZ d d	lmZmZ d d
lmZ 	 e
j                            d          dk    r ej        dd           n# e
j        j        $ r Y nw xY wd dZ da!tB          a"dZ#d Z$ e$            Z% G d de          Z& G d de&          Z' G d de&          Z( G d de&          Z) G d d          Z*d Z+dS )!    N)mkstempmkdtemp)PopenPIPE)DistutilsError)assert_assert_equalassert_raises)	ccompilercustomized_ccompiler)system_infoConfigParsermkl_info)AliasedOptionError)default_lib_dirsdefault_include_dirs)_shell_utils
setuptools60zsetuptools is too newT)allow_module_level   c                     t           t          t          d                    |                                 t
                    } |            S )zg
    notfound_action:
      0 - do nothing
      1 - display warning message
      2 - raise error
    )temp1temp2duplicate_options)	Temp1Info	Temp2InfoDuplicateOptionInfogetlower_system_info)namenotfound_actioncls      f/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpy/distutils/tests/test_system_info.py	get_classr&      sB     2
 
 C

l++  244K    a  
[ALL]
library_dirs = {dir1:s}{pathsep:s}{dir2:s}
libraries = {lib1:s},{lib2:s}
extra_compile_args = -I/fake/directory -I"/path with/spaces" -Os
runtime_library_dirs = {dir1:s}

[temp1]
library_dirs = {dir1:s}
libraries = {lib1:s}
runtime_library_dirs = {dir1:s}

[temp2]
library_dirs = {dir2:s}
libraries = {lib2:s}
extra_link_args = -Wl,-rpath={lib2_escaped:s}
rpath = {dir2:s}

[duplicate_options]
mylib_libs = {lib1:s}
libraries = {lib2:s}
z
/* This file is generated from numpy/distutils/testing/test_system_info.py */
#include<stdio.h>
void foo(void) {
   printf("Hello foo");
}
void bar(void) {
   printf("Hello bar");
}
c                     t                      } 	 | j        }nN# t          $ rA 	 | j        s|                                  n# t
          t          f$ r Y Y dS w xY w| j        g}Y nw xY w	 t          |t          t                    }|j
                                         |j                                         |                                 n# t          $ r Y dS w xY wdS )z? Return True if there appears to be an executable compiler
    F)stdoutstderrT)r   compilerAttributeErrorinitialized
initializer   
ValueErrorccr   r   r)   closer*   waitOSError)r+   cmdps      r%   have_compilerr6   K   s    $%%H   	' &##%%%
+ 	 	 	555	{m#d4000			   uu4sB    
A#?A#AA#AA#"A#'A"C
 

CCc                   "    e Zd ZeedfdZd ZdS )r!   r   c           	      j    i | j         _        g | _        ddddddddd}t          |          | _        d S )N 0)library_dirsinclude_dirsruntime_library_dirsrpathsrc_dirssearch_static_firstextra_compile_argsextra_link_args)	__class__infolocal_prefixesr   cp)selfr   r   	verbositydefaultss        r%   __init__z_system_info.__init__g   sO    
 ! $&$&,. "+.*,')+ + x((r'   c                     ||d}|S )z-Override _check_libs to return with all dirs )	librariesr;    )rG   lib_dirslibsopt_libsextsrD   s         r%   _check_libsz_system_info._check_libsz   s    !8<<r'   N)__name__
__module____qualname__r   r   rJ   rR   rM   r'   r%   r!   r!   e   sB         #3&:) ) ) )&    r'   r!   c                       e Zd ZdZdZdS )r   For testing purposesr   NrS   rT   rU   __doc__sectionrM   r'   r%   r   r              GGGr'   r   c                       e Zd ZdZdZdS )r   rW   r   NrX   rM   r'   r%   r   r      r[   r'   r   c                       e Zd ZdZdZdS )r   rW   r   NrX   rM   r'   r%   r   r      s        !GGGr'   r   c                      e Zd Zd Zd Zd Zd Zd Zd Ze	j
                            e d          d	             Ze	j
                            e d          e	j
                            d
 e ej                              v d          d                         Zd e                                                                dg           v Ze	j
                            ed          d             ZdS )TestSystemInfoReadingc                 p   t                      | _        t          j                            | j        d          | _        t          j                            | j        d          | _        t                      | _        t          j                            | j        d          | _        t          j                            | j        d          | _	        t          j        di | j        | j        | j        | j	        t          j        t          j                            | j	        g          dat!                      \  }| _        t          j        |           t'          | j        d          5 }|                    t                     ddd           n# 1 swxY w Y   t'          | j        d          5 }|                    t*                     ddd           n# 1 swxY w Y   t'          | j        d          5 }|                    t*                     ddd           n# 1 swxY w Y   d } |t-          d	          | j                  | _         |t-          d
          | j                  | _         |t-          d          | j                  | _         |t-          d          | j                  | _        dS )z Create the libraries zfoo.cz	libfoo.sozbar.cz	libbar.so)dir1lib1dir2lib2pathseplib2_escapedwNc                 >    |g| _         |                                  | S N)filesparse_config_files)csite_cfgs     r%   site_and_parsez:TestSystemInfoReading.setup_method.<locals>.site_and_parse   s"    jAG  """Hr'   defaultr   r   r   rM   )r   _dir1ospathjoin_src1_lib1_dir2_src2_lib2simple_siteformatre   r   NativeParserrm   r   _sitecfgr1   openwritefakelib_c_textr&   	c_defaultc_temp1c_temp2c_dup_options)rG   fdrn   s      r%   setup_methodz"TestSystemInfoReading.setup_method   s    YY
W\\$*g66
W\\$*k::
YY
W\\$*g66
W\\$*k::
 %  JJJJz(5::DJ<HH)
 )
   $IIDM
$-%% 	HHX	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 $*c"" 	%bHH^$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%$*c"" 	%bHH^$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%	 	 	 (	)(<(<dmLL%~i&8&8$-HH%~i&8&8$-HH+^I6I,J,J,0M; ;s6   'FFF.GGG5HH #H c                    	 t          j        | j                   n# t          $ r Y nw xY w	 t          j        | j                   n# t          $ r Y nw xY w	 t          j        | j                   d S # t          $ r Y d S w xY wri   )shutilrmtreerp   	Exceptionrv   rq   remover|   )rG   s    r%   teardown_methodz%TestSystemInfoReading.teardown_method   s    	M$*%%%% 	 	 	D		M$*%%%% 	 	 	D		Idm$$$$$ 	 	 	DD	s/    
))A 
AAA3 3
B Bc                 t   | j         }t          |                                | j        | j        g           t          |                                | j        | j        g           t          |                                | j        g           |	                                }t          |d         g d           d S )NrA   )z-I/fake/directoryz-I/path with/spacesz-Os)
r   r	   get_lib_dirsrp   rv   get_librariesru   rx   get_runtime_lib_dirscalc_extra_inforG   tsiextras      r%   test_allzTestSystemInfoReading.test_all   s    nS%%''$*dj)ABBBS&&((4:tz*BCCCS--//$*>>>##%%U/02e2e2efffffr'   c                    | j         }t          |                                | j        g           t          |                                | j        g           t          |                                | j        g           d S ri   )r   r	   r   rp   r   ru   r   rG   r   s     r%   
test_temp1z TestSystemInfoReading.test_temp1   so    lS%%''$*666S&&((4:,777S--//$*>>>>>r'   c                 n   | j         }t          |                                | j        g           t          |                                | j        g           t          |                    d          | j        g           |                                }t          |d         d| j        z   g           d S )Nr>   )keyrB   z-Wl,-rpath=)r   r	   r   rv   r   rx   r   r   r   s      r%   
test_temp2z TestSystemInfoReading.test_temp2   s    lS%%''$*666S&&((4:,777S--'-::TZLIII##%%U,-
0J/KLLLLLr'   c                    | j         }t          t          |j        dd           t	          |                    d| j        g          | j        g           t	          |                    d| j        g          | j        g           d S )N
mylib_libsrL   )r   r
   r   get_option_singler	   get_libsru   rx   r   s     r%   test_duplicate_optionsz,TestSystemInfoReading.test_duplicate_options   st     (#*?{[[[S\\,==
|LLLS\\+
|<<tzlKKKKKr'   zMissing compiler)reasonc                 N   t                      }t          j                    }	 t          j        | j                   |                    t          j                            | j                  g| j                   t          t          j        
                    | j                            dd                    p7t          j        
                    | j                            dd                               t          j        |           d S # t          j        |           w xY w)N)
output_dir.c.oz.obj)r   rq   getcwdchdirrp   compilerr   basenamert   r   isfilereplace)rG   rl   previousDirs      r%   test_compile1z#TestSystemInfoReading.test_compile1   s     !""ikk	"HTZ   IIrw''
334ILLLBGNN4:#5#5dD#A#ABB EGNN4:#5#5dF#C#CDDF F F H[!!!!!BH[!!!!s   CD D$msvczFails with MSVC compiler c                 "   | j         }t                      }|                                d         }t          j                    }	 t          j        | j                   |                    t          j        	                    | j
                  g| j        |           t          t          j                            | j
                            dd                               t          j        |           d S # t          j        |           w xY w)NrB   )r   extra_postargsr   r   )r   r   r   rq   r   r   rv   r   rr   r   rw   r   r   r   )rG   r   rl   rB   r   s        r%   test_compile2z#TestSystemInfoReading.test_compile2   s    
 l ""--//0ABikk	"HTZ   IIrw''
334%4  6 6 6 BGNN4:#5#5dD#A#ABBCCCH[!!!!!BH[!!!!s   BC8 8Dmkl_rtrL   zD`[DEFAULT]` override doesn't work if numpy is built with MKL supportc                    t          j                    }t           j                            | j        d          }t          j        | j        |           	 t          j        | j                   t                      }|j
        d         d                             t           j                  }|                                |k    sJ t          |          5 }|                                                    ddd          }d d d            n# 1 swxY w Y   t          |d          5 }|                    |           d d d            n# 1 swxY w Y   t                      }|                                |k    sJ t          |          5 }|                                                    ddd          }d d d            n# 1 swxY w Y   t          |d          5 }|                    |           d d d            n# 1 swxY w Y   t                      }|                                |k    sJ 	 t          j        |           d S # t          j        |           w xY w)	Nzsite.cfgALLr;   z[ALL]z[mkl]r   rg   z	[DEFAULT])rq   r   rr   rs   rp   r   copyr|   r   r   rF   splitre   r   r}   readr   r~   )rG   r   cfgrD   rN   fidmkldflts           r%   test_overridesz$TestSystemInfoReading.test_overrides  s     ikkgll4:z22DM3'''	"HTZ    ::Dwu~n5;;BJGGH$$&&(2222 c >chhjj(('1==> > > > > > > > > > > > > > >c3 3		#              ::D$$&&(2222 c Ccxxzz))';BBC C C C C C C C C C C C C C Cc3  3		$                             ::D$$&&(22222H[!!!!!BH[!!!!s   B I *D
>I 
DI DI %E;I EI E:I 	*F?3I ?GI GI G<0I <H  I H +I IN)rS   rT   rU   r   r   r   r   r   r   pytestmarkskipifHAVE_COMPILERr   reprr   new_compilerr   r   calc_libraries_infor   HAS_MKLxfailr   rM   r'   r%   r_   r_      s       '; '; ';R  g g g? ? ?M M ML L L [M)2DEE" " FE" [M)2DEE[$$'=y'='?'?"@"@@ ;  = =" "= = FE"  ((**88::>>{BOOOG[w )J L L" "L L" " "r'   r_   c                    ddl m} d}t          d          }|                     |d            |||          \  }}t	          |          dk    sJ |t          d          k    sJ t	          |          dk    sJ |                     |d	            |||          \  }}t	          |          dk    sJ t	          |          dk    sJ d
D ]i}|                     || d            |||          \  }}t	          |          dk    sJ |t          d          k    sJ t	          |          dk    sJ jt          j        t                    5  |                     |d            |||           d d d            n# 1 swxY w Y   t          j        t                    5  |                     |d            |||           d d d            d S # 1 swxY w Y   d S )Nr   )_parse_env_order#NPY_TESTS_DISTUTILS_PARSE_ENV_ORDERabcdefzb,i,e,f   befr   r9   z^!zb,i,e   acdfzb,^e,iz!b,^e,i)numpy.distutils.system_infor   listsetenvlenr   raisesr/   )monkeypatchr   env
base_orderorderunknownprefixs          r%   test_distutils_parse_env_orderr   /  s   <<<<<<
/ChJsI&&&%%j#66NE7u::????DKKw<<1 sB%%j#66NE7u::????w<<1 ! !36 0 0 0111))*c::w5zzQV$$$$7||q     	z	"	" * *3)))S)))* * * * * * * * * * * * * * * 
z	"	" * *3	***S)))* * * * * * * * * * * * * * * * * *s$   #E??FF##GGG)r   ),rq   r   r   tempfiler   r   
subprocessr   r   importlib.metadata	importlibdistutils.errorsr   numpy.testingr   r	   r
   numpy.distutilsr   r   r   r   r   r   r   r   r   r   metadataversionskipPackageNotFoundErrorr&   ry   rm   r   r6   r   r!   r   r   r   r_   r   rM   r'   r%   <module>r      s   				   % % % % % % % % " " " " " " " "     + + + + + + > > > > > > > > > > ; ; ; ; ; ; ; ; K K K K K K K K K K : : : : : : N N N N N N N N ( ( ( ( ( (	!!,//477 	+EEEE. 	 	 	D	
   , 	  .     ;   6       
       " " " " ", " " "
^" ^" ^" ^" ^" ^" ^" ^"B* * * * *s   0B	 	BB