U C^O@sddlmZmZmZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZddlmZddlmZmZddlZddlmZdd lmZdd lmZmZmZmZmZmZdd l m!Z!d e d <de d<Gddde Z Gddde"Z#dS))divisionabsolute_importprint_functionN)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_attribute check_inlinecheck_restrictcheck_compiler_gcc4) get_exceptionz.ff77z.f90f90c@seZdZejdg7_ddZddZddZdd Zd d Z d+ddZ d,ddZ d-ddZ d.ddZ d/ddZd0ddZd1ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd2d)d*Zd S)3r)z fcompiler=Nz!specify the Fortran compiler typecCsd|_t|dSN) fcompiler old_configinitialize_optionsselfrA/tmp/pip-install-6_kvzl1k/numpy/numpy/distutils/command/config.pyr%szconfig.initialize_optionscCs:t|ddlm}m}tjdkr|jjdkr|jj sz|j WnLt k rt }t d||jjjf}tt dtj|YnXddlm}|dkr|jj|jjfD]}d |kr|d qt|j|s6||j|jd |jd |_|jdk r6|j|j|jr6|j ||j!dS) Nr) FCompiler new_fcompilerwin32)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)compilerdry_runforceZ c_compiler)"r_check_compilerZnumpy.distutils.fcompilerrrsysplatformr% compiler_typeZ initializedZ initializeIOErrorrtextwrapdedent __class____name__print distutilserrorsDistutilsPlatformErrorr"Zget_build_versionZldflags_sharedZldflags_shared_debugappend isinstancerr&Z customize distribution get_versionZ customize_cmdZshow_customization)rrremsgr"Zldflagsrrrr()sB         zconfig._check_compilerc Csxddlm}ddlm}|j}|dkr.|j|_z||f|}Wn,||fk rltt||_|YnX||_|S)Nr)r )DistutilsExecErrorrr)distutils.ccompilerr distutils.errorsr;r%rstrr)rZmthlangargsr r;Z save_compilerretrrr _wrap_method[s    zconfig._wrap_methodcCs4|tj|||||f\}}|j|d||fS)Nz.d)rCr_compile temp_filesr5)rbodyheaders include_dirsr@srcobjrrrrDjs   zconfig._compilec Cs|jjdkr|pgdd}|p$gdd}|dkrd}|jr|jjpJgD]P}|drztdd|g}Wnttjfk rYn Xt |}| |qL|jj pgD]}||kr| |q|D]}|drqd} |pgD],} t j | d|} t j | rd } qq| rqd} |D]X} t j | d |} t j | r t j | d|} t| | |j | d } qzq | rqtd ||fqn|jjd krt||tj|||||||fS) 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_outputOSErrorCalledProcessErrorr r5 librariesospathjoinisfilerrErwarnr rCr_link) rrFrGrHrRrLr@dZlibnameZ fileexistsZlibdirZlibfileZlibfile2rrrrXrsl            z config._linkNrKcCs||d|g|S)Nz2/* we need a dummy line to make distutils happy */)r( try_compile)rheaderrHrLr@rrr check_headers zconfig.check_headercCs(|td||f}||||S)Nz int main(void) { #ifndef %s (void) %s; #endif ; return 0; }r(r-r.rZrsymbolrGrHrFrrr check_decls  zconfig.check_declcCs&|td|f}||||S)Nz int main(void) { #if %s #else #error false or undefined macro #endif ; return 0; }r]r^rrrcheck_macro_trues   zconfig.check_macro_truecCsp|tdd|i}d}zBz ||d|i||dd}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; } nameFtyperKT)r(r-r._cleanrDr2r3r )r type_namerGrHrLrFstrrr check_types"  zconfig.check_typec Csb|td}||d|i||d||rtd}|D]F}z,||||d||d||WStk rYqDXqDtd}d}d} z*|||| d||d|WqWqtk r| d}d | d} YqXq| } || kr^| |d |} z*|||| d||d|| } Wqtk rZ| d}YqXq|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; } )rcsizea3 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 ) rrerGrHrLexpectedrFrhlowZmidhighrrrcheck_type_sizesb     zconfig.check_type_sizeFc Cs|g} |r6t|tkr(| |n| d|| d| d|| d| d|r|dkrrd}| 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(rcr?r5rUtry_link) rfuncrGrHrRrLdeclcall 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|| 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. rnrorprqrrrsrtrurvrwrx)r(itemsr5rUry)rfuncsrGrHrRrLr{r|r}rFfvrzrArrrcheck_funcs_once_s8      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 >= 4.)rrrrrrszconfig.check_compiler_gcc4cCs t|||Sr)r )r attributerbrrrr sz#config.check_gcc_function_attributecCst|||||Sr)r)rrrbcodeincluderrrrs z3config.check_gcc_function_attribute_with_intrinsicscCs t||Sr)r)rrrrrrsz#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 rd }d} Yn Xt| } tt d r8t |}t |rs,        U