B � f^@�@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�>/opt/alt/python37/lib64/python3.7/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.oz.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�dllwrapz2.13z-sharedz -mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallz gcc -mcygwinz%s -mcygwin %s)�compiler� compiler_so� compiler_cxx� linker_exe� linker_soz2.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#ds<      zCygwinCCompiler.__init__c Cs�|dks|dkrVy|�dd|d|g�Wq�tk rR}z t|��Wdd}~XYq�XnNy"|�|j||d|g|�Wn*tk r�}z t|��Wdd}~XYnXdS)z:Compiles the source by spawning GCC and windres if needed.z.rcz.resZwindresz-iz-oN)Zspawnr r r)r.�obj�src�extZcc_args�extra_postargsZpp_opts�msgrrr�_compile�s zCygwinCCompiler._compileNcCsTt�| p g�} t�|pg�}t�|p&g�}|�|j�|dk �r||jksV|jdk�rtj�|d�}tj�tj� |��\}}tj� ||d�}tj� |d|d�}dtj� |�dg}x|D]}|� |�q�W|� t ||fd |�|jd k�r| �d |g�| �d |g�n |� |�| �s,| � d �t�||||||||d| | | | | �dS)zLink the objects.Nrrz.def�libz.az LIBRARY %sZEXPORTSz writing %srz --output-libz--defz-s)�copy�extendr-Z EXECUTABLEr+�os�path�dirname�splitext�basename�join�appendZexecuterr�link)r.Z target_descZobjectsZoutput_filename� output_dirZ librariesZ library_dirsZruntime_library_dirsZexport_symbols�debugZ extra_preargsr6Z build_tempZ target_langZtemp_dirZdll_nameZ dll_extensionZdef_fileZlib_file�contentsZsymrrrrC�s:          zCygwinCCompiler.link�cCs�|dkr d}g}x�|D]�}tj�tj�|��\}}||jddgkrTtd||f��|rdtj�|�}|dkr�|�tj�||||j ��q|�tj�|||j ��qW|S)z#Adds supports for rc and res files.NrGz.rcz.resz"unknown file type '%s' (from '%s'))z.resz.rc) r<r=r?�normcaseZsrc_extensionsr r@rBrA� obj_extension)r.Zsource_filenamesZ strip_dirrDZ obj_namesZsrc_name�baser5rrr�object_filenames�s      z CygwinCCompiler.object_filenames)rrr) NNNNNrNNNN)rrG)�__name__� __module__� __qualname__�__doc__r*rIZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr#r8rCrKrrrrrYs ; Krc@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)Nz2.13z-sharedz -mdll -staticz2.91.57z--entry _DllMain@12rGz1Cygwin gcc cannot be used with --compiler=mingw32z gcc -O -Wallzgcc -mdll -O -Wallz g++ -O -Wallrz%s %s %s)rrr r!r") rr#r)r(� is_cygwingccr r,r+r-r)r.r/r0r1r2Z entry_pointrrrr#s&   zMingw32CCompiler.__init__N)rrr)rLrMrNrOr*r#rrrrrPsrP�okznot okZ uncertainc Cs�ddlm}dtjkrtdfS|��}y@t|�}z(d|��krJtd|fStd|fSWd|� �XWn0t k r�}zt d ||j ffSd}~XYnXdS) 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__'Nzcouldn't read '%s': %s) � distutilsrSrrr%Zget_config_h_filename�open�read�CONFIG_H_NOTOK�close�OSError�CONFIG_H_UNCERTAIN�strerror)rS�fnZconfig_h�excrrrr$Hs    r$s(\d+\.\d+(\.\d+)*)cCsl|��d}t|�dkrdSt|dtd�j}z |��}Wd|��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�) �splitrrrr_rVrX� RE_VERSION�searchr�group�decode)�cmd� executable�out� out_string�resultrrr�_find_exe_versionus     rkcCsdddg}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)rk)�.0rfrrr� �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)rirrrrQ�s rQ)'rOr<rr:� subprocessrrr�reZdistutils.ccompilerrrZdistutils.unixccompilerrZdistutils.file_utilrZdistutils.errorsr r r r rTr Zdistutils.versionrZdistutils.spawnrrrrPr%rWrZr$�compilerbrkr'rQrrrr�s0)     ;1+