Your IP : 13.59.5.179


Current Path : /opt/alt/python34/lib64/python3.4/distutils/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/distutils/__pycache__/msvccompiler.cpython-34.pyc

�
i f�[�@sdZddlZddlZddlmZmZmZmZmZddl	m
Z
mZmZddl
mZdZy@ddlZdZeZejZejZejZejZWn�ek
r:yLddlZddlZdZeZejZejZejZejZWnek
r5ejd�YnXYnXerbejejej ej!fZ"nd	d
�Z#dd�Z$d
d�Z%Gdd�d�Z&dd�Z'dd�Z(dd�Z)Gdd�de
�Z*e'�dkrej+d�e*Z,ddl-m*Z*ddl-m&Z&ndS)z�distutils.msvccompiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio.
�N)�DistutilsExecError�DistutilsPlatformError�CompileError�LibError�	LinkError)�	CCompiler�gen_preprocess_options�gen_lib_options)�logFTz�Warning: Can't read registry to find the necessary compiler setting
Make sure that Python modules winreg, win32api or win32con are installed.cCs�yt||�}Wntk
r+dSYnXg}d}xDyt||�}Wntk
rcPYnX|j|�|d7}q;W|S)zReturn list of registry keys.Nr�)�RegOpenKeyEx�RegError�
RegEnumKey�append)�base�key�handle�L�i�k�r�;/opt/alt/python34/lib64/python3.4/distutils/msvccompiler.py�	read_keys7s
	

rcCs�yt||�}Wntk
r+dSYnXi}d}xbyt||�\}}}Wntk
rlPYnX|j�}t|�|t|�<|d7}q;W|S)zXReturn dict of registry keys and values.

    All names are converted to lowercase.
    Nrr)rr
�RegEnumValue�lower�convert_mbcs)rrr�dr�name�value�typerrr�read_valuesHs
	
r cCsJt|dd�}|dk	rFy|d�}WqFtk
rBYqFXn|S)N�decode�mbcs)�getattr�UnicodeError)�sZdecrrrr]s
rc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
MacroExpandercCsi|_|j|�dS)N)�macros�load_macros)�self�versionrrr�__init__gs	zMacroExpander.__init__cCsCx<tD]4}t||�}|r|||jd|<PqqWdS)Nz$(%s))�HKEYSr r')r)Zmacro�pathrrrrrr�	set_macroks

zMacroExpander.set_macroc
Cs=d|}|jd|dd�|jd|dd�d}|jd|d	�y9|d
krv|jd|d�n|jd|d
�Wn1tk
r�}ztd��WYdd}~XnXd}xrtD]j}yt||�}Wntk
r�w�YnXt|d�}t|d||f�}	|	d|jd<q�WdS)Nz%Software\Microsoft\VisualStudio\%0.1fZVCInstallDirz	\Setup\VCZ
productdirZVSInstallDirz	\Setup\VSz Software\Microsoft\.NETFrameworkZFrameworkDirZinstallrootg@ZFrameworkSDKDirzsdkinstallrootv1.1ZsdkinstallrootaPython was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.z.Software\Microsoft\NET Framework Setup\Productrz%s\%sr*z$(FrameworkVersion))	r.�KeyErrorrr,rr
rr r')
r)r*ZvsbaseZnet�exc�pr�hrrrrrr(rs*


zMacroExpander.load_macroscCs6x/|jj�D]\}}|j||�}qW|S)N)r'�items�replace)r)r%r�vrrr�sub�szMacroExpander.subN)�__name__�
__module__�__qualname__r+r.r(r6rrrrr&fsr&cCs�d}tjj|�}|d
kr(dS|t|�}tj|d�jdd�\}}t|dd��d}t|dd��d}|dkr�d	}n|dkr�||SdS)z�Return the version of MSVC that was used to build Python.

    For Python 2.3 and up, the version number is included in
    sys.version.  For earlier versions, assume the compiler is MSVC 6.
    zMSC v.r�N� ��g$@r������)�sysr*�find�len�split�int)�prefixrr%�restZmajorVersionZminorVersionrrr�get_build_version�s%	rGcCsXd}tjj|�}|dkr(dStjjd|�}tj|t|�|�S)zaReturn the processor architecture.

    Possible results are "Intel", "Itanium", or "AMD64".
    z bit (r�Intel�)r>)r@r*rArB)rEr�jrrr�get_build_architecture�srKcCsIg}x<|D]4}tjj|�}||kr
|j|�q
q
W|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )�osr-�normpathr)�pathsZ
reduced_pathsr1Znprrr�normalize_and_reduce_paths�s
rOc@sseZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZddddd�Zdd�Zdddd�Zddddddddd�Zddddd�Zdddddddddddd�
Zdd�Zd d!�Zd"d#�Zdd$d%�Zd&d'�Zd(d)d*�Zd+d,�ZdS)-�MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++,
       as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxxz.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCs�tj||||�t�|_t�|_|jdkr�|jdkrjd|_t|j�|_n	d|_d|j|_	nd|jd|_	d|_
dS)	NrH�zSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr:F)rr+rG�_MSVCCompiler__versionrK�_MSVCCompiler__arch�_MSVCCompiler__rootr&�_MSVCCompiler__macros�_MSVCCompiler__product�initialized)r)�verboseZdry_runZforcerrrr+�s		zMSVCCompiler.__init__cCs�g|_dtjkrfdtjkrf|jd�rfd|_d|_d|_d|_d|_n�|j	d�|_t
|j�d	kr�td
|j��n|jd�|_|jd�|_|jd�|_|jd�|_|jd�|_|j
d�|j
d�y5x.tjdjd
�D]}|jj|�q1WWntk
r`YnXt|j�|_d
j|j�tjd<d|_|jdkr�ddddddg|_dddddddg|_n9ddddddg|_dddddddg|_dddg|_|jdkrRddddg|_ndddddg|_dg|_d |_dS)!NZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer-rzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.�lib�include�;rHz/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrQz/INCREMENTAL:noz/DEBUGz	/pdb:NoneT)�_MSVCCompiler__pathsrL�environ�find_exe�cc�linkerrY�rc�mc�get_msvc_pathsrBrrV�set_path_env_varrCrr/rO�joinZpreprocess_optionsrS�compile_options�compile_options_debug�ldflags_sharedrR�ldflags_shared_debugZldflags_staticrW)r)r1rrr�
initialize�sR	-				


	zMSVCCompiler.initialize�cCsD|dkrd}ng}x"|D]}tjj|�\}}tjj|�d}|tjj|�d�}||jkr�td|��n|r�tjj|�}n||jkr�|j	tjj
|||j��q"||jkr|j	tjj
|||j��q"|j	tjj
|||j
��q"W|S)NrkrzDon't know how to compile %s)rLr-�splitext�
splitdrive�isabs�src_extensionsr�basename�_rc_extensionsrre�
res_extension�_mc_extensions�
obj_extension)r)Zsource_filenamesZ	strip_dir�
output_dirZ	obj_namesZsrc_namer�extrrr�object_filenames5s(	
zMSVCCompiler.object_filenamesNc	Cs|js|j�n|j||||||�}	|	\}}
}}}|pRg}
|
jd�|r{|
j|j�n|
j|j�x�|
D]�}y||\}}Wntk
r�w�YnX|r�tj	j
|�}n||jkr�d|}n�||jkrd|}n�||j
kr�|}d|}y)|j|jg||g|g�Wq�tk
r�}zt|��WYdd}~Xq�Xq�n||jkr�tj	j|�}tj	j|�}y�|j|jgd|d|g|g�tj	jtj	j|��\}}tj	j||d�}|j|jgd|g|g�Wq�tk
r�}zt|��WYdd}~Xq�Xq�ntd||f��d	|}y-|j|jg|
|||g|�Wq�tk
r}zt|��WYdd}~Xq�Xq�W|
S)
Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)rWrjZ_setup_compiler�extendrgrfr/rLr-�abspath�
_c_extensions�_cpp_extensionsrq�spawnrarrrs�dirnamerbrlrprer_)r)Zsourcesrur'Zinclude_dirs�debug�
extra_preargs�extra_postargsZdependsZcompile_info�objectsZpp_optsZbuildZcompile_opts�obj�srcrvZ	input_optZ
output_opt�msgZh_dirZrc_dirr�_Zrc_filerrr�compileTsj	






#$$#
#zMSVCCompiler.compilec	Cs�|js|j�n|j||�\}}|j|d|�}|j||�r�|d|g}|rony|j|jg|�Wq�tk
r�}zt|��WYdd}~Xq�Xnt	j
d|�dS)Nruz/OUT:zskipping %s (up-to-date))rWrj�_fix_object_args�library_filename�
_need_linkr|rYrrr
r~)	r)r�Zoutput_libnamerur~�target_lang�output_filenameZlib_argsr�rrr�create_static_lib�s	
	"zMSVCCompiler.create_static_libcCs�|js|j�n|j||�\}}|j|||�}|\}}}|rr|jdt|��nt||||�}|dk	r�tjj	||�}n|j
||�rp|tjkr�|	r�|j
dd�}q|jdd�}n|	r|j
}n	|j}g}x%|p+gD]}|jd|�q,W||||d|g}|dk	r�tjjtjj|��\}}tjj	tjj|d�|j|��}|jd|�n|
r�|
|dd�<n|r|j|�n|jtjj|��y|j|jg|�Wq�tk
rl}zt|��WYdd}~Xq�Xntjd|�dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:z/OUT:rz/IMPLIB:zskipping %s (up-to-date))rWrjr�Z
_fix_lib_args�warn�strr	rLr-rer�rZ
EXECUTABLErirhrrlrpr}r�rxZmkpathr|r`rrr
r~)r)Ztarget_descr�r�ruZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr~rr�Z
build_tempr�Z
fixed_argsZlib_optsZldflagsZexport_optsZsymZld_argsZdll_nameZdll_extZimplib_filer�rrr�link�sV	
						"zMSVCCompiler.linkcCsd|S)Nz	/LIBPATH:r)r)�dirrrr�library_dir_optionszMSVCCompiler.library_dir_optioncCstd��dS)Nz<don't know how to set runtime library search path for MSVC++)r)r)r�rrr�runtime_library_dir_optionsz'MSVCCompiler.runtime_library_dir_optioncCs
|j|�S)N)r�)r)rYrrr�library_optionszMSVCCompiler.library_optioncCs�|r|d|g}n	|g}xW|D]K}xB|D]:}tjj||j|��}tjj|�r6|Sq6Wq)WdSdS)NZ_d)rLr-rer��exists)r)�dirsrYr~Z	try_namesr�rZlibfilerrr�find_library_file s	

zMSVCCompiler.find_library_filecCs�xH|jD]=}tjjtjj|�|�}tjj|�r
|Sq
WxUtjdjd�D]=}tjjtjj|�|�}tjj|�rb|SqbW|S)a�Return path to an MSVC executable program.

        Tries to find the program in several places: first, one of the
        MSVC program search paths from the registry; next, the directories
        in the PATH environment variable.  If any of those work, return an
        absolute path that is known to exist.  If none of them work, just
        return the original program name, 'exe'.
        ZPathr[)r\rLr-rery�isfiler]rC)r)Zexer1�fnrrrr^2s	!!zMSVCCompiler.find_exeZx86cCs	ts
gS|d}|jdkr<d|j|jf}nd|j|f}xctD][}t||�}|rV|jdkr�|jj||�jd�S||jd�SqVqVW|jdkrx>tD]3}t|d|j�dk	r�|jd	�Pq�q�WngS)
z�Get a list of devstudio directories (include, lib or path).

        Return a list of strings.  The list will be empty if unable to
        access the registry or appropriate registry keys not found.
        z dirsrQz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr[r:z%s\6.0Nz�It seems you have Visual Studio 6 installed, but the expected registry settings are not present.
You must at least run the Visual Studio GUI once so that these entries are created.)	�
_can_read_regrRrTr,r rUr6rCr�)r)r-�platformrrrrrrrcHs(



zMSVCCompiler.get_msvc_pathscCsP|dkr|jd�}n|j|�}|rLdj|�tj|<ndS)z�Set environment variable 'name' to an MSVC path type value.

        This is equivalent to a SET command prior to execution of spawned
        commands.
        rYZlibraryr[N)rcrerLr])r)rr1rrrrdls
zMSVCCompiler.set_path_env_var)r7r8r9�__doc__Z
compiler_typeZexecutablesrzr{rqrsrorrrtZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr+rjrwr�r�r�r�r�r�r�r^rcrdrrrrrP�sP			
BVF$rPg @z3Importing new compiler from distutils.msvc9compiler)rP)r&).r�r@rLZdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
r��winregZhkey_modZ	OpenKeyExrZEnumKeyrZ	EnumValuer�errorr
�ImportErrorZwin32apiZwin32con�infoZ
HKEY_USERS�HKEY_CURRENT_USER�HKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr,rr rr&rGrKrOrPr~ZOldMSVCCompilerZdistutils.msvc9compilerrrrr�<module>sZ(			

			



	-
��


?>