v]c@`sdZddlmZmZmZddlZddlZddlZddlZddl Z ej ddkrddl m Z nddlm Z ddlZddlmZddl mZmZdd lmZdd lmZdd lmZmZmZdd lmZm Z m!Z!m"Z"d Z#e#ej$_%ej&dZ'ej&dZ(dej$j)fdYZ*dZ+dZ,dZ-dZ.e/dZ0dZ1dZ2dZ3dZ4iZ5ej6dkrxyxddl7Z7de5dk rte j?d%qxXnd&Z@d'd(ZAd)ZBd*ZCd+ZDd,ZEd-ZFdS(.s Support code for building Python extensions on Windows. # NT stuff # 1. Make sure libpython.a exists for gcc. If not, build it. # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) # 3. Force windows to use g77 i(tdivisiontabsolute_importtprint_functionNii(tlog(t StrictVersion(tgen_preprocess_optionstgen_lib_options(t UnixCCompiler(tget_build_version(tDistutilsExecErrort CompileErrortUnknownFileError(tmsvc_runtime_librarytmsvc_runtime_versiontmsvc_runtime_majortget_build_architecturecC`s t}|dkrgS|gS(sBReplacement for outdated version of get_msvcr from cygwinccompilerN(R tNone(tmsvcr((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytget_msvcr_replacement*s s\[Ordinal/Name Pointer\] Tables$^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)tMingw32CCompilercB`sPeZdZdZddddZdddddddZdddZRS(sH A modified MingW32 compiler compatible with an MSVC built Python. tmingw32ic C`setjjj|||||jdkrtjddgdtdtj }|j j }|j j t jd|}|rt|jd|_qn|jdkrd}nd }|jd krd |_n|jdkrd |_ntt}td t} |s | r0|jd nt} | rV|jdd| ntdkr|jdkr|jddddddddqU|jddddddddn|jdkr|jdddd dd!dd"|j|fnV|jdkr3|jdd#dd$dd!dd%n"|jdd&dd'dd(dd)d g|_dS(*Ntgccs -dumpversiontshelltstdouts (\d+\.\d+)is2.91.57s--entry _DllMain@12ttdllwrapsg++tdebugtNPY_MINGW_USE_CUSTOM_MSVCRt__MSVCRT_VERSION__s0x%04itAMD64s4.0tcompilers/gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wallt compiler_sosCgcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall -Wstrict-prototypest linker_exesgcc -g -mno-cygwint linker_sosgcc -g -mno-cygwin -shareds#gcc -g -DDEBUG -DMS_WIN64 -O0 -Walls7gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypessgcc -gsgcc -g -shareds3.0.0sgcc -mno-cygwin -O2 -ws0gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypessg++ -mno-cygwins%s -mno-cygwin -mdll -static %ssgcc -mno-cygwin -O2 -Walls-gcc -mno-cygwin -O2 -Wall -Wstrict-prototypessg++ -mno-cygwin -shareds gcc -O2 -Walls!gcc -O2 -Wall -Wstrict-prototypessg++ s g++ -shared(t distutilstcygwinccompilertCygwinCCompilert__init__t gcc_versionRt subprocesstPopentTruetPIPERtreadtclosetretsearchRtgroupt linker_dlltlinkertbuild_import_librarytbuild_msvcr_libraryt define_macroR Rtset_executablest compiler_cxx( tselftverbosetdry_runtforcetpt out_stringtresultt entry_pointt msvcr_successtmsvcr_dbg_successt msvcr_version((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyR%?sp                 cC`st}|r.|sg}n|j|n||||||||d| | | | | f}|jdkrtjjj}n tj}|||j j dS(Ns3.0.0( R tappendRR&R"R#R$tlinkRt__code__t co_argcount(R7t target_desctobjectstoutput_filenamet output_dirt librariest library_dirstruntime_library_dirstexport_symbolsRt extra_preargstextra_postargst build_tempt target_langtruntime_librarytargstfunc((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyRCs0    Rc C`s1|dkrd}ng}x|D]}tjjtjj|\}}tjj|\}}|rw|d}n||jddgkrtd||fn|rtjj|}n|dks|dkr|j tjj ||||j q"|j tjj |||j q"W|S(NRis.rcs.ress"unknown file type '%s' (from '%s')( Rtostpathtsplitexttnormcaset splitdrivetsrc_extensionsR tbasenameRBtjoint obj_extension( R7tsource_filenamest strip_dirRIt obj_namestsrc_nametbasetexttdrv((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytobject_filenamess(  $ N(t__name__t __module__t__doc__t compiler_typeR%RRCRe(((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyR8s r c C`stjg}ttdr@tjtjkr@|jtjn4ttdrttjtjkrt|jtjndddg}g}x;|D]3}x*|D]"}|jtjj||qWqWdtj kr|jtjjtj ddnt tj d \}}d g}xh|D]`}|||f} t d | x9|D]1}tjj|| } tjj | rP| SqPWq%Wtd | |fdS( Nt base_prefixt real_prefixRtlibtbint SYSTEMROOTtSystem32ispython%d%d.dllsLooking for %ss%s not found in %s(tsystprefixthasattrRjRBRkRURVR\tenvironttuplet version_infotprinttexistst ValueError( tstemstsub_dirstlib_dirststemtfoldert major_versiont minor_versiontpatternstpattdllnametdll((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytfind_python_dlls, !!  $&    cC`s.tjdd|gdtj}|jjS(Ns objdump.exes-pR(R'R(R*Rt readlines(Rtst((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt dump_tables!c C`s}t|}xCtt|D]#}tj||jrPqqWtdg}xut|dt|D]Z}tj||j}|r|jt |j dj |j dfqrPqrWt|dkrt j d|nt|d}|jdtjj||jd|jd |jd x#|D]}|jd |dqPW|jd S( sGiven a dll file location, get all its exported symbols and dump them into the given def file. The .def file will be overwrittensSymbol table not foundiiisNo symbols found in %stwsLIBRARY %s s,;CODE PRELOAD MOVEABLE DISCARDABLE s;DATA PRELOAD SINGLE s EXPORTS s%s N(Rtrangetlent_STARTtmatchtdecodeRxt_TABLERBtintR/tstripRtwarntopentwriteRURVR[R,( Rtdfiletdumptitsymstjtmtdts((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt generate_def#s*   4    c`sIidd6dd6tfd}d}||pH||S(Ntamd64Rtx86tIntelc`stjjtjjddd}tjj|s:dSxKtj|D]:\}}}||krJ|krJtjj||SqJWdS(NtWINDIRs C:\WINDOWStwinsxs(RURVR\RstgetRwRtwalk(tdll_namet winsxs_pathtroottdirstfiles(tarch(sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt_find_dll_in_winsxsIs cS`sfx_tjgtjdjdD]=}tjj||}tjj|r!tjj|Sq!WdS(NtPATHt;( RpRqRURstsplitRVR\Rwtabspath(RRVtfilepath((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt_find_dll_in_pathTs'(R(RRR((Rsp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytfind_dllDs   c C`sqtjdkrtSt}|dkr9tjdtS|dkrVtjdtSt}|rr|d7}nd|}tjj t j d|}tjj |rtjd|ft S|d }t|}|stjd |tSd |}tjj t j d|}tjd ||ft||d d|d|g} tj| } tj|| S(Ntnts?Skip building import library: Runtime is not compiled with MSVCiPs=Skip building msvcr library: custom functionality not presentRslib%s.atlibss(Skip building msvcr library: "%s" existss.dlls*Cannot build msvcr library: "%s" not founds lib%s.defs&Building msvcr library: "%s" (from %s)tdlltools-ds-l(RUtnametFalseRRRRR RVR\RpRqtisfileR)RRtinfoRR'tcalltremove( Rt msvcr_vert msvcr_nametout_nametout_filetmsvcr_dll_nametdll_filetdef_nametdef_filetcmdtretcode((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyR3^sB                 cC`sVtjdkrdSt}|dkr/tS|dkrBtStd|dS(NRRRsUnhandled arch %s(RURRt_build_import_library_amd64t_build_import_library_x86Rx(R((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyR2s   c C`sKttjd \}}dddg}tjg}ttdrhtjtjkrh|jtjn4ttdrtjtjkr|jtjnddg}g}x_|D]W}|||f}x>|D]6}x-|D]%} |jtj j || |qWqWqWx*|D]"} tj j | rt | fSqWt |d fS( sACheck if an import library for the Python runtime already exists.islibpython%d%d.aslibpython%d%d.dll.aslibpython%d.%d.dll.aRjRkRRli(RtRpRuRqRrRjRBRkRURVR\RR)R( R~RRRyRzt candidatesRtfilenametstem_dirR}tfullname((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt_check_for_import_libs(  !!    + cC`st\}}|r)tjd|dSt}tjd||fdttjd }tj j tj d|}t ||dd|d|g}t j|dS( Ns)Skip building import library: "%s" existss4Building import library (arch=AMD64): "%s" (from %s)spython%d%d.defiRRs-ds-l(RRRRRRtRpRuRURVR\RqRR'R((t out_existsRRRRR((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyRs   cC`st\}}|r)tjd|dSdttjd }tjjtj d|}tjj |st tdrtjjtj d|}n3t tdrtjjtj d|}nd}tjj |r|}qtjd |dSntjd |d d lm}d ttjd }tjjtj d|}d|j|f}|j|} |j| \} } |j| | |jt|dt} | ||f} d| }tj|}|rtjdndS(s; Build the import libraries for Mingw32-gcc on Windows s)Skip building import library: "%s" existsNspython%d%d.libiRRjRkRs+Cannot build import library: "%s" not founds(Building import library (ARCH=x86): "%s"i(tlib2defspython%d%d.defs%s %sRs3dlltool --dllname "%s" --def "%s" --output-lib "%s"s:Failed to build import library for gcc. Linking will fail.(RRRRtRpRuRURVR\RqRRrRjRkRRtnumpy.distutilsRt DEFAULT_NMtgetnmtparse_nmt output_deft DEF_HEADERRRtsystem(RRtlib_nametlib_filetbase_libRRRtnm_cmdt nm_outputtdlisttflistRRSRtstatus((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyRs> "  twin32s 8.0.50727.42t80s 9.0.21022.8t90s10.0.30319.460t100tCRT_ASSEMBLY_VERSIONt.is9Cannot import msvcrt: using manifest will not be possiblecC`siytt|d|}Wn'tk rEtd||fnXd}|i|d6|d6|d6S(sUGiven a major and minor version of the MSVCR, returns the corresponding XML file.i s)Version %d,%d of MSVCRT not supported yetsS tfullvertmajtmin(t_MSVCRVER_TO_FULLVERtstrtKeyErrorRx(RRRttemplate((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytmsvc_manifest_xml1s RcC`sH|dkrd}n%|dkr*d}ntd|d||fS(sWReturn the rc file used to generate the res file which will be embedded as manifest for given manifest file name, of given type ('dll' or 'exe'). Parameters ---------- name : str name of the manifest file to embed type : str {'dll', 'exe'} type of the binary which will embed the manifest RitexeisType %s not supporteds&#include "winuser.h" %d RT_MANIFEST %s(Rx(Rttypetrctype((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt manifest_rcQs    cC`sGt}|rC|t|ksCtdt||fqCndS(s6msver is the ms runtime version used for the MANIFEST.sKDiscrepancy between linked msvcr (%d) and the one about to be embedded (%d)N(RRRx(tmsverR((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt!check_embedded_msvcr_match_linkedis  cC`s5tjj|jdgd}tjj|dS(Ntyotci(RURVR[t_gen_temp_sourcefileRW(tconfigRb((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytconfigtest_nameus!cC`s$t|}|jj}||dS(Ns .manifest(RRt exe_extension(RRtexext((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt manifest_nameys  cC`st|}|dS(Ns.rc(R(RR((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytrc_names cC`st}|dk r|dkrt|t|}t||d}t||}tt|d}|jjt||j ||j qndS(Nii R( tget_build_msvc_versionRRRRRRt temp_filesRBRR,(RRtmatmitmanxmltman((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pytgenerate_manifests      (GRht __future__RRRRURpR'R-tnumpy.distutils.ccompilertnumpyRuRRRtdistutils.cygwinccompilerR"tdistutils.versionRRRtdistutils.unixccompilerRtdistutils.msvccompilerRRtdistutils.errorsR R R tnumpy.distutils.misc_utilR R RRRR#t get_msvcrtcompileRRR$RRRRRRR3R2RRRRtplatformtmsvcrtRrRRtmajortminortrestt ImportErrorRRRRRRRR(((sp/home/ec2-user/environment/lambda-staging/venv/lib64/python2.7/dist-packages/numpy/distutils/mingw32ccompiler.pyt sd      "   &  !  ; $  ?