U e5d^@ã@sþdZddlZddlZddlZddlmZmZmZddlZddl m Z m Z ddl m Z ddlmZddlmZmZmZmZddlmZdd lmZdd lmZd d „ZGd d„de ƒZGdd„deƒZdZdZdZ dd„Z!e "d¡Z#dd„Z$dd„Z%dd„Z&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)ÚPopenÚPIPEÚ check_output)Úgen_preprocess_optionsÚgen_lib_options)Ú UnixCCompiler)Ú write_file)ÚDistutilsExecErrorÚCCompilerErrorÚ CompileErrorÚUnknownFileError)Úlog)Ú LooseVersion)Úfind_executablecCs€tj d¡}|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)ÚsysÚversionÚfindÚ ValueError)Zmsc_posZmsc_ver©rú1/usr/lib64/python3.8/distutils/cygwinccompiler.pyÚ get_msvcr?s rc @sReZdZdZdZdZdZdZdZdZ dZ dd d „Z d d „Z ddd„Z ddd„ZdS)ÚCygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows. Úcygwinz.oú.az.dllzlib%s%sz%s%sz.exercCsèt ||||¡tƒ\}}| d||f¡|tk rB| d|¡tƒ\|_|_|_ | |j d|j|j|j f¡|jdkr†d|_ nd|_ |jdkrœd}nd }|j d d d d d|j |fd�|jdkrÜdg|_ | d¡ntƒ|_ dS)Nz%Python's GCC status: %s (details: %s)zƒPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.z: gcc %s, ld %s, dllwrap %s z2.10.90ÚgccÚdllwrapú2.13ú-sharedú -mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallz gcc -mcygwinz%s -mcygwin %s©ZcompilerÚ compiler_soZ compiler_cxxZ linker_exeZ linker_soú2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)rÚ__init__Úcheck_config_hZ debug_printÚ CONFIG_H_OKÚwarnÚ get_versionsÚ gcc_versionÚ ld_versionZdllwrap_versionÚ compiler_typeÚ linker_dllÚset_executablesÚ dll_librariesr)ÚselfÚverboseÚdry_runÚforceZstatusZdetailsÚ shared_optionrrrr%dsN ÿýÿÿ þÿ  ÿü ÿzCygwinCCompiler.__init__c Cs¨|dks|dkrVz| dd|d|g¡Wq¤tk rR}z t|ƒ‚W5d}~XYq¤XnNz"| |j||d|g|¡Wn*tk r¢}z t|ƒ‚W5d}~XYnXdS)z:Compiles the source by spawning GCC and windres if needed.ú.rcú.resZwindresz-iz-oN)Zspawnr r r#)r0ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsÚmsgrrrÚ_compileŸsÿ zCygwinCCompiler._compileNcCsPt | p g¡} t |pg¡}t |p&g¡}| |j¡|dk �r||jksV|jdk�rtj |d¡}tj tj  |¡¡\}}tj  ||d¡}tj  |d|d¡}dtj  |¡dg}|D]}|  |¡q¾|  t ||fd |¡|jd k�r|  d |g¡|  d |g¡n |  |¡| �s(|   d ¡t ||||||||d| | | | | ¡dS)zLink the objects.Nrrz.defÚlibrz LIBRARY %sZEXPORTSz writing %srz --output-libz--defz-s)ÚcopyÚextendr/Z EXECUTABLEr-ÚosÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendZexecuterrÚlink)r0Z target_descZobjectsZoutput_filenameÚ output_dirZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsÚdebugZ extra_preargsr:Z build_tempZ target_langZtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_fileÚcontentsZsymrrrrG®sR  ÿÿ  ÿþ  ÿ    ûzCygwinCCompiler.linkÚcCsª|dkr d}g}|D]�}tj tj |¡¡\}}||jddgkrRtd||fƒ‚|rbtj |¡}|dkrŠ| tj ||||j ¡¡q| tj |||j ¡¡q|S)z#Adds supports for rc and res files.NrKr5r6z"unknown file type '%s' (from '%s'))r6r5) r@rArCÚnormcaseZsrc_extensionsr rDrFrEÚ obj_extension)r0Zsource_filenamesZ strip_dirrHZ obj_namesZsrc_nameÚbaser9rrrÚobject_filenamesüs&ÿ   ÿ ÿz CygwinCCompiler.object_filenames)rrr) NNNNNrNNNN)rrK)Ú__name__Ú __module__Ú __qualname__Ú__doc__r,rMZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr%r<rGrOrrrrrYs, ;ý Nrc@seZdZdZdZddd„ZdS)ÚMingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows. Zmingw32rc Csxt ||||¡|jdkr d}nd}|jdkr4d}nd}tƒrFtdƒ‚|jdd d d d |j||fd �g|_t ƒ|_dS)Nrr r!r$z--entry _DllMain@12rKz1Cygwin gcc cannot be used with --compiler=mingw32z gcc -O -Wallzgcc -mdll -O -Wallz g++ -O -Wallrz%s %s %sr") rr%r+r*Ú is_cygwingccr r.r-r/r)r0r1r2r3r4Z entry_pointrrrr%s.  ÿÿÿü zMingw32CCompiler.__init__N)rrr)rPrQrRrSr,r%rrrrrTsrTÚokznot okZ uncertainc Cs°ddlm}dtjkrtdfS| ¡}zLt|ƒ}z4d| ¡krPtd|fW¢WSt d|fW¢WSW5| ¡XWn8t k rª}zt d||j ffWY¢Sd }~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'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %sN) Ú distutilsrWrrr'Zget_config_h_filenameÚopenÚcloseÚreadÚCONFIG_H_NOTOKÚOSErrorÚCONFIG_H_UNCERTAINÚstrerror)rWÚfnZconfig_hÚexcrrrr&Hs    ÿr&s(\d+\.\d+(\.\d+)*)cCsl| ¡d}t|ƒdkrdSt|dtd�j}z | ¡}W5| ¡Xt |¡}|dkrZdSt |  d¡  ¡ƒS)z¤Find 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)ÚshellÚstdouté) ÚsplitrrrrcrZr[Ú RE_VERSIONÚsearchrÚgroupÚdecode)ÚcmdÚ executableÚoutÚ out_stringÚresultrrrÚ_find_exe_versionus     rocCsdddg}tdd„|DƒƒS)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)ro)Ú.0rjrrrÚ �sz get_versions..)Útuple)Zcommandsrrrr)Šs r)cCstddgƒ}| ¡ d¡S)z>Try to determine if the gcc that would be used is from cygwin.rz -dumpmachinescygwin)rÚstripÚendswith)rmrrrrU’s rU)'rSr@rr>Ú subprocessrrrÚreZdistutils.ccompilerrrZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsr r r r rXr Zdistutils.versionrZdistutils.spawnrrrrTr'r\r^r&Úcompilerfror)rUrrrrÚs0/     ;1+