B s1@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}|dkr8dgS|dkrFdgS|d krTd gS|d krbd gS|d krpdgStd|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-python37-setuptools-58.3.0-4.el9.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/_distutils/cygwinccompiler.py get_msvcr?s rc @sReZdZdZdZdZdZdZdZdZ dZ dd d Z d d Z dddZ dddZdS)CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows. cygwinz.oz.az.dllzlib%s%sz%s%sz.exercCsHt||||t\}}|d||f|tk rB|d|tjdd|_ tjdd|_ d|j krt \|_ |_ |_||jd|j |j |jf|j dkr|j |_nd |_|j d krd }qd }n |j |_d }|jd |j d|j d |j d|j d|j|fdd|j kr<|j dkrrrrobject_filenamess      z CygwinCCompiler.object_filenames)rrr) NNNNNrNNNN)rrW)__name__ __module__ __qualname____doc__r0rYZstatic_lib_extensionshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr#rArLr\rrrrrYs @ Krc@seZdZdZdZdddZdS)Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows. Zmingw32rc Cst||||d|jkr*|jdkr*d}nd}d|jkrH|jdkrHd}nd}t|jr^td|jd |jd |jd |jd |jd |j ||fd g|_ t |_ dS)Nrz2.13z -mdll -staticz-sharedz2.91.57z--entry _DllMain@12rWz1Cygwin gcc cannot be used with --compiler=mingw32z %s -O -Wallz%s -mdll -O -Wallz%sz%s %s %s)rrrr r!) rr#r+r/r. is_cygwinccrr2r,r1r3r)r4r5r6r7r: entry_pointrrrr#s&   zMingw32CCompiler.__init__N)rrr)r]r^r_r`r0r#rrrrrbsrbokznot okZ uncertainc Csddlm}dtjkrtdfSdtjkr0tdfS|}y@t|}z(d|kr\td|fStd |fSWd | XWn0t k r}zt d ||j ffSd }~XYnXd 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__'Nzcouldn't read '%s': %s) distutilsrfrrr&get_config_h_filenameopenreadCONFIG_H_NOTOKcloseOSErrorCONFIG_H_UNCERTAINstrerror)rffnconfig_hexcrrrr$Ms      r$s(\d+\.\d+(\.\d+)*)cCsl|d}t|dkrdSt|dtdj}z |}Wd|Xt|}|dkrZdSt | 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 rrrtrjrl RE_VERSIONsearchr groupdecode)cmd executableout out_stringresultrrr_find_exe_version~s     rcCsdddg}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).0r{rrr sz get_versions..)tuple)commandsrrrr-s r-cCst|dg}|dS)zCTry to determine if the compiler that would be used is from cygwin.z -dumpmachinescygwin)rstripendswith)r+r~rrrrcs rc)"r`r(rrC subprocessrrrreZdistutils.unixccompilerrdistutils.file_utilrdistutils.errorsrrr r Zdistutils.versionr distutils.spawnr rrrbr&rkrnr$compilerwrr-rcrrrrs,+    @1/