Vc?dZddlZddlZddlZddlmZmZmZddlZddl m Z ddl m Z ddl mZmZmZmZddlmZddlmZd ZGd d e ZGd d eZdZdZdZdZejdZdZdZ 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)PopenPIPE check_output) UnixCCompiler) write_file)DistutilsExecErrorCCompilerError CompileErrorUnknownFileError) LooseVersion)find_executablectjd}|dkrYtj|dz|dz}|dkrdgS|dkrdgS|d krd gS|d krd gS|d krdgStd|zdS)zaInclude the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. zMSC v. 1300msvcr701310msvcr711400msvcr801500msvcr901600msvcr100zUnknown MS Compiler version %s N)sysversionfind ValueError)msc_posmsc_vers 2/usr/lib64/python3.11/distutils/cygwinccompiler.py get_msvcrr#=skx((G"}J+gai 23 f  J;    J;    J;    J;    J< >HII I%JJcTeZdZdZdZdZdZdZdZdZ dZ dd Z d Z dd Z ddZd S)CygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows. cygwinz.o.az.dllzlib%s%sz%s%sz.exerc tj||||t\}}|d|d|d|tur|d|zt \|_|_|_ ||j d|jd|jd|j dz|jd krd |_ nd |_ |jd krd }nd}| dddd|j d||jdkrdg|_ |ddSt|_ dS)NzPython's GCC status: z (details: )zPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc z, ld z , dllwrap  z2.10.90gccdllwrap2.13-shared -mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallz gcc -mcygwinz -mcygwin compiler 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_OKwarn get_versions gcc_version ld_versiondllwrap_version compiler_type linker_dllset_executables dll_librariesr#)selfverbosedry_runforcestatusdetails shared_options r"r9zCygwinCCompiler.__init__bstWgu===(**  &&'''+ , , ,  $  IIO    NN @$/4+? ++***///.../00 2 2 2 ?i ' (#DOO'DO ?f $ ,%MM+M &=)F*A(6)---)I  K K K  y ( -!)zD  II> @ @ @ @ @ "+D   r$c*|dks|dkr> |dd|d|gdS#t$r}t|d}~wwxYw ||j|z|d|gz|zdS#t$r}t|d}~wwxYw)z:Compiles the source by spawning GCC and windres if needed..rc.reswindresz-iz-oN)spawnrr r3)rFobjsrcextcc_argsextra_postargspp_optsmsgs r"_compilezCygwinCCompiler._compiles %< (3&= ( ( ItS$<=====% ( ( ("3''' ( ( 4+g5dC8HH)*+++++% ( ( ("3''' (s,* AAA &A44 B>B  BNctj| pg} tj|pg}tj|pg}||j|r||jks |jdkr[t j|d}t jt j |\}}t j ||dz}t j |d|zdz}dt j |zdg}|D]}| || t||fd |z|jd kr/| d |g| d |gn| || s| d tj||||||||d| | | | | dS)zLink the objects.Nr,rz.deflibr(z LIBRARY %sEXPORTSz writing %sr-z --output-libz--defz-s)copyextendrE EXECUTABLErCospathdirnamesplitextbasenamejoinappendexecuterrlink)rF target_descobjectsoutput_filename output_dir libraries library_dirsruntime_library_dirsexport_symbolsdebug extra_preargsrV build_temp target_langtemp_dirdll_name dll_extensiondef_filelib_filecontentssyms r"rhzCygwinCCompiler.links+  -"5266 Iio2.. )GMr** +,,,( ) DO +( )/3%/G( )wwqz22H(*(8(8  11)3)3 %X}w||Hh.?@@Hw||Heh.>.EFFHrw//@@@H& % %$$$$ LLh%9%0 2 2 2 )+ )$$nh%?@@@$$gx%89999 x((( '   & & &4g%y,/ -&  ( ( ( ( (r$c$|d}g}|D]}tjtj|\}}||jddgzvrt d|d|d|rtj|}|dvr?|tj|||z|j z|tj|||j z|S) z#Adds supports for rc and res files.Nr|rNrOzunknown file type 'z ' (from 'z'))rOrN) r`rarcnormcasesrc_extensionsr rdrfre obj_extension)rFsource_filenames strip_dirrl obj_namessrc_namebaserTs r"object_filenamesz CygwinCCompiler.object_filenamessI  J ( K KH(()9)9()C)CDDID#4.%?@ '&&ssHHH(&''' /w''..o% K  "',,z.2Sj4;M.M#O#OPPPP  "',,z/3d6H/H#J#JKKKKr$rrr) NNNNNrNNNN)rr|)__name__ __module__ __qualname____doc__rBrstatic_lib_extensionshared_lib_extensionstatic_lib_formatshared_lib_format exe_extensionr9rYrhrr$r"r&r&WsMM!!M9-9-9-9-v ( ( (FJEI9=?CJ(J(J(J(\r$r&ceZdZdZdZddZdS)Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows. mingw32rc <t|||||jdkrd}nd}|jdkrd}nd}t rt d|dd d d |jd |d | g|_t|_dS)Nr.r/r0r7z--entry _DllMain@12r|z1Cygwin gcc cannot be used with --compiler=mingw32z gcc -O -Wallzgcc -mdll -O -Wallz g++ -O -Wallr, r1) r&r9r@r? is_cygwingccr rDrCrEr#)rFrGrHrIrL entry_points r"r9zMingw32CCompiler.__init__s  $%@@@ ?f $ ,%MM+M  y ( /KKK >> E CEE E n)=*8(-+/???MMM+6;(8  9 9 9'[[r$Nr)rrrrrBr9rr$r"rrs7M&)&)&)&)&)&)r$rokznot ok uncertaincddlm}dtjvr tdfS|} t |} d|vr td|zf|Std|zf|S#|wxYw#t$r}td|d |j fcYd }~Sd }~wwxYw) 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) sysconfigGCCzsys.version mentions 'GCC'__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read 'z': N) distutilsrrrr<get_config_h_filenameopenreadcloseCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINstrerror)rfnconfig_hexcs r"r:r:Fs%*$#####  9888  ( ( * *B ?88 X]]__, O"$>$CC NN    &'IB'NN NN    HNN     ???"",.BB =? ? ? ? ? ? ??sAB2!B$B29 BB2B//B22 C<CCCs(\d+\.\d+(\.\d+)*)c|d}t|dSt|dtj} |}|n#|wxYwt|}|dSt| 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 rrrrr RE_VERSIONsearchr groupdecode)cmd executableout out_stringresults r"_find_exe_versionrss QJz""t 4 - - - 4CXXZZ     z * *F t  Q..00 1 11s A22Bc<gd}td|DS)zg Try to find out the versions of gcc, ld and dllwrap. If not possible it returns None for it. )zgcc -dumpversionzld -vzdllwrap --versionc,g|]}t|Sr)r).0rs r" z get_versions..s!===S#C((===r$)tuple)commandss r"r>r>s- BAAH ==H=== > >>r$crtddg}|dS)z>Try to determine if the gcc that would be used is from cygwin.r,z -dumpmachinescygwin)rstripendswith)rs r"rrs4un566J      & &y 1 11r$)"rr`rr] subprocessrrrredistutils.unixccompilerrdistutils.file_utilrdistutils.errorsrr r r distutils.versionr distutils.spawnr r#r&rr<rrr:compilerrr>rrr$r"rs^ 0000000000 111111******((((((((((((******++++++JJJ4wwwwwmwwwt+)+)+)+)+)+)+)+)b  )?)?)?VRZ. / / 222*???22222r$