U
    aÊ¹js.  ã                   @   sÜ   d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZmZ d
d„ ZdZG dd„ deƒZG dd„ deƒZdZdZdZdd„ Zdd„ ZdZ dS )a  distutils.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)Úcheck_outputé   )ÚCCompilerErrorÚCompileErrorÚDistutilsExecErrorÚDistutilsPlatformError)Ú
write_file)Úget_config_vars)ÚUnixCCompiler)ÚLooseVersionÚsuppress_known_deprecationc                   C   s   g S )z6No longer needed, but kept for backward compatibility.© r   r   r   úd/var/www/html/bwave/python/venv/lib/python3.8/site-packages/setuptools/_distutils/cygwinccompiler.pyÚ	get_msvcr   s    r   zxUnable to set runtime library search path on Windows, usually indicated by `runtime_library_dirs` parameter to Extensionc                
       sˆ   e Zd ZdZdZdZdZdZdZdZ	dZ
dZd	Zd‡ fdd„	Zedd„ ƒZdd„ Zddd„Zdd„ Z‡ fdd„Ze‡ fdd„ƒZ‡  ZS )ÚCygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.Úcygwinz.oz.az.dll.az.dllzlib%s%szcyg%s%sz.exeFc                    s  t ƒ  |||¡ tƒ \}}|  d|› d|› d�¡ |tk	rL|  d|› d�¡ tddƒ\| _| _t	j
 d| jpnd¡| _t	j
 d| jp„d	¡| _| j| _| j| _d
}| j| j› d�| j› d�| j› d�| j› d�| j› d�| j› d|› �| j› d�| j› d|› �d� tƒ | _d S )NzPython's GCC status: z (details: ú)zCPython's pyconfig.h doesn't seem to support your compiler. Reason: z>. Compiling may fail because of undefined preprocessor macros.ÚCCÚCXXÚgcczg++ú-sharedz -mcygwin -O -Wallz -mcygwin -mdll -O -Wallz	 -mcygwinz
 -mcygwin )ÚcompilerÚcompiler_soÚcompiler_cxxÚcompiler_so_cxxÚ
linker_exeÚ	linker_soÚlinker_exe_cxxÚlinker_so_cxx)ÚsuperÚ__init__Úcheck_config_hÚdebug_printÚCONFIG_H_OKÚwarnr	   ÚccÚcxxÚosÚenvironÚgetÚ
linker_dllÚlinker_dll_cxxÚset_executablesr   Údll_libraries)ÚselfÚverboseÚdry_runÚforceÚstatusÚdetailsÚshared_option©Ú	__class__r   r   r    5   s0    

ÿ





øzCygwinCCompiler.__init__c              
   C   s6   t jdtdd� tƒ � tdƒW  5 Q R £ S Q R X d S )Nz�gcc_version attribute of CygwinCCompiler is deprecated. Instead of returning actual gcc version a fixed value 11.2.0 is returned.é   )Ú
stacklevelz11.2.0)Úwarningsr$   ÚDeprecationWarningr   r   ©r.   r   r   r   Úgcc_versionY   s    üzCygwinCCompiler.gcc_versionc              
   C   sÎ   |dkrNz|   dd|d|g¡ W qÊ tk
rJ } zt|ƒ‚W 5 d}~X Y qÊX n|zP|  |¡dkr~|   | j| |d|g | ¡ n|   | j| |d|g | ¡ W n* tk
rÈ } zt|ƒ‚W 5 d}~X Y nX dS )z:Compiles the source by spawning GCC and windres if needed.)ú.rcú.resZwindresz-iz-oNzc++)Úspawnr   r   Zdetect_languager   r   )r.   ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsÚmsgr   r   r   Ú_compileh   s*    ÿþýÿÿzCygwinCCompiler._compileNc                 C   s  t   |
p
g ¡}
t   |pg ¡}t   |p&g ¡}|r8|  t¡ | | j¡ |dk	rÜ|| jks`| jdkrÜtj 	|d ¡}tj 
tj |¡¡\}}tj ||d ¡}dtj |¡› �dg}| |¡ |  t||fd|› �¡ | |¡ |	sê|
 d¡ t | |||||||d|	|
|||¡ dS )	zLink the objects.Nr   r   z.defzLIBRARY ZEXPORTSzwriting z-s)Úcopyr$   Ú_runtime_library_dirs_msgÚextendr-   Z
EXECUTABLEr*   r'   ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚexecuter   Úappendr
   Úlink)r.   Ztarget_descÚobjectsZoutput_filenameÚ
output_dirÚ	librariesÚlibrary_dirsÚruntime_library_dirsÚexport_symbolsÚdebugZextra_preargsrC   Ú
build_tempZtarget_langÚtemp_dirZdll_nameZdll_extensionZdef_fileÚcontentsr   r   r   rP   €   sL    
ÿÿ
ÿ


òzCygwinCCompiler.linkc                 C   s   |   t¡ g S ©N)r$   rG   ©r.   Údirr   r   r   Úruntime_library_dir_optionÙ   s    
z*CygwinCCompiler.runtime_library_dir_optionc                    s   t j |¡}tƒ  |||¡S r[   )r'   rI   Únormcaser   Ú_make_out_path)r.   rR   Z	strip_dirÚsrc_nameZnorm_src_namer5   r   r   r`   â   s    zCygwinCCompiler._make_out_pathc                    s   t ƒ j‡ fdd„dD ƒ–S )z3
        Add support for rc and res files.
        c                    s   i | ]}||ˆ j  “qS r   )Úobj_extension)Ú.0rB   r;   r   r   Ú
<dictcomp>î   s      z2CygwinCCompiler.out_extensions.<locals>.<dictcomp>)r>   r=   )r   Úout_extensionsr;   r5   r;   r   re   ç   s    þzCygwinCCompiler.out_extensions)FFF)
NNNNNFNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompiler_typerb   Zstatic_lib_extensionÚshared_lib_extensionZdylib_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZexe_extensionr    Úpropertyr<   rE   rP   r^   r`   re   Ú__classcell__r   r   r5   r   r   (   s:   $
          ò
Y	r   c                       s.   e Zd ZdZdZd‡ fdd„	Zdd„ Z‡  ZS )	ÚMingw32CCompilerz:Handles the Mingw32 port of the GNU C compiler to Windows.Zmingw32Fc                    s„   t ƒ  |||¡ d}t| jƒr&tdƒ‚| j| j› d�| j› d�| j› d�| j› d�| j› | j› d|› �| j› | j› d|› �d� d S )Nr   z1Cygwin gcc cannot be used with --compiler=mingw32z	 -O -Wallz -shared -O -Wallú )r   r   r   r   r   r   r   r   )	r   r    Úis_cygwinccr%   r   r,   r&   r*   r+   )r.   r/   r0   r1   r4   r5   r   r   r    ø   s    




øzMingw32CCompiler.__init__c                 C   s   t tƒ‚d S r[   )r   rG   r\   r   r   r   r^     s    z+Mingw32CCompiler.runtime_library_dir_option)FFF)rf   rg   rh   ri   rj   r    r^   rm   r   r   r5   r   rn   ó   s   rn   Úokznot okZ	uncertainc               
   C   sÆ   ddl m}  dtjkrtdfS dtjkr0tdfS |  ¡ }zt |¡jdd�}W n< t	k
rŠ } zt
d	|› d
|j› �f W Y ¢S d}~X Y n8X d}||kr¢t}d}nt}d}||›d|› d|›�fS dS )aw  Check 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   )Ú	sysconfigZGCCzsys.version mentions 'GCC'ZClangzsys.version mentions 'Clang'zutf-8)Úencodingzcouldn't read 'z': NZ__GNUC__Zmentionszdoes not mentionro   )Ú	distutilsrr   ÚsysÚversionr#   Úget_config_h_filenameÚpathlibÚPathÚ	read_textÚOSErrorÚCONFIG_H_UNCERTAINÚstrerrorÚCONFIG_H_NOTOK)rr   ÚfnÚconfig_hÚexcZ	substringÚcodeZmention_inflectedr   r   r   r!     s"    

,r!   c                 C   s"   t t | ¡dg ƒ}| ¡  d¡S )zCTry to determine if the compiler that would be used is from cygwin.z-dumpmachines   cygwin)r   ÚshlexÚsplitÚstripÚendswith)r%   Z
out_stringr   r   r   rp   I  s    rp   )!ri   rF   r'   rx   rƒ   ru   r9   Ú
subprocessr   Úerrorsr   r   r   r   Ú	file_utilr   rr   r	   Zunixccompilerr
   rv   r   r   r   rG   r   rn   r#   r~   r|   r!   rp   Úget_versionsr   r   r   r   Ú<module>   s2   ÿ L 1