U ã€C^ùOã@sddlmZmZmZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZddlmZddlmZmZddlZddlmZdd lmZdd lmZmZmZmZmZmZdd l m!Z!d e d <de d<Gdd„de ƒZ Gdd„de"ƒZ#dS)é)ÚdivisionÚabsolute_importÚprint_functionN)Ú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_inlineÚcheck_restrictÚcheck_compiler_gcc4)Ú get_exceptionz.fÚf77z.f90Úf90c@sÄeZdZejdg7_dd„Zdd„Zdd„Zdd „Zd d „Z d+dd„Z d,dd„Z d-dd„Z d.dd„Z d/dd„Zd0dd„Zd1dd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd2d)d*„Zd S)3r)z fcompiler=Nz!specify the Fortran compiler typecCsd|_t |¡dS©N)Ú fcompilerÚ old_configÚinitialize_options©Úself©rúA/tmp/pip-install-6_kvzl1k/numpy/numpy/distutils/command/config.pyr%szconfig.initialize_optionscCs:t |¡ddlm}m}tjdkrÔ|jjdkrÔ|jj s”z|j  ¡WnLt k r’t ƒ}t  d¡||jjjf}tt  d¡ƒtj |¡‚YnXddlm}| ¡dkrÔ|jj|jjfD]}d |kr¼| d ¡q¼t|j|ƒ�s6||j|jd |jd �|_|jdk �r6|j |j¡|j ¡�r6|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ÚIOErrorrÚtextwrapÚdedentÚ __class__Ú__name__ÚprintÚ distutilsÚerrorsÚDistutilsPlatformErrorr"Zget_build_versionZldflags_sharedZldflags_shared_debugÚappendÚ isinstancerr&Z customizeÚ distributionÚ get_versionZ customize_cmdZshow_customization)rrrÚeÚmsgr"Zldflagsrrrr()sB ÿ ÷   ÿ þ   zconfig._check_compilerc Csxddlm}ddlm}|j}|dkr.|j|_z||f|Ž}Wn,||fk rlttƒƒ||_|‚YnX||_|S)Nr)r )ÚDistutilsExecError©rr)Údistutils.ccompilerr Údistutils.errorsr;r%rÚstrr)rZmthÚlangÚargsr r;Z save_compilerÚretrrrÚ _wrap_method[s    zconfig._wrap_methodcCs4| tj|||||f¡\}}|j |d¡||fS)Nz.d)rCrÚ_compileÚ temp_filesr5)rÚbodyÚheadersÚ include_dirsr@ÚsrcÚobjrrrrDjs   ÿzconfig._compilec CsÊ|jjdk�r˜|pgdd…}|p$gdd…}|dkrÂd}|jrÂ|jjpJgD]P}| d¡r’zt dd|g¡}Wnttjfk rˆYn Xt |ƒ}|  |¡qL|jj p¨gD]}||krª|  |¡qª|D]Î}| d¡rÖqÆd} |pàgD],} t j  | d|¡} t j  | ¡râd } �qqâ| �rqÆd} |D]X} t j  | d |¡} t j  | ¡�r t j  | d|¡} t| | ƒ|j  | ¡d } �qz�q | �r‚qÆt d ||f¡qÆn|jjd k�r®t|ƒ| tj|||||||f¡S) Nr!r<Ú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ÚCalledProcessErrorr r5Ú librariesÚosÚpathÚjoinÚisfilerrErÚwarnr rCrÚ_link) rrFrGrHrRrLr@ÚdZlibnameZ fileexistsZlibdirZlibfileZlibfile2rrrrXrsl ÿ         ÿ  ÿÿz config._linkNrKcCs| ¡| d|g|¡S)Nz2/* we need a dummy line to make distutils happy */)r(Ú try_compile)rÚheaderrHrLr@rrrÚ check_header¨s þzconfig.check_headercCs(| ¡t d¡||f}| |||¡S)Nz¨ int main(void) { #ifndef %s (void) %s; #endif ; return 0; }©r(r-r.rZ©rÚsymbolrGrHrFrrrÚ check_decl®s ø zconfig.check_declcCs&| ¡t d¡|f}| |||¡S)NzÇ int main(void) { #if %s #else #error false or undefined macro #endif ; return 0; }r]r^rrrÚcheck_macro_true½s  ÷ zconfig.check_macro_truecCsp| ¡t d¡d|i}d}zBz | |d|i||d¡d}Wntjjk r\d}YnXW5| ¡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ÚtyperKT)r(r-r.Ú_cleanrDr2r3r )rÚ type_namerGrHrLrFÚstrrrÚ check_typeÍs"ù ÿ zconfig.check_typec Csb| ¡t d¡}| |d|i||d¡| ¡|rŒt d¡}|D]F}z,| |||dœ||d¡| ¡|WStk rˆYqDXqDt d¡}d}d} z*| ||| dœ||d¡| ¡WqôWqžtk rð| d}d | d} YqžXqž| } || k�r^| |d |} z*| ||| dœ||d¡| ¡| } Wqøtk �rZ| d}YqøXqø|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; } rcrKaW 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; } )rcÚ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.rDrdr ) rrerGrHrLÚexpectedrFrhÚlowZmidÚhighrrrÚcheck_type_sizeêsb ÿ ÿ  ÿ ÿ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) Núint %s (void);ú#ifdef _MSC_VERú#pragma function(%s)ú#endifúint main (void) {Úú %s(%s);ú %s;ú return 0;Ú}Ú )r(rcr?r5rUÚtry_link) rÚfuncrGrHrRrLÚdeclÚcallÚ call_argsrFrrrÚ check_func=s,        ÿzconfig.check_funcc Cs| ¡g} |r4| ¡D]\} } | r|  d| ¡q|  d¡|D]} |  d| ¡qB|  d¡|  d¡|rÎ|D]X} | |kr¼|| r¼|rš| |krš|| s d} n|| } |  d| | f¡qr|  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. rnrorprqrrrsrtrurvrwrx)r(Úitemsr5rUry)rÚfuncsrGrHrRrLr{r|r}rFÚfÚvrzrArrrÚcheck_funcs_once_s8      ÿzconfig.check_funcs_oncecCst|ƒS)zUReturn the inline keyword recognized by the compiler, empty string otherwise.)rrrrrrœszconfig.check_inlinecCst|ƒS)zWReturn the restrict keyword recognized by the compiler, empty string otherwise.)rrrrrr¡szconfig.check_restrictcCst|ƒS)z*Return True if the C compiler is gcc >= 4.)rrrrrr¦szconfig.check_compiler_gcc4cCs t|||ƒSr)r )rÚ attributerbrrrr ªsz#config.check_gcc_function_attributecCst|||||ƒSr)r)rr„rbÚcodeÚincluderrrr­s ÿz3config.check_gcc_function_attribute_with_intrinsicscCs t||ƒSr)r)rr„rrrr²sz#config.check_gcc_variable_attributec Cs~tjdtdd�| ¡d\}} �z&tƒ} z&| ||||||¡\} } } |  ¡Wn$tk rt| j} |  ¡‚YnXt j   d| ¡} zt j | gdd�} WnHt jk rÆ}z|j}d} W5d}~XYn$tk ràd }d} Yn Xt| ƒ} tt d ƒ�r8t  |¡}t  |¡�rs,        U