o Xai*B@sdZddlZddlZddlZddlmZmZmZddlZddl m Z ddl m Z ddl mZmZmZmZddlmZddlmZd d ZGd d d e ZGd ddeZdZdZdZddZedZddZddZ ddZ!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)PopenPIPE check_output) UnixCCompiler) write_file)DistutilsExecErrorCCompilerError CompileErrorUnknownFileError) LooseVersion)find_executablecCstjd}|dkr>tj|d|d}|dkrdgS|dkr#dgS|d kr*d gS|d kr1d gS|d kr8dgStd|dS)zaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. zMSC v. Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100zUnknown MS Compiler version %s N)sysversionfind ValueError)Zmsc_posZmsc_verr/builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-4.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/_distutils/cygwinccompiler.py get_msvcr?s  rc@sZeZdZdZdZdZdZdZdZdZ dZ dd d Z d d Z    dddZ dddZdS)CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows. cygwinz.o.az.dllzlib%s%sz%s%sz.exercCsFt||||t\}}|d||f|tur!|d|tjdd|_ tjdd|_ d|j vrgt \|_ |_ |_||jd|j |j |jf|j dkrY|j |_nd |_|j d krdd }n d }n|j |_d }|jd |j d|j d |j d|j d|j|fdd|j vr|j dkrdg|_|ddSt|_dS)Nz%Python's GCC status: %s (details: %s)zPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.CCgccCXXzg++z: gcc %s, ld %s, dllwrap %s z2.10.90dllwrap2.13-shared -mdll -staticz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz %s -mcygwinz%s -mcygwin %scompiler compiler_so compiler_cxx linker_exe linker_so2.91.57msvcrtz,Consider upgrading to a newer version of gcc)r__init__check_config_h debug_print CONFIG_H_OKwarnosenvirongetcccxx get_versions gcc_version ld_versionZdllwrap_version compiler_type linker_dllset_executables dll_librariesr)selfverbosedry_runforcestatusdetails shared_optionrrrr)dsX       zCygwinCCompiler.__init__c Cs|dks|dkr&z |dd|d|gWdSty%}zt|d}~wwz||j||d|g|WdStyH}zt|d}~ww)z:Compiles the source by spawning GCC and windres if needed..rc.resZwindresz-iz-oN)spawnrr r#)r:objsrcextZcc_argsextra_postargsZpp_optsmsgrrr_compiles zCygwinCCompiler._compileNcCsHt| pg} t|p g}t|pg}||j|dur||jks)|jdkrtj|d}tjtj |\}}tj ||d}tj |d|d}dtj |dg}|D]}| |q]| t ||fd ||jd kr| d |g| d |gn| || s| d t||||||||d| | | | | dS)zLink the objects.Nrrz.deflibrz LIBRARY %sZEXPORTSz writing %srz --output-libz--defz-s)copyextendr9Z EXECUTABLEr7r.pathdirnamesplitextbasenamejoinappendexecuterrlink)r:Z target_descZobjectsZoutput_filename output_dir libraries library_dirsruntime_library_dirsexport_symbolsdebugZ extra_preargsrGZ build_tempZ target_langtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_filecontentssymrrrrTsB         zCygwinCCompiler.linkcCs|durd}g}|D]H}tjtj|\}}||jddgvr)td||f|r1tj|}|dvrE|tj||||j q |tj|||j q |S)z#Adds supports for rc and res files.Nr^rArBz"unknown file type '%s' (from '%s'))rBrA) r.rMrOnormcaseZsrc_extensionsr rPrRrQ obj_extension)r:Zsource_filenamesZ strip_dirrUZ obj_namessrc_namebaserFrrrobject_filenamess&    z CygwinCCompiler.object_filenamesrrr) NNNNNrNNNN)rr^)__name__ __module__ __qualname____doc__r6r`Zstatic_lib_extensionshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr)rIrTrcrrrrrYs" @ Nrc@seZdZdZdZdddZdS)Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows. Zmingw32rc Cst||||d|jvr|jdkrd}nd}d|jvr$|jdkr$d}nd}t|jr/td|jd |jd |jd |jd |jd |j ||fd g|_ t |_ dS)Nrrr rr'z--entry _DllMain@12r^z1Cygwin gcc cannot be used with --compiler=mingw32z %s -O -Wallz%s -mdll -O -Wallz%sz%s %s %sr!) rr)r1r5r4 is_cygwinccrr8r2r7r9r)r:r;r<r=r@ entry_pointrrrr)s.   zMingw32CCompiler.__init__Nrd)rerfrgrhr6r)rrrrrjsrjokznot okZ uncertainc Csddlm}dtjvrtdfSdtjvrtdfS|}z(t|}zd|vr4td|fW|WSt d |fW|WS|wt y_}zt d ||j ffWYd }~Sd }~ww) 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 '%s': %sN) distutilsrnrrr,get_config_h_filenameopenreadcloseCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINstrerror)rnfnconfig_hexcrrrr*Ms(        r*s(\d+\.\d+(\.\d+)*)cCst|d}t|durdSt|dtdj}z |}W|n|wt|}|dur1dSt | d S)zFind the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. rNT)shellstdout) splitr rrr|rrrs RE_VERSIONsearchr groupdecode)cmd executableout out_stringresultrrr_find_exe_version~s    rcCsgd}tdd|DS)zg Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. )zgcc -dumpversionzld -vzdllwrap --versioncSsg|]}t|qSr)r).0rrrr sz get_versions..)tuple)commandsrrrr3sr3cCst|dg}|dS)zCTry to determine if the compiler that would be used is from cygwin.z -dumpmachinescygwin)rstripendswith)r1rrrrrks rk)"rhr.rrK subprocessrrrreZdistutils.unixccompilerrdistutils.file_utilrdistutils.errorsrrr r Zdistutils.versionr distutils.spawnr rrrjr,rtrvr*compilerrr3rkrrrrs.1    @1 /