U Wzf_?@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}/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-slp6y8a5/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.o.az.dllzlib%s%sz%s%sz.exercCst||||t\}}|d||f|tk rB|d|t\|_|_|_ ||j d|j|j|j f|jdkrd|_ nd|_ |jdkrd}nd }|j d d d d d|j |fd|jdkrdg|_ |dnt|_ 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.z: gcc %s, ld %s, dllwrap %s z2.10.90gccdllwrap2.13-shared -mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallz gcc -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_OKwarn get_versions gcc_version ld_versionZdllwrap_version compiler_type linker_dllset_executables dll_librariesr)selfverbosedry_runforcestatusdetails shared_optionrrrr'bsN     zCygwinCCompiler.__init__c Cs|dks|dkrVz|dd|d|gWqtk rR}z t|W5d}~XYqXnNz"||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)spawnrr r!)r3objsrcextcc_argsextra_postargsZpp_optsmsgrrr_compiles zCygwinCCompiler._compileNcCsPt| p g} t|pg}t|p&g}||j|dk r||jksV|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)copyextendr2Z EXECUTABLEr0ospathdirnamesplitextbasenamejoinappendexecuterrlink)r3Z target_descZobjectsZoutput_filename output_dir libraries library_dirsruntime_library_dirsexport_symbolsdebugZ extra_preargsrA build_tempZ target_langtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_filecontentssymrrrrOsR          zCygwinCCompiler.linkcCs|dkr d}g}|D]}tjtj|\}}||jddgkrRtd||f|rbtj|}|dkr|tj||||j q|tj|||j q|S)z#Adds supports for rc and res files.NrZr:r;z"unknown file type '%s' (from '%s'))r;r:) rGrHrJnormcaseZsrc_extensionsr rKrMrL obj_extension)r3Zsource_filenamesZ strip_dirrPZ obj_namessrc_namebaser?rrrobject_filenamess&    z CygwinCCompiler.object_filenames)rrr) NNNNNrNNNN)rrZ)__name__ __module__ __qualname____doc__r/r\Zstatic_lib_extensionshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr'rCrOr_rrrrrWs, ; Nrc@seZdZdZdZdddZdS)Mingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows. Zmingw32rc Csxt|||||jdkr d}nd}|jdkr4d}nd}trFtd|jdd d d d |j||fd g|_t |_dS)Nrrrr%z--entry _DllMain@12rZz1Cygwin gcc cannot be used with --compiler=mingw32z gcc -O -Wallzgcc -mdll -O -Wallz g++ -O -Wallrz%s %s %sr) rr'r.r- is_cygwingccrr1r0r2r)r3r4r5r6r9 entry_pointrrrr's.   zMingw32CCompiler.__init__N)rrr)r`rarbrcr/r'rrrrresreokznot okZ uncertainc Csddlm}dtjkrtdfS|}zLt|}z4d|krPtd|fWWSt d|fWWSW5|XWn8t k r}zt d||j ffWYSd }~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) distutilsrirrr*get_config_h_filenameopenclosereadCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINstrerror)rifnconfig_hexcrrrr(Fs    r(s(\d+\.\d+(\.\d+)*)cCsl|d}t|dkrdSt|dtdj}z |}W5|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 rrrwrmrn RE_VERSIONsearchr groupdecode)cmd executableout out_stringresultrrr_find_exe_versionss     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,cCstddg}|dS)z>Try to determine if the gcc that would be used is from cygwin.rz -dumpmachinescygwin)rstripendswith)rrrrrfs rf)"rcrGrrE subprocessrrrreZdistutils.unixccompilerrdistutils.file_utilrdistutils.errorsrrr r Zdistutils.versionr distutils.spawnr rrrer*rorqr(compilerzrr,rfrrrrs,/    ;1+