U e5d \ @sddlZddlZddlmZmZmZmZmZddlm Z m Z m Z ddl m Z dZz,ddlZdZeZejZejZejZejZWnhek rz4ddlZddlZdZeZejZejZejZejZWnek re dYnXYnXerejejejej fZ!dd Z"d d Z#d d Z$GdddZ%ddZ&ddZ'ddZ(Gddde Z)e&dkr~e *de)Z+ddl,m)Z)ddl,m%Z%dS)N)DistutilsExecErrorDistutilsPlatformError CompileErrorLibError LinkError) CCompilergen_preprocess_optionsgen_lib_options)logFTzWarning: Can't read registry to find the necessary compiler setting Make sure that Python modules winreg, win32api or win32con are installed.cCsnzt||}Wntk r$YdSXg}d}zt||}Wntk rTYqjYnX|||d7}q.|SNr) RegOpenKeyExRegError RegEnumKeyappend)basekeyhandleLikr./usr/lib64/python3.8/distutils/msvccompiler.py read_keys7s   rcCszt||}Wntk r$YdSXi}d}zt||\}}}Wntk rZYq~YnX|}t||t|<|d7}q.|Sr )r r RegEnumValuelower convert_mbcs)rrrdrnamevaluetyperrr read_valuesHs  r!cCs:t|dd}|dk r6z |d}Wntk r4YnX|S)Ndecodembcs)getattr UnicodeError)sZdecrrrr]s  rc@s,eZdZddZddZddZddZd S) MacroExpandercCsi|_||dSN)macros load_macros)selfversionrrr__init__gszMacroExpander.__init__cCs2tD](}t||}|r|||jd|<q.qdS)Nz$(%s))HKEYSr!r))r+Zmacropathrrrrrr set_macroks  zMacroExpander.set_macroc Csd|}|d|dd|d|ddd}|d|d z*|d krX|d |d n|d |d Wn*tk r}z tdW5d}~XYnXd}tD]V}zt||}Wntk rYqYnXt|d}t|d||f} | d|jd<qdS)Nz%Software\Microsoft\VisualStudio\%0.1fZ VCInstallDirz \Setup\VCZ productdirZ VSInstallDirz \Setup\VSz Software\Microsoft\.NETFrameworkZ FrameworkDirZ installrootg@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)) r0KeyErrorrr.r rrr!r)) r+r,ZvsbaseZnetexcprhrrrrrr*rs,  zMacroExpander.load_macroscCs$|jD]\}}|||}q |Sr()r)itemsreplace)r+r&rvrrrsubszMacroExpander.subN)__name__ __module__ __qualname__r-r0r*r8rrrrr'fsr'cCsd}tj|}|dkrdS|t|}tj|ddd\}}t|ddd}|dkrf|d7}t|dd d }|dkrd }|dkr||SdS) NzMSC v. r g$@r)sysr,findlensplitint)prefixrr&restZ majorVersionZ minorVersionrrrget_build_versions  rJcCs@d}tj|}|dkrdStjd|}tj|t||S)Nz bit (r<Intel))rCr,rDrE)rHrjrrrget_build_architectures  rNcCs0g}|D]"}tj|}||kr||q|Sr()osr/normpathr)pathsZ reduced_pathsr3Znprrrnormalize_and_reduce_pathss   rRc @seZdZdZiZdgZdddgZdgZdgZeeeeZ dZ d Z d Z d Z d ZZd Zd,ddZddZd-ddZd.ddZd/ddZd0ddZddZdd Zd!d"Zd1d#d$Zd%d&Zd2d(d)Zd*d+ZdS)3 MSVCCompilerZmsvcz.cz.ccz.cppz.cxx.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCsvt||||t|_t|_|jdkr\|jdkrHd|_t|j|_nd|_d|j|_ nd|jd|_ d|_ dS) NrKzSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr=F) rr-rJ_MSVCCompiler__versionrN_MSVCCompiler__arch_MSVCCompiler__rootr'_MSVCCompiler__macros_MSVCCompiler__product initialized)r+verboseZdry_runZforcerrrr-s  zMSVCCompiler.__init__cCsg|_dtjkrDdtjkrD|drDd|_d|_d|_d|_d|_nx| d|_t |jd krlt d |j |d|_|d|_|d|_|d|_|d|_| d | d z&tjdd D]}|j|qWntk rYnXt|j|_d |jtjd<d|_|jdkrPddddddg|_dddddddg|_n&ddddddg|_dddddddg|_dddg|_|jdkrddddg|_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.libZinclude;rKz/nologoz/Oxz/MDz/W3z/GXz/DNDEBUGz/Odz/MDdz/Z7z/D_DEBUGz/GS-z/DLLz/INCREMENTAL:NOrUz/INCREMENTAL:noz/DEBUGz /pdb:NoneT)_MSVCCompiler__pathsrOenvironfind_execclinkerr]rcmcget_msvc_pathsrErrZset_path_env_varrFrr1rRjoinZpreprocess_optionsrWcompile_optionscompile_options_debugldflags_sharedrVldflags_shared_debugZldflags_staticr[)r+r3rrr initializesr                zMSVCCompiler.initializecCs|dkr d}g}|D]}tj|\}}tj|d}|tj|d}||jkrbtd||rrtj|}||jkr| tj |||j q||j kr| tj |||j q| tj |||j q|S)Nrnr zDon't know how to compile %s)rOr/splitext splitdriveisabssrc_extensionsrbasename_rc_extensionsrrh res_extension_mc_extensions obj_extension)r+Zsource_filenamesZ strip_dir output_dirZ obj_namesZsrc_namerextrrrobject_filenames8s.        zMSVCCompiler.object_filenamesNc  Csp|js||||||||} | \}} }} } |p6g} | d|rT| |jn | |j| D]}z| |\}}Wntk rYqdYnX|rtj |}||j krd|}nT||j krd|}n>||j kr<|}d|}z"||jg| |g|gWqdtk r6}z t|W5d}~XYqdXqdn||jkrtj |}tj |}zl||jgd|d|g|gtj tj |\}}tj ||d}||jgd|g|gWqdtk r}z t|W5d}~XYqdXqdntd||fd |}z&||jg| | ||g|Wqdtk rh}z t|W5d}~XYqdXqd| S) Nz/cz/Tcz/Tpz/foz-hz-rrTz"Don't know how to compile %s to %sz/Fo)r[rmZ_setup_compilerextendrjrir1rOr/abspath _c_extensions_cpp_extensionsrtspawnrdrrrvdirnamererorsrhrb)r+Zsourcesrxr)Z include_dirsdebug extra_preargsextra_postargsZdependsZ compile_infoobjectsZpp_optsZbuildZ compile_optsobjsrcryZ input_optZ output_optmsgZh_dirZrc_dirr_Zrc_filerrrcompileWs                   zMSVCCompiler.compilec Cs|js||||\}}|j||d}|||r|d|g}|rJz||jg|Wqtk r}z t|W5d}~XYqXn t d|dS)N)rx/OUT:skipping %s (up-to-date)) r[rm_fix_object_argslibrary_filename _need_linkrr]rrr r) r+rZoutput_libnamerxr target_langoutput_filenameZlib_argsrrrrcreate_static_libs zMSVCCompiler.create_static_libc Cs|js||||\}}||||}|\}}}|rL|dt|t||||}|dk rptj ||}| ||r|t j kr| r|j dd}q|jdd}n| r|j }n|j}g}|pgD]}|d|q||||d|g}|dk rHtjtj|\}}tj tj|d||}|d|| rZ| |dd<| rj|| |tj|z||jg|Wn,tk r}z t|W5d}~XYnXn td|dS)Nz5I don't know what to do with 'runtime_library_dirs': r z/EXPORT:rrz/IMPLIB:r)r[rmrZ _fix_lib_argswarnstrr rOr/rhrrZ EXECUTABLErlrkrrorsrrr{Zmkpathrrcrrr r)r+Z target_descrrrxZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsrrrZ build_temprZ fixed_argsZlib_optsZldflagsZ export_optsZsymZld_argsZdll_nameZdll_extZ implib_filerrrrlinksj        zMSVCCompiler.linkcCsd|S)Nz /LIBPATH:rr+dirrrrlibrary_dir_optionszMSVCCompiler.library_dir_optioncCs tddS)Nz|jdkrt|j||dS||dSq>|jdkrtD]&}t|d|jdk r|dqqgS) Nz dirsrUz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr^r=z%s\6.0zIt 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_regrVrXr.r!rYr8rFr)r+r/platformrrrrrrrfKs,      zMSVCCompiler.get_msvc_pathscCs6|dkr|d}n ||}|r2d|tj|<dS)Nr]Zlibraryr^)rfrhrOr`)r+rr3rrrrgos   zMSVCCompiler.set_path_env_var)rrr)rrn)NNNrNNN)NrN) NNNNNrNNNN)r)r)r9r:r;Z compiler_typeZ executablesr}r~rtrvrrrurwZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr-rmrzrrrrrrrrarfrgrrrrrSsh  B  X  S  $rSg @z3Importing new compiler from distutils.msvc9compiler)rS)r')-rCrOZdistutils.errorsrrrrrZdistutils.ccompilerrrr Z distutilsr rwinregZhkey_modZ OpenKeyExr ZEnumKeyrZ EnumValuererrorr ImportErrorZwin32apiZwin32coninfoZ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr.rr!rr'rJrNrRrSrZOldMSVCCompilerZdistutils.msvc9compilerrrrr s^      - 9