a ;jgP@sddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZddl Z ddlmZddlmZdd lmZmZmZmZmZmZmZd e d <d e d <GdddeZGdddZdS)N)config)LANG_EXT)log) copy_file) CompileError LinkError)filepath_from_subprocess_output)generate_manifest)check_gcc_function_attribute,check_gcc_function_attribute_with_intrinsicscheck_gcc_variable_attributecheck_gcc_version_at_least check_inlinecheck_restrictcheck_compiler_gccz.ff77z.f90f90c@seZdZejdg7_ddZddZddZdd Zd d Z d.ddZ d/ddZ d0ddZ d1ddZ d2ddZd3ddZd4ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd5d*d+Zd6d,d-Zd S)7r)z fcompiler=Nz!specify the Fortran compiler typecCsd|_t|dSN) fcompiler old_configinitialize_optionsselfrH/usr/local/lib/python3.9/site-packages/numpy/distutils/command/config.pyr$szconfig.initialize_optionsc CsFt|ddlm}m}tjdkr|jjdvr|jj sz|j WnXt y}z@t d||jjjf}tt dtj||WYd}~n d}~00ddlm}|dkr|jj|jjfD]}d |vr|d qt|j|sB||j|jd |jd |_|jdurB|j|j|jrB|j||j dS) Nr) FCompiler new_fcompilerwin32)msvcZintelwZintelemwa> 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)compilerdry_runforceZ c_compiler)!r_check_compilerZnumpy.distutils.fcompilerrrsysplatformr" compiler_typeZ initializedZ initializeOSErrortextwrapdedent __class____name__print distutilserrorsDistutilsPlatformErrorrZget_build_versionZldflags_sharedZldflags_shared_debugappend isinstancerr#Z customize distribution get_versionZ customize_cmdZshow_customization)rrremsgrZldflagsrrrr%(s>   $      zconfig._check_compilerc Csddlm}ddlm}|j}|dvr.|j|_|jdurF|d|fz||f|}Wn4||fy}z||_||WYd}~n d}~00||_|S)Nr)r)DistutilsExecErrorrrz%s compiler is not set)distutils.ccompilerrdistutils.errorsr8r"r) rZmthlangargsrr8Z save_compilerretr6rrr _wrap_methodXs   zconfig._wrap_methodcCs4|tj|||||f\}}|j|d||fS)Nz.d)r?r_compile temp_filesr2)rbodyheaders include_dirsr<srcobjrrrr@hs   zconfig._compilec Cs|jjdkr|pgdd}|p$gdd}|dvrd}|jr|jjpJgD]N}|drztdd|g}WnttjfyYn 0t |}| |qL|jj pgD]}||vr| |q|D]}|drqd} |pgD],} t j | d|} t j | rd } qq| rqd} |D]X} t j | d |} t j | rt j | d|} t| | |j | d } qxq| rqtd ||fqn|jjd krt||tj|||||||fS) Nrr9cz/usr/libZcygpathz-wFz%s.libTzlib%s.az+could not find library %r in directories %sZmingw32)r"r(r library_dirs startswith subprocess check_outputr)CalledProcessErrorrr2 librariesospathjoinisfilerrArwarnr r?r_link) rrBrCrDrMrHr<dZlibnameZ fileexistslibdirZlibfileZlibfile2rrrrSps`            z config._linkNrGcCs||d|g|S)Nz2/* we need a dummy line to make distutils happy */)r% try_compile)rheaderrDrHr<rrr check_headers zconfig.check_headercCs(|td||f}||||S)Nz int main(void) { #ifndef %s (void) %s; #endif ; return 0; }r%r*r+rVrsymbolrCrDrBrrr check_decls  zconfig.check_declcCs&|td|f}||||S)Nz int main(void) { #if %s #else #error false or undefined macro #endif ; return 0; }rYrZrrrcheck_macro_trues   zconfig.check_macro_truecCsv|tdd|i}d}zHz ||d|i||dd}WntjjyZd}Yn0W|n |0|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; } nameFtyperGT)r%r*r+r@r/r0r_clean)r type_namerCrDrHrBstrrr check_types  zconfig.check_typec Cs\|td}||d|i||d||rtd}|D]D}z,||||d||d||WStyYqD0qDtd}d}d} z*|||| d||d|WqWqty| d}d | d} Yq0q| } || krX| |d |} z*|||| d||d|| } WqtyT| d}Yq0q|S) zCheck 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_rGaW 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; } rr!)r%r*r+r@r`r) rrarCrDrHexpectedrBrdlowmidhighrrrcheck_type_sizesR       zconfig.check_type_sizeFc Cs|g} |r6t|tkr(| |n| d|| d| d|| d| d|r|durrd}| d||fn| d|| d | d d | d } || ||||S) Nint %s (void);#ifdef _MSC_VER#pragma function(%s)#endifint main (void) { %s(%s); %s; return 0;} )r%r_strr2rPtry_link) rfuncrCrDrMrHdeclcall call_argsrBrrr check_func;s*        zconfig.check_funcc Cs|g} |r4|D]\} } | r| d| q| d|D]} | d| qB| d| d|r|D]X} | |vr|| r|r| |vr|| sd} n|| } | d| | fqr| d| qrn|D]} | d| q| d | d d | d } || ||||S) a0Check 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. rkrlrmrnrorprqrrrsrtru)r%itemsr2rPrw)rfuncsrCrDrMrHryrzr{rBfvrxr=rrrcheck_funcs_once]s6      zconfig.check_funcs_oncecCst|S)zUReturn the inline keyword recognized by the compiler, empty string otherwise.)rrrrrrszconfig.check_inlinecCst|S)zWReturn the restrict keyword recognized by the compiler, empty string otherwise.)rrrrrrszconfig.check_restrictcCst|S)z$Return True if the C compiler is gcc)rrrrrrszconfig.check_compiler_gcccCs t|||Sr)r )r attributer^rrrr sz#config.check_gcc_function_attributecCst|||||Sr)r )rrr^codeincluderrrr sz3config.check_gcc_function_attribute_with_intrinsicscCs t||Sr)r )rrrrrr sz#config.check_gcc_variable_attributercCst||||S)zYReturn True if the GCC version is greater than or equal to the specified version.)r )rmajorminorZ patchlevelrrrr sz!config.check_gcc_version_at_leastc Csztjdtdd|d\}} z$t} z&|||||||\} } } | Wn"tyr| j} | Yn0t j d| } zt j | gdd} WnHt jy}z|j}d} WYd}~n*d}~0tyd }d} Yn 0t| } tt d r6t |}t |r:t |}td |f|tjkr:tn|}td Wn"ttfyhtd Yn0||| fS)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. +++++++++++++++++++++++++++++++++++++++++++++++++ re) stacklevel)rp.)cwdrpN WEXITSTATUSz subprocess exited with signal %dzsuccess!zfailure.)warningsrRDeprecationWarningr% GrabStdoutrSrestore ExceptiondatarNrOrPrJrKrL returncoder)rhasattrr WIFSIGNALEDWTERMSIGrerrorsignalSIGINTKeyboardInterruptinforrr`)rrBrCrDrMrHr<Zuse_teeexitcodeoutputZgrabberrErFexeexcZ exitstatussigrrr get_outputsN           zconfig.get_output)NNrG)NN)NN)NNN)NNNN)NNNNFFN)NNNNFFN)rr)NNNNrGN)r- __module__ __qualname__r user_optionsrr%r?r@rSrXr\r]rcrjr|rrrrr r r r rrrrrrsH06     T # = rc@s,eZdZddZddZddZddZd S) rcCstj|_d|_|t_dS)Nrp)r&stdout sys_stdoutrrrrr__init__szGrabStdout.__init__cCs|j||j|7_dSr)rwriter)rrrrrrs zGrabStdout.writecCs|jdSr)rflushrrrrrszGrabStdout.flushcCs |jt_dSr)rr&rrrrrrszGrabStdout.restoreN)r-rrrrrrrrrrrsr)rNrrJr&r*rZdistutils.command.configrrrr/rdistutils.file_utilrr:rrZnumpy.distutils.exec_commandrZ numpy.distutils.mingw32ccompilerr Z numpy.distutils.command.autodistr r r r rrrrrrrrs*      $Y