• File: msvc9compiler.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/distutils/__pycache__/msvc9compiler.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 16.97 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Mj/w@sRdZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
ddlmZm
Z
mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dkoej"dkZ#e#rd	Z$d
Z%dZ&ndZ$d
Z%dZ&dddZ'GdddZ(GdddZ)ddZ*ddZ+ddZ,ddZ-d$ddZ.e*Z/e/d kr>ed!e/Gd"d#d#eZ0dS)%adistutils.msvc9compiler

Contains MSVCCompiler, an implementation of the abstract CCompiler class
for the Microsoft Visual Studio 2008.

The module is compatible with VS 2005 and VS 2008. You can find legacy support
for older versions of VS in distutils.msvccompiler.
N)DistutilsExecErrorDistutilsPlatformErrorCompileErrorLibError	LinkError)	CCompilergen_preprocess_optionsgen_lib_options)log)get_platformwin32lz1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fz5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowsz,Software\Wow6432Node\Microsoft\.NETFrameworkz%Software\Microsoft\VisualStudio\%0.1fz)Software\Microsoft\Microsoft SDKs\Windowsz Software\Microsoft\.NETFrameworkx86Zamd64)rz	win-amd64c@sPeZdZdZddZeeZddZeeZddZeeZdd	Ze	eZd
S)Regz2Helper class to read values from the registry
    cCs:x,tD]$}|||}|r||kr||SqWt|dS)N)HKEYSread_valuesKeyError)clspathkeybasedr</opt/alt/python37/lib64/python3.7/distutils/msvc9compiler.py	get_value@s

z
Reg.get_valuecCsnyt||}Wntk
r"dSXg}d}x<yt||}Wntk
rRPYnX|||d7}q.W|S)zReturn list of registry keys.Nr)RegOpenKeyExRegError
RegEnumKeyappend)rrrhandleLikrrr	read_keysHs
z
Reg.read_keysc	Csyt||}Wntk
r"dSXi}d}xTyt||\}}}Wntk
rXPYnX|}|||||<|d7}q.W|S)z`Return dict of registry keys and values.

        All names are converted to lowercase.
        Nrr)rrRegEnumValuelowerconvert_mbcs)	rrrrrr!namevaluetyperrrrZszReg.read_valuescCs:t|dd}|dk	r6y|d}Wntk
r4YnX|S)Ndecodembcs)getattrUnicodeError)sZdecrrrr&pszReg.convert_mbcsN)
__name__
__module____qualname____doc__rclassmethodr#rr&staticmethodrrrrr<src@s,eZdZddZddZddZddZd	S)

MacroExpandercCsi|_t||_||dS)N)macrosVS_BASEvsbaseload_macros)selfversionrrr__init__|s
zMacroExpander.__init__cCst|||jd|<dS)Nz$(%s))rrr6)r:Zmacrorrrrr	set_macroszMacroExpander.set_macroc	Cs|d|jdd|d|jdd|dtdy$|dkrP|d	td
ntd
Wntk
rvtdYnX|dkr|d
|jd|dtdndd}x^tD]V}yt||}Wntk
rwYnXt	|d}t
|d||f}|d|jd<qWdS)NZVCInstallDirz	\Setup\VC
productdirZVSInstallDirz	\Setup\VSZFrameworkDirZinstallrootg @ZFrameworkSDKDirzsdkinstallrootv2.0aPython was built with Visual Studio 2008;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2008 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.g"@ZFrameworkVersionzclr versionZ
WindowsSdkDirZcurrentinstallfolderz.Software\Microsoft\NET Framework Setup\Productrz%s\%sr;z$(FrameworkVersion))
r=r8NET_BASErrWINSDK_BASErrrrrrr6)r:r;prhrrrrrr9s.

zMacroExpander.load_macroscCs(x"|jD]\}}|||}qW|S)N)r6itemsreplace)r:r.r"vrrrsubszMacroExpander.subN)r/r0r1r<r=r9rFrrrrr5zsr5cCsd}tj|}|dkrdS|t|}tj|ddd\}}t|ddd}|dkrf|d7}t|d	d
d}|dkrd}|dkr||SdS)
zReturn 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.N r
g$@r)sysr;findlensplitint)prefixr!r.restZmajorVersionZminorVersionrrrget_build_versionsrUcCs4g}x*|D]"}tj|}||kr
||q
W|S)znReturn a list of normalized paths with duplicates removed.

    The current order of paths is maintained.
    )osrnormpathr)pathsZ
reduced_pathsrAZnprrrnormalize_and_reduce_pathss
rYcCs@|tj}g}x|D]}||kr||qWtj|}|S)z8Remove duplicate values of an environment variable.
    )rQrVpathseprjoin)ZvariableZoldListZnewListr!ZnewVariablerrrremoveDuplicatess
r\cCst|}ytd|d}Wn"tk
r>tdd}YnX|rPtj|sd|}tj	
|d}|rtj|rtj|tjtjd}tj
|}tj|std|dSntd||std	dStj|d
}tj|r|StddS)zFind the vcvarsall.bat file

    At first it tries to find the productdir of VS 2008 in the registry. If
    that fails it falls back to the VS90COMNTOOLS env var.
    z%s\Setup\VCr>z%Unable to find productdir in registryNzVS%0.f0COMNTOOLSZVCz%s is not a valid directoryz Env var %s is not set or invalidzNo productdir foundz
vcvarsall.batzUnable to find vcvarsall.bat)r7rrrr
debugrVrisdirenvirongetr[pardirabspathisfile)r;r8r>ZtoolskeyZtoolsdir	vcvarsallrrrfind_vcvarsalls2





recCs<t|}ddddh}i}|dkr(tdtd||tjd||ftjtjd	}z|\}}|d
krzt|	d|	d}xr|
dD]d}t|}d
|krq|
}|
d
d\}	}
|	}	|	|kr|
tjr|
dd}
t|
||	<qWWd|j|jXt|t|kr8ttt||S)zDLaunch vcvarsall.bat and read the settings from its environment
    includelibZlibpathrNzUnable to find vcvarsall.batz'Calling 'vcvarsall.bat %s' (version=%s)z
"%s" %s & set)stdoutstderrrr+
=rrG)rerr
r]
subprocessPopenPIPEZcommunicatewaitr*rQrr&stripr%endswithrVrZr\rhcloserirP
ValueErrorstrlistkeys)r;ZarchrdZinterestingresultpopenrhrilinerr(rrrquery_vcvarsalls<



rzg @z(VC %0.1f is not supported by this modulec
@seZdZdZdZiZdgZdddgZdgZdgZ	eeee	Z
d	Zd
ZdZ
dZd
ZZdZd.ddZd/ddZd0ddZd1ddZd2ddZd3ddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd4d*d+Zd,d-ZdS)5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.exercCs8t||||t|_d|_g|_d|_d|_d|_dS)NzSoftware\Microsoft\VisualStudioF)	rr<VERSION_MSVCCompiler__versionZ_MSVCCompiler__root_MSVCCompiler__paths	plat_name_MSVCCompiler__archinitialized)r:verboseZdry_runZforcerrrr<IszMSVCCompiler.__init__NcCs,|jrtd|dkrt}d}||kr6td|fdtjkrtdtjkrt|drtd|_d|_d|_	d	|_
d
|_n|tks|dkrt|}nttdt|}t
t|}|d
tj|_|dtjd<|dtjd<t|jdkrtd|j|d|_|d|_|d|_	|d	|_
|d
|_y,x&tjd
dD]}|j|qJWWntk
rxYnXt|j|_d|jtjd
<d|_|jdkrdddddg|_ddddddg|_n&ddddddg|_dddddddg|_dddg|_|jd krddd!d"g|_dg|_d#|_dS)$Nzdon't init multiple times)rz	win-amd64z--plat-name must be one of %sZDISTUTILS_USE_SDKZMSSdkzcl.exezlink.exezlib.exezrc.exezmc.exer_rrgrfrzxPython was built with %s, and extensions need to be built with the same version of the compiler, but it isn't installed.;r
z/nologoz/Oxz/MDz/W3z/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOz/INCREMENTAL:noz/DEBUGT) rAssertionErrorrrrVr_find_execclinkerrgrcmcPLAT_TO_VCVARSrzr|rQrZr~rPZ_MSVCCompiler__productrrrYr[Zpreprocess_optionsrcompile_optionscompile_options_debugldflags_sharedr}ldflags_shared_debugZldflags_static)r:rZok_platsZ	plat_specZvc_envrArrr
initializeTsf







zMSVCCompiler.initializecCs|dkrd}g}x|D]}tj|\}}tj|d}|tj|d}||jkrdtd||rttj|}||jkr|	tj
|||jq||jkr|	tj
|||jq|	tj
|||j
qW|S)NrrzDon't know how to compile %s)rVrsplitext
splitdriveisabssrc_extensionsrbasename_rc_extensionsrr[
res_extension_mc_extensions
obj_extension)r:Zsource_filenamesZ	strip_dir
output_dirZ	obj_namesZsrc_namerextrrrobject_filenamess(



zMSVCCompiler.object_filenamesc	Cst|js||||||||}	|	\}}
}}}|p6g}
|
d|rT|
|jn|
|jx|
D]}y||\}}Wntk
rwhYnX|rtj	
|}||jkrd|}nT||jkrd|}n>||j
kr>|}d|}y"||jg||g|gWqhtk
r8}zt|Wdd}~XYqhXqhn||jkrtj	|}tj	|}yl||jgd|d|g|gtj	tj	|\}}tj	||d}||jgd|g|gWqhtk
r}zt|Wdd}~XYqhXqhntd||fd	|}y&||jg|
|||g|Wqhtk
rj}zt|Wdd}~XYqhXqhW|
S)
Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)rrZ_setup_compilerextendrrrrVrrb
_c_extensions_cpp_extensionsrspawnrrrrdirnamerrrr[r)r:Zsourcesrr6Zinclude_dirsr]
extra_preargsextra_postargsZdependsZcompile_infoobjectsZpp_optsZbuildZcompile_optsobjsrcrZ	input_optZ
output_optmsgZh_dirZrc_dirrrZrc_filerrrcompilesj




zMSVCCompiler.compilec	
Cs|js||||\}}|j||d}|||r|d|g}|rJy||jg|Wqtk
r}zt|Wdd}~XYqXnt	
d|dS)N)rz/OUT:zskipping %s (up-to-date))rr_fix_object_argslibrary_filename
_need_linkrrgrrr
r])	r:rZoutput_libnamerr]target_langoutput_filenameZlib_argsrrrrcreate_static_libszMSVCCompiler.create_static_libc
CsX|js||||\}}||||}|\}}}|rL|dt|t||||}|dk	rptj	||}|
||rH|tjkr|	r|j
dd}q|jdd}n|	r|j
}n|j}g}x|pgD]}|d|qW||||d|g}tj|d}|dk	rPtjtj|\}}tj	|||}|d||||||
rp|
|dd<|r|||tj|y||jg|Wn,tk
r}zt|Wdd}~XYnX|||}|dk	rT|\}}d||f}y|dd	d
||gWn,tk
rD}zt|Wdd}~XYnXntd|dS)Nz5I don't know what to do with 'runtime_library_dirs': rz/EXPORT:z/OUT:rz/IMPLIB:z-outputresource:%s;%szmt.exez-nologoz	-manifestzskipping %s (up-to-date))rrrZ
_fix_lib_argswarnrtr	rVrr[rr
EXECUTABLErrrrrrrmanifest_setup_ldargsrZmkpathrrrrmanifest_get_embed_infor
r])r:target_descrrrZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsr]rr
build_temprZ
fixed_argsZlib_optsZldflagsZexport_optsZsymld_argsZdll_nameZdll_extZimplib_filerZmfinfoZ
mffilenamemfidZout_argrrrlink6sl





zMSVCCompiler.linkcCs,tj|tj|d}|d|dS)Nz	.manifestz/MANIFESTFILE:)rVrr[rr)r:rrr
temp_manifestrrrrsz"MSVCCompiler.manifest_setup_ldargscCs`x,|D] }|dr|ddd}PqWdS|tjkr>d}nd}||}|dkrXdS||fS)Nz/MANIFESTFILE::rrL)
startswithrQrr_remove_visual_c_ref)r:rrargrrrrrrs



z$MSVCCompiler.manifest_get_embed_infocCsyt|}z|}Wd|Xtdtj}t|d|}d}t|d|}tdtj}t||dkrrdSt|d}z|||S|XWnt	k
rYnXdS)NzU<assemblyIdentity.*?name=("|')Microsoft\.VC\d{2}\.CRT("|').*?(/>|</assemblyIdentity>)rz*<dependentAssembly>\s*</dependentAssembly>zI<assemblyIdentity.*?name=(?:"|')(.+?)(?:"|').*?(?:/>|</assemblyIdentity>)w)
openreadrrrerDOTALLrFsearchwriteOSError)r:Z
manifest_fileZ
manifest_fZmanifest_bufpatternrrrrs.	


z!MSVCCompiler._remove_visual_c_refcCsd|S)Nz	/LIBPATH:r)r:dirrrrlibrary_dir_optionszMSVCCompiler.library_dir_optioncCstddS)Nz<don't know how to set runtime library search path for MSVC++)r)r:rrrrruntime_library_dir_optionsz'MSVCCompiler.runtime_library_dir_optioncCs
||S)N)r)r:rgrrrlibrary_optionszMSVCCompiler.library_optioncCs`|r|d|g}n|g}xB|D]6}x0|D](}tj|||}tj|r(|Sq(WqWdSdS)NZ_d)rVrr[rexists)r:dirsrgr]Z	try_namesrr'Zlibfilerrrfind_library_files

zMSVCCompiler.find_library_filecCszx4|jD]*}tjtj||}tj|r|SqWx>tjddD]*}tjtj||}tj|rH|SqHW|S)aReturn 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~rVrr[rbrcr_rQ)r:ZexerAfnrrrrs	zMSVCCompiler.find_exe)rrr)N)rr)NNNrNNN)NrN)
NNNNNrNNNN)r) r/r0r1r2Z
compiler_typeZexecutablesrrrrrrrZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ
exe_extensionr<rrrrrrrrrrrrrrrrrr{+sR


W

V

R+
r{)r
)1r2rVrlrNrZdistutils.errorsrrrrrZdistutils.ccompilerrrr	Z	distutilsr
Zdistutils.utilrwinregZ	OpenKeyExrZEnumKeyrZ	EnumValuer$errorrZ
HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTrplatformmaxsizeZNATIVE_WIN64r7r@r?rrr5rUrYr\rerzr|r{rrrr<module>sL>.#
)