a oe. @s dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZmZmZddlmZmZdd lmZed gd gd gd gdgdgdgdgejd ZddZdZGddde ZGdddeZdZdZdZ ddZ!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)DistutilsExecErrorDistutilsPlatformErrorCCompilerError CompileError) LooseVersionsuppress_known_deprecation)RangeMapZmsvcr70Zmsvcr71Zmsvcr80Zmsvcr90Zmsvcr100Zmsvcr110Zmsvcr120Z vcruntime140) iiixii@iiilicCsdtdtj}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 ) researchsysversionintgroupAttributeError _msvcr_lookupKeyError ValueError)matchZmsc_verrFC:\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 seZdZdZdZdZdZdZdZdZ dZ dZ d Z dfd d Z ed dZddZdddZddZfddZefddZZS)CygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.cygwinz.oz.az.dll.az.dllzlib%s%szcyg%s%sz.exerc st|||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: {})zPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.ZCCgccZCXXzg++-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_printformat CONFIG_H_OKwarnosenvirongetcccxx linker_dllset_executablesr dll_libraries)selfverbosedry_runforcestatusZdetails shared_option __class__rrr"Vs.    zCygwinCCompiler.__init__cCsBtjdtddttdWdS1s40YdS)Nzgcc_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_versionvszCygwinCCompiler.gcc_versionc Cs|dvrPz|dd|d|gWqtyL}zt|WYd}~qd}~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/objsrcextZcc_argsextra_postargsZpp_optsmsgrrr_compiles zCygwinCCompiler._compileNcCst| p g} t|pg}t|p&g}|r8|t||j|dur||jks`|jdkrtj |d}tj tj |\}}tj ||d}dtj |dg}|D]}| |q|t||fd|| || s| dt||||||||d| | | | | dS) zLink the objects.Nrrz.defz LIBRARY %sZEXPORTSz writing %sz-s)copyr&_runtime_library_dirs_msgextendr.Z EXECUTABLEr,r'pathdirnamesplitextbasenamejoinappendZexecuterrlink)r/Z target_descZobjectsZoutput_filename output_dirZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsdebugZ extra_preargsrBZ build_tempZ target_langZtemp_dirZdll_nameZ dll_extensionZdef_filecontentsZsymrrrrNsN       zCygwinCCompiler.linkcCs|tgSN)r&rFr/dirrrrruntime_library_dir_options z*CygwinCCompiler.runtime_library_dir_optioncstj|}t|||SrR)r'rHnormcaser!_make_out_path)r/rOZ strip_dirZsrc_nameZ norm_src_namer5rrrWs zCygwinCCompiler._make_out_pathcsitjfdddDS)z3 Add support for rc and res files. csi|]}||jqSr) 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.eZdZdZdZdfdd ZddZZS) Mingw32CCompilerz:Handles the Mingw32 port of the GNU C compiler to Windows.Zmingw32rc s`t|||d}t|jr&td|jd|jd|jd|jd|jd|j|ddS)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 ttdSrR)rrFrSrrrrUsz+Mingw32CCompiler.runtime_library_dir_option)rrr)r]r^r_r`rar"rUrcrrr5rrd srdokznot okZ uncertainc Csddlm}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_filenameopenreadcloseCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINr$strerror)rgfnZconfig_hexcrrrr#+s&      r#cCs"tt|dg}|dS)zCTry to determine if the compiler that would be used is from cygwin.z -dumpmachinescygwin)rshlexsplitstripendswith)r*Z out_stringrrrreZsre)$r`r'r rrErqr9 subprocessrZ unixccompilerrZ file_utilrerrorsrrrr rr r _collectionsr leftZundefined_valuerrrFrrdr%rkrmr#reZ get_versionsrrrrsJ    A/