a „oe”.ã @s dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZmZmZddlmZmZdd lmZe d gd gd gd gdgdgdgdgejdœ ¡Zdd„ZdZGdd„de ƒZGdd„deƒZdZdZdZ dd„Z!dd „Z"dZ#dS)!adistutils.cygwinccompiler Provides the CygwinCCompiler class, a subclass of UnixCCompiler that handles the Cygwin port of the GNU C compiler to Windows. It also contains the Mingw32CCompiler class which handles the mingw32 port of GCC (same as cygwin in no-cygwin mode). éN)Ú check_outputé)Ú UnixCCompiler)Ú write_file)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚCCompilerErrorÚ CompileError)Ú LooseVersionÚsuppress_known_deprecation)ÚRangeMapZmsvcr70Zmsvcr71Zmsvcr80Zmsvcr90Zmsvcr100Zmsvcr110Zmsvcr120Z vcruntime140) iiixiÜi@i¤iiliÐcCsdt dtj¡}zt| d¡ƒ}Wnty4YdS0z t|WSty^t d|ƒ‚Yn0dS)zaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. zMSC v\.(\d{4})rNzUnknown MS Compiler version %s ) ÚreÚsearchÚsysÚversionÚintÚgroupÚAttributeErrorÚ _msvcr_lookupÚKeyErrorÚ ValueError)ÚmatchZmsc_ver©rúFC:\Program Files\Certbot\pkgs\setuptools\_distutils\cygwinccompiler.pyÚ get_msvcr4s   rzxUnable to set runtime library search path on Windows, usually indicated by `runtime_library_dirs` parameter to Extensionc sˆeZdZdZdZdZdZdZdZdZ dZ dZ d Z d‡fd d „ Z ed d„ƒZdd„Zddd„Zdd„Z‡fdd„Ze‡fdd„ƒZ‡ZS)ÚCygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.Úcygwinz.oz.az.dll.az.dllzlib%s%szcyg%s%sz.exerc s°tƒ |||¡tƒ\}}| d ||¡¡|turB| d|¡tj  dd¡|_ tj  dd¡|_ |j |_ d}|j d|j d |j d|j d |j d  |j |¡d �tƒ|_dS) Nz%Python's GCC status: {} (details: {})zƒPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.ZCCÚgccZCXXzg++ú-sharedz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz %s -mcygwinz{} -mcygwin {}©ZcompilerÚ compiler_soZ compiler_cxxZ linker_exeZ linker_so)ÚsuperÚ__init__Úcheck_config_hZ debug_printÚformatÚ CONFIG_H_OKÚwarnÚosÚenvironÚgetÚccÚcxxÚ linker_dllÚset_executablesrÚ dll_libraries)ÚselfÚverboseÚdry_runÚforceÚstatusZdetailsÚ shared_option©Ú __class__rrr"Vs.  ÿþÿ û zCygwinCCompiler.__init__cCsBtjdtdd�tƒ�tdƒWdƒS1s40YdS)Nz�gcc_version attribute of CygwinCCompiler is deprecated. Instead of returning actual gcc version a fixed value 11.2.0 is returned.é)Ú stacklevelz11.2.0)Úwarningsr&ÚDeprecationWarningr r ©r/rrrÚ gcc_versionvsüzCygwinCCompiler.gcc_versionc Cs¤|dvrPz| dd|d|g¡Wq tyL}zt|ƒ‚WYd}~q d}~00nPz"| |j||d|g|¡Wn,tyž}zt|ƒ‚WYd}~n d}~00dS)z:Compiles the source by spawning GCC and windres if needed.)ú.rcú.resZwindresz-iz-oN)Zspawnrr r )r/ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsÚmsgrrrÚ_compile…s ÿzCygwinCCompiler._compileNcCst | p g¡} t |pg¡}t |p&g¡}|r8| t¡| |j¡|durâ||jks`|jdkrâtj  |d¡}tj  tj  |¡¡\}}tj  ||d¡}dtj  |¡dg}|D]}|  |¡q²| t||fd|¡|  |¡| sð|   d¡t ||||||||d| | | | | ¡dS) zLink the objects.Nrrz.defz LIBRARY %sZEXPORTSz writing %sz-s)Úcopyr&Ú_runtime_library_dirs_msgÚextendr.Z EXECUTABLEr,r'ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendZexecuterrÚlink)r/Z target_descZobjectsZoutput_filenameÚ output_dirZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsÚdebugZ extra_preargsrBZ build_tempZ target_langZtemp_dirZdll_nameZ dll_extensionZdef_fileÚcontentsZsymrrrrN•sN  ÿÿ  ÿ   òzCygwinCCompiler.linkcCs| t¡gS©N)r&rF©r/ÚdirrrrÚruntime_library_dir_optionïs z*CygwinCCompiler.runtime_library_dir_optioncstj |¡}tƒ |||¡SrR)r'rHÚnormcaser!Ú_make_out_path)r/rOZ strip_dirZsrc_nameZ norm_src_namer5rrrWøs zCygwinCCompiler._make_out_pathcsitƒj¥‡fdd„dDƒ¥S)z3 Add support for rc and res files. csi|]}||ˆj“qSr)Ú obj_extension)Ú.0rAr;rrÚ óz2CygwinCCompiler.out_extensions..)r>r=)r!Úout_extensionsr;r5r;rr\ýs ÿþzCygwinCCompiler.out_extensions)rrr) NNNNNrNNNN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú compiler_typerXZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZ exe_extensionr"Úpropertyr<rDrNrUrWr\Ú __classcell__rrr5rrIs:  ò Z rcs.eZdZdZdZd‡fdd„ Zdd„Z‡ZS) ÚMingw32CCompilerz:Handles the Mingw32 port of the GNU C compiler to Windows.Zmingw32rc s`tƒ |||¡d}t|jƒr&tdƒ‚|jd|jd|jd|jd|jd |j|¡d�dS)Nrz1Cygwin gcc cannot be used with --compiler=mingw32z %s -O -Wallz%s -mdll -O -Wallz%sz{} {}r) r!r"Ú is_cygwinccr*rr-r+r$r,)r/r0r1r2r4r5rrr"s  ûzMingw32CCompiler.__init__cCs ttƒ‚dSrR)rrFrSrrrrUsz+Mingw32CCompiler.runtime_library_dir_option)rrr)r]r^r_r`rar"rUrcrrr5rrd srdÚokznot okZ uncertainc CsÔddlm}dtjvrtdfSdtjvr0tdfS| ¡}z`t|ƒ}zHd| ¡vrhtd|fW| ¡WSt d |fW| ¡WSW| ¡n | ¡0Wn6t yÎ}zt d   ||j ¡fWYd }~Sd }~00d S) awCheck if the current Python installation appears amenable to building extensions with GCC. Returns a tuple (status, details), where 'status' is one of the following constants: - CONFIG_H_OK: all is well, go ahead and compile - CONFIG_H_NOTOK: doesn't look good - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h 'details' is a human-readable string explaining the situation. Note there are two ways to conclude "OK": either 'sys.version' contains the string "GCC" (implying that this Python was built with GCC), or the installed "pyconfig.h" contains the string "__GNUC__". r)Ú sysconfigZGCCzsys.version mentions 'GCC'ZClangzsys.version mentions 'Clang'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '{}': {}N)Z distutilsrgrrr%Zget_config_h_filenameÚopenÚreadÚcloseÚCONFIG_H_NOTOKÚOSErrorÚCONFIG_H_UNCERTAINr$Ústrerror)rgÚfnZconfig_hÚexcrrrr#+s&     ü þr#cCs"tt |¡dgƒ}| ¡ d¡S)zCTry to determine if the compiler that would be used is from cygwin.z -dumpmachinescygwin)rÚshlexÚsplitÚstripÚendswith)r*Z out_stringrrrreZsre)$r`r'r rrErqr9Ú subprocessrZ unixccompilerrZ file_utilrÚerrorsrrrr rr r Ú _collectionsr ÚleftZundefined_valuerrrFrrdr%rkrmr#reZ get_versionsrrrrÚsJ    ïÿÿA/