Current File : //usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyc
�
E�`Qc@s�dZddlZddlZddlZddlZddlZddlZejddkrpddlZnddl	mZddl
Zddlm
Z
ddlmZmZddlmZmZmZdd	lmZdd
lmZddlmZmZejd�Zejd
�Zdejj fd��YZ!d�Z"d�Z#d�Z$d�Z%e&d�Z'd�Z(d�Z)d�Z*iZ+ej,dkr:yxddl-Z-de+d<de+d<de+d<e.e-d�re-j/j0d d!�\Z1Z2Z3e-j/e+e1e2<[1[2[3nWq:e4k
r6ej5d"�q:Xnd#�Z6d$d%�Z7d&�Z8d'�Z9d(�Z:d)�Z;d*�Z<dS(+s
Support code for building Python extensions on Windows.

    # NT stuff
    # 1. Make sure libpython<version>.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����Nii(tlog(t
StrictVersion(tgen_preprocess_optionstgen_lib_options(tDistutilsExecErrortCompileErrortUnknownFileError(t
UnixCCompiler(tget_build_version(tmsvc_runtime_librarytget_build_architectures\[Ordinal/Name Pointer\] Tables$^\s+\[([\s*[0-9]*)\] ([a-zA-Z0-9_]*)tMingw32CCompilercBsPeZdZdZdddd�Zddddddd�Zddd�ZRS(sH A modified MingW32 compiler compatible with an MSVC built Python.

    tmingw32icCswtjjj||||�|jdkr�ddl}tjddgdt	dtj
�}|jj�}|jj
�|jd|�}|r�t|jd��|_q�n|jdkr�d	}nd
}|jdkr�d|_n|jdkrd|_nt�t�}	td
t	�}
|	s,|
r<|jd�ndtt�jd��}|jd|�t�dkr�|jdkr�|jdddddddd�qg|jdddddddd�n�|jd kr|jdd!dd"dd#dd$|j|f�nV|jdkrE|jdd%dd&dd#dd'�n"|jdd(dd)dd*dd+�dg|_dS(,Ni����tgccs-dumpversiontshelltstdouts
(\d+\.\d+)is2.91.57s--entry _DllMain@12ttdllwrapsg++tdebugtNPY_MINGW_USE_CUSTOM_MSVCRs0x%03i0tmsvcrt__MSVCRT_VERSION__tAMD64s4.0tcompilers/gcc -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Walltcompiler_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++ sg++ -shared(t	distutilstcygwinccompilertCygwinCCompilert__init__tgcc_versiontNonetret
subprocesstPopentTruetPIPERtreadtclosetsearchRtgroupt
linker_dlltlinkertbuild_import_librarytbuild_msvcr_librarytdefine_macrotintR	tlstripR
tset_executablestcompiler_cxx(tselftverbosetdry_runtforceR!tpt
out_stringtresulttentry_pointt
msvcr_successtmsvcr_dbg_successt
msvcr_version((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR3sl

			
	

cCs�t�}|r.|sg}n|j|�n||||||||d|	|
|||
f}|jdkrtjjj}n	tj}t	j
ddkr�|||jj �n|||j
jj �dS(Ns3.0.0ii(R	tappendR RRRRtlinkRtsystversion_infot__code__tco_argcounttim_funct	func_code(R3ttarget_desctobjectstoutput_filenamet
output_dirt	librariestlibrary_dirstruntime_library_dirstexport_symbolsRt
extra_preargstextra_postargst
build_tempttarget_langtruntime_librarytargstfunc((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR?�s4				Rc	Cs1|dkrd}ng}x|D]}tjjtjj|��\}}tjj|�\}}|rw|d}n||jddgkr�td||f��n|r�tjj|�}n|dks�|dkr|j	tjj
||||j��q"|j	tjj
|||j��q"W|S(NRis.rcs.ress"unknown file type '%s' (from '%s')(R tostpathtsplitexttnormcaset
splitdrivetsrc_extensionsRtbasenameR>tjoint
obj_extension(	R3tsource_filenamest	strip_dirRIt	obj_namestsrc_nametbasetexttdrv((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytobject_filenames�s(	
$
N(t__name__t
__module__t__doc__t
compiler_typeRR R?Re(((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR,su"cCsgtjd D]}t|�^q\}}}d||f}d|GHg}|jtj�|jtjjtjd��y'|jtjjtjdd��Wnt	k
r�nXx9|D]1}tjj||�}tjj
|�r�|Sq�Wtd||f��dS(Nispython%d%d.dllsLooking for %stlibt
SYSTEMROOTtsystem32s%s not found in %s(R@RAR/R>tprefixRURVR\tenvirontKeyErrortexistst
ValueError(titmajtmintmicrotdllnametlib_dirstdtdll((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytfind_python_dll�s/	'

cCs.tjdd|gdtj�}|jj�S(Nsobjdump.exes-pR(R"R#R%Rt	readlines(Rytst((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt
dump_tables!c	Cs}t|�}xCtt|��D]#}tj||j��rPqqWtd��g}xut|dt|��D]Z}tj||j��}|r�|jt	|j
d�j��|j
d�f�qrPqrWt|�dkr�tj
d|�nt|d�}|jdtjj|��|jd�|jd	�|jd
�x#|D]}|jd|d�qPW|j�dS(
s�Given 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(R}trangetlent_STARTtmatchtdecodeRqt_TABLER>R/R)tstripRtwarntopentwriteRURVR[R'(	RytdfiletdumpRrtsymstjtmRxts((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytgenerate_defs* 4



csIidd6dd6t���fd�}d�}||�pH||�S(Ntamd64Rtx86tIntelcs�tjjtjdd�}tjj|�s2dSxKtj|�D]:\}}}||krB�|krBtjj||�SqBWdS(NtWINDIRtwinsxs(RURVR\RnRpR twalk(tdll_nametwinsxs_pathtroottdirstfiles(tarch(sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt_find_dll_in_winsxs5scSsfx_tjgtjdjd�D]=}tjj||�}tjj|�r!tjj|�Sq!WdS(NtPATHt;(	R@RmRURntsplitRVR\Rptabspath(R�RVtfilepath((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt_find_dll_in_path?s'(R
(R�R�R�((R�sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytfind_dll0s


	c
CsWtjdkrtSt�}t|jd��dkrHtjd�tS|r[|d7}nd|}tjj	t
jd|�}tjj|�r�tjd|�t
S|d	}t|�}|s�tjd
|�tSd|}tjj	t
jd|�}tjd||f�t||�d
d|d|g}tj|�}	tj|�|	S(NtntRiPs=Skip building msvcr library: custom functionality not presentRxslib%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(RUtnametFalseR	R/R0RRRVR\R@RmtisfileR$R�R�tinfoR�R"tcalltremove(
Rt
msvcr_nametout_nametout_filetmsvcr_dll_nametdll_filetdef_nametdef_filetcmdtretcode((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR-Is6	




	

cCsVtjdkrdSt�}|dkr/t�S|dkrBt�Std|��dS(NR�RR�sUnhandled arch %s(RUR�R
t_build_import_library_amd64t_build_import_library_x86Rq(R�((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR,ws	cCs�t�}dttjd �}tjjtjd|�}tjj|�rbt	j
d|�dSdttjd �}tjjtjd|�}t	jd||f�t||�dd|d	|g}t
j|�dS(
Nslibpython%d%d.aiR�s)Skip building import library: "%s" existsspython%d%d.defs4Building import library (arch=AMD64): "%s" (from %s)R�s-ds-l(RzttupleR@RARURVR\RmR�RRR�R�R"R#(R�R�R�R�R�R�((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR��s		
cCs�dttjd �}tjjtjd|�}dttjd �}tjjtjd|�}tjj|�s�tj	d|�dStjj|�r�tj
d|�dStjd|�d	d
lm
}dttjd �}tjjtjd|�}d|j|f}|j|�}|j|�\}	}
|j|	|
|jt|d
��dttjd �}|||f}d|}
tj|
�}|r�tj	d�ndS(s; Build the import libraries for Mingw32-gcc on Windows
    spython%d%d.libiR�slibpython%d%d.as+Cannot build import library: "%s" not foundNs)Skip building import library: "%s" existss(Building import library (ARCH=x86): "%s"i����(tlib2defspython%d%d.defs%s %sR~spython%d%d.dlls-dlltool --dllname %s --def %s --output-lib %ss:Failed to build import library for gcc. Linking will fail.(R�R@RARURVR\RmR�RR�RR�tnumpy.distutilsR�t
DEFAULT_NMtgetnmtparse_nmt
output_deft
DEF_HEADERR�tsystem(tlib_nametlib_fileR�R�R�R�R�tnm_cmdt	nm_outputtdlisttflistR�RSR�tstatus((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyR��s2"
twin32s8.0.50727.42t80s9.0.21022.8t90s10.0.30319.460t100tCRT_ASSEMBLY_VERSIONt.is9Cannot import msvcrt: using manifest will not be possiblecCsiytt|d|�}Wn'tk
rEtd||f��nXd}|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<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC%(maj)d%(min)d.CRT" version="%(fullver)s" processorArchitecture="*" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>tfullverRsRt(t_MSVCRVER_TO_FULLVERtstrRoRq(RsRtR�ttemplate((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytmsvc_manifest_xml�s
RycCsH|dkrd}n%|dkr*d}ntd|��d||fS(sOReturn 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 manifestRyitexeisType %s not supporteds&#include "winuser.h"
%d RT_MANIFEST %s(Rq(R�ttypetrctype((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytmanifest_rcs
		cCsut�}|rq|jd�s*t|��t|dd!�}|t|�ksqtdt|�|f��qqndS(s6msver is the ms runtime version used for the MANIFEST.Rii����sKDiscrepancy between linked msvcr (%d) and the one about to be embedded (%d)N(R	t
startswithtAssertionErrorR/Rq(tmsvertmsvcvRs((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt!check_embedded_msvcr_match_linkeds	cCs5tjj|jdgd��}tjj|�dS(Ntyotci(RURVR[t_gen_temp_sourcefileRW(tconfigRb((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytconfigtest_name%s!cCs$t|�}|jj}||dS(Ns	.manifest(R�Rt
exe_extension(R�R�texext((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt
manifest_name)scCst|�}|dS(Ns.rc(R�(R�R�((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytrc_name/scCs�t�}|dk	r�|dkr�t|�t|�}t||d�}t||�}tt|�d�}|jjt|��|j	|�|j
�q�ndS(Nii
R~(tget_build_msvc_versionR R�R/R�R�R�t
temp_filesR>R�R'(R�R�tmatmitmanxmltman((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pytgenerate_manifest4s	

(=RhRUR"R@R!tnumpy.distutils.ccompilertnumpyRARR�tdistutils.cygwinccompilerRtdistutils.versionRRRtdistutils.errorsRRRtdistutils.unixccompilerRtdistutils.msvccompilerRR�tnumpy.distutils.misc_utilR	R
tcompileR�R�RRRRzR}R�R�R�R-R,R�R�R�tplatformtmsvcrtthasattrR�R�tmajortminortresttImportErrorR�R�R�R�R�R�R�R�(((sF/usr/lib64/python2.7/site-packages/numpy/distutils/mingw32ccompiler.pyt<module>	s^�			!	.			5