o 6aP@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 d/ddZ d0ddZ d1ddZ d2ddZ d2ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd3d*d+Z d4d,d-Zd S)5r)z fcompiler=Nz!specify the Fortran compiler typecCsd|_t|dSN) fcompiler old_configinitialize_optionsselfr@/usr/lib/python3/dist-packages/numpy/distutils/command/config.pyr$szconfig.initialize_optionsc Cs@t|ddlm}m}tjdkrj|jjdvrj|jj sJz|j Wn&t yI}zt d||jjjf}tt dtj||d}~wwddlm}|dkrj|jj|jjfD] }d |vri|d q^t|j|s||j|jd |jd |_|jdur|j|j|jr|j||j dSdSdSdS) Nr) FCompiler new_fcompilerwin32)msvcintelwintelemwas 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 2008 for python 2.6, 2.7 and 3.2, VS 2010 for >= 3.3). Original exception was: %s, and the Compiler class was %s ============================================================================zd ============================================================================) msvc9compiler z /MANIFEST)compilerdry_runforce c_compiler)!r_check_compilernumpy.distutils.fcompilerrrsysplatformr$ compiler_type initialized initializeIOErrortextwrapdedent __class____name__print distutilserrorsDistutilsPlatformErrorr!get_build_versionldflags_sharedldflags_shared_debugappend isinstancerr% customize distribution get_version customize_cmdshow_customization)rrremsgr!ldflagsrrrr((sJ          zconfig._check_compilerc Csddlm}ddlm}|j}|dvr|j|_|jdur#|d|fz ||f|}Wn||fy@}z||_||d}~ww||_|S)Nr)r)DistutilsExecErrorrrz%s compiler is not set)distutils.ccompilerrdistutils.errorsrEr$r) rmthlangargsrrE save_compilerretrBrrr _wrap_methodYs   zconfig._wrap_methodcCs4|tj|||||f\}}|j|d||fS)Nz.d)rNr_compile temp_filesr;)rbodyheaders include_dirsrJsrcobjrrrrOis  zconfig._compilec Cs|jjdkr|p gdd}|pgdd}|dvr_d}|jr_|jjp$gD]'}|drGz tdd|g}Wn ttjfyBYnwt |}| |q%|jj pRgD] }||vr^| |qS|D]a}|driqad} |pngD]} t j | d|} t j | rd } nqo| rqad} |D])} t j | d |} t j | rt j | d|} t| | |j | d } nq| rqatd ||fqan |jjd krt||tj|||||||fS) NrrFcz/usr/libcygpathz-wFz%s.libTzlib%s.az+could not find library %r in directories %smingw32)r$r,r library_dirs startswith subprocess check_outputOSErrorCalledProcessErrorrr; librariesospathjoinisfilerrPrwarnr rNr_link) rrQrRrSr_rYrJdlibname fileexistslibdirlibfilelibfile2rrrreqsj             z config._linkNrVcCs||d|g|S)Nz2/* we need a dummy line to make distutils happy */)r( try_compile)rheaderrSrYrJrrr check_headers zconfig.check_headercCs(|td||f}||||S)Nz int main(void) { #ifndef %s (void) %s; #endif ; return 0; }r(r0r1rlrsymbolrRrSrQrrr check_decls  zconfig.check_declcCs&|td|f}||||S)Nz int main(void) { #if %s #else #error false or undefined macro #endif ; return 0; }rorprrrcheck_macro_trues   zconfig.check_macro_truecCs|tdd|i}d}z,z||d|i||dd}Wn tjjy-d}YnwW||SW||S|w)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; } nameFtyperVT)r(r0r1rOr5r6r_clean)r type_namerRrSrYrQstrrr check_types*  zconfig.check_typec CsZ|td}||d|i||d||rDtd}|D]!}z||||d||d||WStyCYq"wtd}d}d} z|||| d||d|Wntyt| d }d | d } YnwqN| } || kr| |d |} z|||| d||d|| } Wn ty| d }Ynw|| ks||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; } rurVaW 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; } )rusizea3 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; } rTr#)r(r0r1rOrvr) rrwrRrSrYexpectedrQrzlowmidhighrrrcheck_type_sizes^            zconfig.check_type_sizeFc Cs|g} |rt|tkr| |n| d|| d| d|| d| d|rC|dur9d}| 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(rustrr;rbtry_link) rfuncrRrSr_rYdeclcall call_argsrQrrr check_func<s*        zconfig.check_funcc Cs|g} |r|D] \} } | r| d| q | d|D] } | d| q!| d| d|rg|D],} | |vr^|| r^|rM| |vrM|| sPd} n|| } | d| | fq9| d| q9n |D] } | d| qi| 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. rrrrrrrrrrr)r(itemsr;rbr)rfuncsrRrSr_rYrrrrQfvrrKrrrcheck_funcs_once^s:       zconfig.check_funcs_oncecCt|S)zUReturn the inline keyword recognized by the compiler, empty string otherwise.)rrrrrrzconfig.check_inlinecCr)zWReturn the restrict keyword recognized by the compiler, empty string otherwise.)rrrrrrrzconfig.check_restrictcCr)z$Return True if the C compiler is gcc)rrrrrrszconfig.check_compiler_gcccCs t|||Sr)r )r attributertrrrr  z#config.check_gcc_function_attributecCst|||||Sr)r )rrrtcodeincluderrrr sz3config.check_gcc_function_attribute_with_intrinsicscCs t||Sr)r )rrrrrr s z#config.check_gcc_variable_attributercCst||||S)zYReturn True if the GCC version is greater than or equal to the specified version.)r )rmajorminor patchlevelrrrr sz!config.check_gcc_version_at_leastc Csltjdtdd|d\}} zt} z|||||||\} } } | Wnty6| j} | wt j d| } z t j | gdd} Wn$t jy`}z |j}d} WYd}~nd}~wtyld }d} Ynwt| } tt d rt |}t |rt |}td |f|tjkrtn|}td Wnttfytd Ynw||| 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. +++++++++++++++++++++++++++++++++++++++++++++++++ r{) stacklevel)r.)cwdrN WEXITSTATUSz subprocess exited with signal %dzsuccess!zfailure.)warningsrdDeprecationWarningr( GrabStdoutrerestore Exceptiondatar`rarbr[r\r^ returncoder]rhasattrr WIFSIGNALEDWTERMSIGrerrorsignalSIGINTKeyboardInterruptinforrrv)rrQrRrSr_rYrJuse_teeexitcodeoutputgrabberrTrUexeexc exitstatussigrrr get_outputsX         zconfig.get_output)NNrV)NN)NNN)NNNN)NNNNFFN)rr)NNNNrVN)r3 __module__ __qualname__r user_optionsrr(rNrOrernrrrsryrrrrrrr r r r rrrrrrsJ1 6   T # = rc@s,eZdZddZddZddZddZd S) rcCstj|_d|_|t_dS)Nr)r*stdout sys_stdoutrrrrr__init__s zGrabStdout.__init__cCs|j||j|7_dSr)rwriter)rrrrrrs zGrabStdout.writecCs|jdSr)rflushrrrrrszGrabStdout.flushcCs |jt_dSr)rr*rrrrrrrzGrabStdout.restoreN)r3rrrrrrrrrrrs  r)r`rr[r*r0rdistutils.command.configrrrr5rdistutils.file_utilrrGrrnumpy.distutils.exec_commandr numpy.distutils.mingw32ccompilerr numpy.distutils.command.autodistr r r r rrrrrrrrs,      $Z