
    G/PhP                        d dl Z d dlZd dlZd dl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mZ d dl
Z
d dlmZ d dlmZ d d	lmZmZmZmZmZmZmZ d
e	d<   de	d<    G d de          Z G d d          ZdS )    N)config)LANG_EXT)log)	copy_file)CompileError	LinkError)filepath_from_subprocess_output)generate_manifest)check_gcc_function_attribute,check_gcc_function_attribute_with_intrinsicscheck_gcc_variable_attributecheck_gcc_version_at_leastcheck_inlinecheck_restrictcheck_compiler_gccz.ff77z.f90f90c                       e Zd Zexj        dgz  c_        d Zd Zd Zd Zd Z	dd	Z
	 dd
Z	 ddZ	 	 ddZddZ	 	 	 ddZ	 	 	 ddZd Zd Zd Zd Zd Zd ZddZ	 	 	 d dZdS )!r   )z
fcompiler=Nz!specify the Fortran compiler typec                 <    d | _         t          j        |            d S N)	fcompiler
old_configinitialize_optionsselfs    ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numpy/distutils/command/config.pyr   zconfig.initialize_options$   s     %d+++++    c                    t          j        |            ddlm}m} t
          j        dk    r| j        j        dv r| j        j	        s	 | j        
                                 n{# t          $ rn}t          j        d          || j        j        j        fz  }t!          t          j        d                     t"          j                            |          |d }~ww xY wddlm} |                                dk    r4| j        j        | j        j        fD ]}d	|vr|                    d	           t3          | j        |          s || j        | j        d
| j                  | _        | j        o| j                            | j                   | j                                        r9| j                            |            | j                                          d S d S d S d S )Nr   )	FCompilernew_fcompilerwin32)msvcintelwintelemwa>                          Could not initialize compiler instance: do you have Visual Studio
                        installed?  If you are trying to build with MinGW, please use "python setup.py
                        build -c mingw32" instead.  If you have Visual Studio installed, check it is
                        correctly installed, and the right version (VS 2015 as of this writing).

                        Original exception was: %s, and the Compiler class was %s
                        ============================================================================zd                        ============================================================================)msvc9compiler
   z	/MANIFEST   )compilerdry_runforce
c_compiler)!r   _check_compilernumpy.distutils.fcompilerr   r    sysplatformr(   compiler_typeinitialized
initializeOSErrortextwrapdedent	__class____name__print	distutilserrorsDistutilsPlatformErrorr%   get_build_versionldflags_sharedldflags_shared_debugappend
isinstancer   r)   	customizedistributionget_versioncustomize_cmdshow_customization)r   r   r    emsgr%   ldflagss          r   r,   zconfig._check_compiler(   sD   "4(((FFFFFFFF<7""(C(F)G )G =, NNM,,.... N N N"/ +h i i dm5>?@C (/ +h i i j j j#*AA#FFAMN" 0/////..00B66 $ < $ B D 4 4G"'11{333$.)44 	8*]DN37<q6:mE E EDN ~)(():;;;>--// 8N00666N5577777	8 	8 *)8 8s   	A# #
C-A)CCc                     ddl m} ddlm} | j        }|dv r| j        | _        | j         ||d          	  || f|z    }n# ||f$ r}|| _        ||d }~ww xY w|| _        |S )Nr   )r   )DistutilsExecErrorr   r   z compiler is not set)distutils.ccompilerr   distutils.errorsrJ   r(   r   )	r   mthlangargsr   rJ   save_compilerretrF   s	            r   _wrap_methodzconfig._wrap_methodX   s    444444777777>!! NDM= ,444ABBB	&#&CC"L1 	& 	& 	&)DMA%	& &
s   	A A
AAc                     |                      t          j        |||||f          \  }}| j                            |dz              ||fS )Nz.d)rS   r   _compile
temp_filesr?   )r   bodyheadersinclude_dirsrO   srcobjs          r   rU   zconfig._compileh   sU    $$Z%8$&*G\4%HJ JS 	sTz***Cxr   c           
         | j         j        dk    r|pg d d          }|pg d d          }|dv rd}| j        r| j        j        pg D ]p}|                    d          rD	 t          j        dd|g          }t          |          }n# t          t
          j	        f$ r Y nw xY w|
                    |           q| j        j        pg D ]}||vr|
                    |           |D ]#}|                    d          rd}	|pg D ]H}
t          j                            |
d|z            }t          j                            |          rd	}	 nI|	rkd}	|D ]}
t          j                            |
d
|z            }t          j                            |          rQt          j                            |
d|z            }t!          ||           | j        
                    |           d	}	 n|	r	t%          j        d|d|           %n| j         j        dk    rt)          |            |                     t,          j        |||||||f          S )Nr"   rK   cz/usr/libcygpathz-wFz%s.libTzlib%s.azcould not find library z in directories mingw32)r(   r0   r   library_dirs
startswith
subprocesscheck_outputr	   r3   CalledProcessErrorr?   	librariesospathjoinisfiler   rV   r   warnr
   rS   r   _link)r   rW   rX   rY   re   r`   rO   dlibname
fileexistslibdirlibfilelibfile2s                r   rk   zconfig._linkp   s    =&.."b!!!,I(.B2L~%%> 6!^8>B / / <<
33 GG$.$;Y=A1=F %G %G
 %DA$F$F %,Z-J#K % % % $% %++A....#'>#;#Ar 6 6")33%,,W555$ 4 4%%f--7x"
*0b  F gll68w3GHHGw~~g.. %)
 'x"
* 	 	F gll693HIIGw~~g..  $&7<<G8L#M#M!'8444..x888%)
 'x#GG\\3 4 4 4 4-40 ](I55d###  !14"&"+\4"AB B 	Bs   BBBNr]   c                 Z    |                                   |                     d|g|          S )Nz2/* we need a dummy line to make distutils happy */)r,   try_compile)r   headerrY   r`   rO   s        r   check_headerzconfig.check_header   s6    D,( ( 	(r   c                     |                                   t          j        d          ||fz  }|                     |||          S )Nz
            int main(void)
            {
            #ifndef %s
                (void) %s;
            #endif
                ;
                return 0;
            }r,   r4   r5   rs   r   symbolrX   rY   rW   s        r   
check_declzconfig.check_decl   sS         V$% g|<<<r   c                     |                                   t          j        d          |fz  }|                     |||          S )Nz
            int main(void)
            {
            #if %s
            #else
            #error false or undefined macro
            #endif
                ;
                return 0;
            }rw   rx   s        r   check_macro_truezconfig.check_macro_true   sP     	  	 	 I	 g|<<<r   c                 <   |                                   t          j        d          d|iz  }d}	 	 |                     |d|iz  ||d           d}n# t          j        j        $ r d}Y nw xY w|                                  n# |                                  w xY w|S )zYCheck type availability. Return True if the type can be compiled,
        False otherwisez
            int main(void) {
              if ((%(name)s *) 0)
                return 0;
              if (sizeof (%(name)s))
                return 0;
            }
            nameFtyper]   T)r,   r4   r5   rU   r9   r:   r   _clean)r   	type_namerX   rY   r`   rW   sts          r   
check_typezconfig.check_type   s     	      I&' 	dfi%88s4 4 4#0    KKMMMMDKKMMMM	s)   A B A+(B *A++B Bc                    |                                   t          j        d          }|                     |d|iz  ||d           |                                  |r_t          j        d          }|D ]H}	 |                     |||dz  ||d           |                                  |c S # t
          $ r Y Ew xY wt          j        d          }d}d}		 	 |                     |||	dz  ||d           |                                  n# t
          $ r |	d	z   }d
|	z  d	z   }	Y nw xY wR|	}
||
k    r\|
|z
  d
z  |z   }		 |                     |||	dz  ||d           |                                  |	}
n# t
          $ r |	d	z   }Y nw xY w||
k    \|S )zCheck size of a given type.a,  
            typedef %(type)s npy_check_sizeof_type;
            int main (void)
            {
                static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) >= 0)];
                test_array [0] = 0

                ;
                return 0;
            }
            r   r]   aW  
                typedef %(type)s npy_check_sizeof_type;
                int main (void)
                {
                    static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) == %(size)s)];
                    test_array [0] = 0

                    ;
                    return 0;
                }
                )r   sizea3  
            typedef %(type)s npy_check_sizeof_type;
            int main (void)
            {
                static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) <= %(size)s)];
                test_array [0] = 0

                ;
                return 0;
            }
            r   Tr'      )r,   r4   r5   rU   r   r   )r   r   rX   rY   r`   expectedrW   r   lowmidhighs              r   check_type_sizezconfig.check_type_size   s@     
  
 
 	dfi00s	, 	, 	, 	? 
$ 
 
D !  MM$)T)J)J"J#\38 8 8KKMMMKKK#   D  
  
 
 		""di%E%EEs4 4 4 " " "Ag#gk"		" Tkk#:!#c)Cdi%E%EEs4 4 4   Ag Tkk 
s6   53B++
B87B82D D"!D":4E/ /F FFc	                    |                                   g }	|rFt          |          t          k    r|	                    |           n|	                    d|z             |	                    d           |	                    d|z             |	                    d           |	                    d           |r!|d}|	                    d|d|d	           n|	                    d
|z             |	                    d           |	                    d           d                    |	          dz   }	|                     |	||||          S )Nint %s (void);#ifdef _MSC_VER#pragma function(%s)#endifint main (void) {   ();  %s;  return 0;}
)r,   r   strr?   rh   try_link)
r   funcrX   rY   re   r`   declcall	call_argsrW   s
             r   
check_funczconfig.check_func;  sY    	 	5DzzS  D!!!!,t3444
 	%&&&*T1222H'((( 	( 	KKKtttYYY78888KK$'''M"""Cyy%}}T7L&6 6 	6r   c	                    |                                   g }	|r4|                                D ]\  }
}|r|	                    d|
z              |	                    d           |D ]}|	                    d|z             |	                    d           |	                    d           |r`|D ]\}
|
|v r>||
         r6|r|
|v r||
         sd}n||
         }|	                    d|
d|d	           D|	                    d
|
z             ]n|D ]}
|	                    d
|
z             |	                    d           |	                    d           d                    |	          dz   }	|                     |	||||          S )a0  Check a list of functions at once.

        This is useful to speed up things, since all the functions in the funcs
        list will be put in one compilation unit.

        Arguments
        ---------
        funcs : seq
            list of functions to test
        include_dirs : seq
            list of header paths
        libraries : seq
            list of libraries to link the code snippet to
        library_dirs : seq
            list of library paths
        decl : dict
            for every (key, value), the declaration in the value will be
            used for function in key. If a function is not in the
            dictionary, no declaration will be used.
        call : dict
            for every item (f, value), if the value is True, a call will be
            done to the function f.
        r   r   r   r   r   r   r   r   r   r   r   r   r   )r,   itemsr?   rh   r   )r   funcsrX   rY   re   r`   r   r   r   rW   fvr   rP   s                 r   check_funcs_oncezconfig.check_funcs_once]  s   6 	 	6

 6 61 6KK 01 4555 	%&&& 	7 	7DKK.56666H'((( 	) - -99a9% ,!y..Yq\.!(|KKKqqq$$$ 78888KK!,,,,-  ) )GaK((((M"""Cyy%}}T7L&6 6 	6r   c                      t          |           S )zUReturn the inline keyword recognized by the compiler, empty string
        otherwise.)r   r   s    r   r   zconfig.check_inline  s     D!!!r   c                      t          |           S )zWReturn the restrict keyword recognized by the compiler, empty string
        otherwise.)r   r   s    r   r   zconfig.check_restrict  s     d###r   c                      t          |           S )z$Return True if the C compiler is gcc)r   r   s    r   r   zconfig.check_compiler_gcc  s    !$'''r   c                 $    t          | ||          S r   )r   )r   	attributer~   s      r   r   z#config.check_gcc_function_attribute  s    +D)TBBBr   c                 (    t          | ||||          S r   )r   )r   r   r~   codeincludes        r   r   z3config.check_gcc_function_attribute_with_intrinsics  s"    ;D)<@$Q Q 	Qr   c                 "    t          | |          S r   )r   )r   r   s     r   r   z#config.check_gcc_variable_attribute  s    +D)<<<r   r   c                 &    t          | |||          S )zYReturn True if the GCC version is greater than or equal to the
        specified version.)r   )r   majorminor
patchlevels       r   r   z!config.check_gcc_version_at_least  s     *$ujIIIr   c                    t          j        dt          d           |                                  d\  }}		 t	                      }
	 |                     ||||||          \  }}}|
                                 n*# t          $ r |
j        }	|
                                  w xY wt          j
                            d|          }	 t          j        |gd          }	t          |	          }	n4# t          j        $ r}|j        }d}	Y d}~nd}~wt"          $ r d	}d}	Y nw xY wt%          t          d
          rlt          j        |          }t          j        |          rCt          j        |          }t-          j        d|fz             |t0          j        k    rt4          n|}t-          j        d           n+# t8          t:          f$ r t-          j        d           Y nw xY w|                                  ||	fS )zTry to compile, link to an executable, and run a program
        built from 'body' and 'headers'. Returns the exit status code
        of the program and its output.
        z
+++++++++++++++++++++++++++++++++++++++++++++++++
Usage of get_output is deprecated: please do not 
use it anymore, and avoid configuration checks 
involving running executable on the target machine.
+++++++++++++++++++++++++++++++++++++++++++++++++
r   )
stacklevel)   r   .)cwdr   N   WEXITSTATUSz subprocess exited with signal %dzsuccess!zfailure.)warningsrj   DeprecationWarningr,   
GrabStdoutrk   restore	Exceptiondatarf   rg   rh   rb   rc   r	   rd   
returncoder3   hasattrr   WIFSIGNALEDWTERMSIGr   errorsignalSIGINTKeyboardInterruptinfor   r   r   )r   rW   rX   rY   re   r`   rO   use_teeexitcodeoutputgrabberrZ   r[   exeexc
exitstatussigs                    r   
get_outputzconfig.get_output  sD    	 L
 )Q	8 	8 	8 	8 	"&)	! llG $

4,+4lD!J !JS#!!!!    !!! ',,sC((CA $0#C@@@ 9@@ 0    ^
    !
	 r=)) 	&>*55>*-- 0+j11CI@C6IJJJfm++//%HZ    i( 	! 	! 	!HZ     	!s`   F7 2A9 8F7 9'B  #F7 C+ F7 +D:	DF7 DF7 DBF7 7%GG)NNr]   )NN)NNN)NNNN)NNNNFFN)r   r   )NNNNr]   N)r7   
__module____qualname__r   user_optionsr   r,   rS   rU   rk   ru   rz   r|   r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r      s       A 
 
, , ,.8 .8 .8`     4B 4B 4Bl( ( ( ( /3= = = =  59= = = =  @D   :Q Q Q Qh /30459 6  6  6  6F /30459;6 ;6 ;6 ;6z" " "
$ $ $
( ( (C C CQ Q Q
= = =J J J J
 ;?04%);  ;  ;  ;  ;  ; r   r   c                   &    e Zd Zd Zd Zd Zd ZdS )r   c                 N    t           j        | _        d| _        | t           _        d S )Nr   )r.   stdout
sys_stdoutr   r   s    r   __init__zGrabStdout.__init__  s    *	


r   c                 Z    | j                             |           | xj        |z  c_        d S r   )r   writer   )r   r   s     r   r   zGrabStdout.write  s,    d###		T				r   c                 8    | j                                          d S r   )r   flushr   s    r   r   zGrabStdout.flush   s    r   c                 (    | j         t          _        d S r   )r   r.   r   r   s    r   r   zGrabStdout.restore  s    _


r   N)r7   r   r   r   r   r   r   r   r   r   r   r     sP          
       % % % % %r   r   )rf   r   rb   r.   r4   r   distutils.command.configr   r   r   r9   r   distutils.file_utilr   rL   r   r   numpy.distutils.exec_commandr	    numpy.distutils.mingw32ccompilerr
    numpy.distutils.command.autodistr   r   r   r   r   r   r   r   r   r   r   <module>r      s  
 
			      



   9 9 9 9 9 9 - - - - - -       ) ) ) ) ) ) 7 7 7 7 7 7 7 7     H H H H H H > > > > > >B B B B B B B B B B B B B B B B B B T  T  T  T  T Z T  T  T l% % % % % % % % % %r   