B { `”Pã@sæddlZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZddl Z ddlmZddlmZdd lmZmZmZmZmZmZmZd e d <d e d <Gdd„deƒZGdd„dƒZdS)é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@sÎeZdZejdg7_dd„Zdd„Zdd„Zdd „Zd d „Z d.dd„Z d/dd„Z d0dd„Z d1dd„Z d2dd„Zd3dd„Zd4dd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd5d*d+„Zd6d,d-„Zd S)7r)z fcompiler=Nz!specify the Fortran compiler typecCsd|_t |¡dS)N)Ú fcompilerÚ old_configÚinitialize_options)Úself©rúB/tmp/pip-unpacked-wheel-4iou4664/numpy/distutils/command/config.pyr$szconfig.initialize_optionsc CsFt |¡ddlm}m}tjdkrà|jjdkrà|jj sœy|j  ¡WnTt k rš}z6t   d¡||jjjf}tt   d¡ƒtj |¡‚Wdd}~XYnXddlm}| ¡dkràx*|jj|jjgD]}d |krÆ| d ¡qÆWt|j|ƒsB||j|jd |jd |_|jdk rB|j |j¡|j ¡rB|j |¡|j  ¡dS) Nr)Ú FCompilerÚ new_fcompilerÚwin32)ÚmsvcZintelwZintelemwas 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é)ÚcompilerÚdry_runÚforceZ c_compiler)!rÚ_check_compilerZnumpy.distutils.fcompilerrrÚsysÚplatformr Ú compiler_typeZ initializedZ initializeÚIOErrorÚtextwrapÚdedentÚ __class__Ú__name__ÚprintÚ distutilsÚerrorsÚDistutilsPlatformErrorrZget_build_versionZldflags_sharedZldflags_shared_debugÚappendÚ isinstancerr!Z customizeÚ distributionÚ get_versionZ customize_cmdZshow_customization)rrrÚeÚmsgrZldflagsrrrr#(s:       zconfig._check_compilerc Cs„ddlm}ddlm}|j}|dkr.|j|_y||f|Ž}Wn8||fk rx}zt|ƒ||_|‚Wdd}~XYnX||_|S)Nr)r)ÚDistutilsExecError)rr)Údistutils.ccompilerrÚdistutils.errorsr6r rÚstr) rZmthÚlangÚargsrr6Z save_compilerÚretr4rrrÚ _wrap_methodYs  zconfig._wrap_methodcCs4| tj|||||f¡\}}|j |d¡||fS)Nz.d)r=rÚ_compileÚ temp_filesr0)rÚbodyÚheadersÚ include_dirsr:ÚsrcÚobjrrrr>hs zconfig._compilec CsÖ|jjdkr¤|pgdd…}|p$gdd…}|dkrÊd}|jrÊx`|jjpLgD]P}| d¡r”yt dd|g¡}Wnttjfk rŠYn Xt |ƒ}|  |¡qNWx&|jj p®gD]}||kr°|  |¡q°Wxî|D]Î}| d¡ràqÐd} x4|pìgD](} t j  | d|¡} t j  | ¡rîd } PqîW| r"qÐd} x\|D]T} t j  | d |¡} t j  | ¡r,t j  | d|¡} t| | ƒ|j  | ¡d } Pq,W| rŒqÐt d ||f¡qÐWn|jjd krºt|ƒ| tj|||||||f¡S) Nr)rrÚcz/usr/libZcygpathz-wFz%s.libTzlib%s.az+could not find library %r in directories %sZmingw32)r r&rÚ library_dirsÚ startswithÚ subprocessÚ check_outputÚOSErrorÚCalledProcessErrorrr0Ú librariesÚosÚpathÚjoinÚisfilerr?rÚwarnr r=rÚ_link) rr@rArBrLrFr:ÚdZlibnameZ fileexistsZlibdirZlibfileZlibfile2rrrrRps^        z config._linkNrEcCs| ¡| d|g|¡S)Nz2/* we need a dummy line to make distutils happy */)r#Ú try_compile)rÚheaderrBrFr:rrrÚ check_header¦szconfig.check_headercCs(| ¡t d¡||f}| |||¡S)Nz¨ int main(void) { #ifndef %s (void) %s; #endif ; return 0; })r#r(r)rT)rÚsymbolrArBr@rrrÚ check_decl¬szconfig.check_declcCs&| ¡t d¡|f}| |||¡S)NzÇ int main(void) { #if %s #else #error false or undefined macro #endif ; return 0; })r#r(r)rT)rrWrArBr@rrrÚcheck_macro_true»s zconfig.check_macro_truecCsp| ¡t d¡d|i}d}zBy | |d|i||d¡d}Wntjjk r\d}YnXWd| ¡X|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ÚtyperETN)r#r(r)r>r-r.rÚ_clean)rÚ type_namerArBrFr@ÚstrrrÚ check_typeËs  zconfig.check_typec Csf| ¡t d¡}| |d|i||d¡| ¡|rŠt d¡}xH|D]@}y&| |||dœ||d¡| ¡|Stk r„YqFXqFWt d¡}d}d} xVy(| ||| dœ||d¡| ¡PWqžtk rî| d}d | d} YqžXqžW| } xh|| kr`| |d |} y*| ||| dœ||d¡| ¡| } Wqútk r\| d}YqúXqúW|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[rEaW 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) rr]rArBrFÚexpectedr@r`ÚlowZmidÚhighrrrÚcheck_type_sizeèsR          zconfig.check_type_sizeFc CsÈ| ¡g} |r6t|ƒtkr(|  |¡n|  d|¡|  d¡|  d|¡|  d¡|  d¡|r†|dkrrd}|  d||f¡n|  d|¡|  d ¡|  d ¡d  | ¡d } | | ||||¡S) Nzint %s (void);z#ifdef _MSC_VERz#pragma function(%s)z#endifzint main (void) {Úz %s(%s);z %s;z return 0;Ú}Ú )r#r[r9r0rOÚtry_link) rÚfuncrArBrLrFÚdeclÚcallÚ call_argsr@rrrÚ check_func;s(        zconfig.check_funcc Cs*| ¡g} |r8x&| ¡D]\} } | r|  d| ¡qW|  d¡x|D]} |  d| ¡qHW|  d¡|  d¡|rÚx~|D]X} | |krÆ|| rÆ|r¤| |kr¤|| sªd} n|| } |  d| | f¡q||  d| ¡q|Wnx|D]} |  d| ¡qàW|  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. zint %s (void);z#ifdef _MSC_VERz#pragma function(%s)z#endifzint main (void) {rfz %s(%s);z %s;z return 0;rgrh)r#Úitemsr0rOri)rÚfuncsrArBrLrFrkrlrmr@ÚfÚvrjr;rrrÚcheck_funcs_once]s4         zconfig.check_funcs_oncecCst|ƒS)zUReturn the inline keyword recognized by the compiler, empty string otherwise.)r)rrrrršszconfig.check_inlinecCst|ƒS)zWReturn the restrict keyword recognized by the compiler, empty string otherwise.)r)rrrrrŸszconfig.check_restrictcCst|ƒS)z$Return True if the C compiler is gcc)r)rrrrr¤szconfig.check_compiler_gcccCs t|||ƒS)N)r )rÚ attributerZrrrr ¨sz#config.check_gcc_function_attributecCst|||||ƒS)N)r )rrtrZÚcodeÚincluderrrr «sz3config.check_gcc_function_attribute_with_intrinsicscCs t||ƒS)N)r )rrtrrrr °sz#config.check_gcc_variable_attributercCst||||ƒS)zYReturn True if the GCC version is greater than or equal to the specified version.)r )rÚmajorÚminorZ patchlevelrrrr ³sz!config.check_gcc_version_at_leastc Cs~tjdtdd| ¡d\}} y&tƒ} y&| ||||||¡\} } } |  ¡Wn$tk rt| j} |  ¡‚YnXt j   d| ¡} yt j | gdd} WnHt jk rÆ}z|j}d} Wdd}~XYn$tk ràd }d} Yn Xt| ƒ} tt d ƒr8t  |¡}t  |¡rrRrVrXrYr_rernrsrrrr r r r r’rrrrrs: 16     T  : rc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) rcCstj|_d|_|t_dS)Nrf)r$ÚstdoutÚ sys_stdoutr„)rrrrÚ__init__÷szGrabStdout.__init__cCs|j |¡|j|7_dS)N)r—Úwriter„)rr„rrrr™üs zGrabStdout.writecCs|j ¡dS)N)r—Úflush)rrrrršszGrabStdout.flushcCs |jt_dS)N)r—r$r–)rrrrr‚szGrabStdout.restoreN)r+r“r”r˜r™ršr‚rrrrrõsr)rMrŠrHr$r(rZdistutils.command.configrrrr-rÚdistutils.file_utilrr7rrZnumpy.distutils.exec_commandrZ numpy.distutils.mingw32ccompilerr Z numpy.distutils.command.autodistr r r r rrrrrrrrÚs*      $Y