o
    5‘ði.  ã                   @   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 ddlmZ ddlmZ ddlmZmZ d	d
lmZ d	dl	mZmZ dd„ ZdZG dd„ dejƒ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é   )ÚDistutilsExecErrorÚDistutilsPlatformError)Ú
write_file)Úget_config_vars)ÚLooseVersionÚsuppress_known_deprecationé   )Úunix)ÚCompileErrorÚErrorc                   C   s   g S )z6No longer needed, but kept for backward compatibility.© r   r   r   úg/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/_distutils/compilers/C/cygwin.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‡ fdd„	Zdd„ Z‡ fdd„Ze‡ fdd„ƒZ‡  ZS )ÚCompilerz9Handles 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 ƒ j||d� tƒ \}}|  d|› d|› d�¡ |tur&|  d|› d�¡ tddƒ\| _| _t	j
 d| jp7d	¡| _t	j
 d| jpBd
¡| _| j| _| j| _d}| j| j› d�| j› d�| j› d�| j› d�| j› d�| j› d|› �| j› d�| j› d|› �d� tƒ | _d S )N)Úforcez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Úverboser   ÚstatusÚdetailsÚshared_option©Ú	__class__r   r   r"   7   s4   
ÿÿ





øzCompiler.__init__c                 C   sB   t jdtdd� tƒ � tdƒW  d   ƒ S 1 sw   Y  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   ©r0   r   r   r   Úgcc_version[   s   ü$ÿzCompiler.gcc_versionc              
   C   s¼   |dv r"z|   dd|d|g¡ W dS  ty! } zt|ƒ‚d}~ww z+|  |¡dkr<|   | j| |d|g | ¡ W dS |   | j| |d|g | ¡ W dS  ty] } zt|ƒ‚d}~ww )z:Compiles the source by spawning GCC and windres if needed.)ú.rcú.resÚwindresz-iz-oNzc++)Úspawnr   r   Údetect_languager   r   )r0   ÚobjÚsrcÚextÚcc_argsÚextra_postargsÚpp_optsÚmsgr   r   r   Ú_compilej   s2   €ÿÿþý
ÿ
ÿ€ÿzCompiler._compileNc                    s  t   |
pg ¡}
t   |pg ¡}t   |pg ¡}|r|  t¡ | | j¡ |durn|| jks0| jdkrntj 	|d ¡}tj 
tj |¡¡\}}tj ||d ¡}dtj |¡› �dg}| |¡ |  t||fd|› �¡ | |¡ |	su|
 d¡ tƒ  |||||||d|	|
|||¡ dS )	zLink the objects.Nr   r   z.defzLIBRARY ÚEXPORTSzwriting z-s)Úcopyr&   Ú_runtime_library_dirs_msgÚextendr/   Ú
EXECUTABLEr,   r)   ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚexecuter   Úappendr!   Úlink)r0   Útarget_descÚobjectsÚoutput_filenameÚ
output_dirÚ	librariesÚlibrary_dirsÚruntime_library_dirsÚexport_symbolsÚdebugÚextra_preargsrF   Ú
build_tempÚtarget_langÚtemp_dirÚdll_nameÚdll_extensionÚdef_fileÚcontentsr5   r   r   rV   ‚   sD   


ÿ


ózCompiler.linkc                 C   s   |   t¡ g S ©N)r&   rL   ©r0   Údirr   r   r   Úruntime_library_dir_optionÚ   s   
z#Compiler.runtime_library_dir_optionc                    s   t j |¡}tƒ  |||¡S rh   )r)   rO   Únormcaser!   Ú_make_out_path)r0   rZ   Ú	strip_dirÚsrc_nameÚnorm_src_namer5   r   r   rm   ã   s   zCompiler._make_out_pathc                    s   i 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)Ú.0rD   r;   r   r   Ú
<dictcomp>ï   s    z+Compiler.out_extensions.<locals>.<dictcomp>)r>   r=   )r!   Úout_extensionsr;   r5   r;   r   rt   è   s
   ÿþzCompiler.out_extensions©FF)
NNNNNFNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompiler_typerq   Ústatic_lib_extensionÚshared_lib_extensionÚdylib_lib_extensionÚstatic_lib_formatÚshared_lib_formatÚdylib_lib_formatÚexe_extensionr"   Úpropertyr<   rI   rV   rk   rm   rt   Ú__classcell__r   r   r5   r   r   *   s<    $
òX	r   c                       s.   e Zd ZdZdZd‡ fdd„	Zdd„ Z‡  ZS )	ÚMinGW32Compilerz:Handles the Mingw32 port of the GNU C compiler to Windows.Ú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-   )r0   r1   r   r4   r5   r   r   r"   ù   s   





øzMinGW32Compiler.__init__c                 C   s   t tƒ‚rh   )r   rL   ri   r   r   r   rk     s   z*MinGW32Compiler.runtime_library_dir_optionru   )rv   rw   rx   ry   rz   r"   rk   rƒ   r   r   r5   r   r„   ô   s
    r„   Úokznot okÚ	uncertainc               
   C   sÀ   ddl m}  dtjv rtdfS dtjv rtdfS |  ¡ }zt |¡jdd�}W n t	yD } zt
d	|› d
|j› �fW  Y d}~S d}~ww d}||v rPt}d}nt}d}||›d|› d|›�f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   )Ú	sysconfigÚGCCzsys.version mentions 'GCC'ÚClangzsys.version mentions 'Clang'zutf-8)Úencodingzcouldn't read 'z': NÚ__GNUC__Úmentionszdoes not mentionr†   )Ú	distutilsrŠ   ÚsysÚversionr%   Úget_config_h_filenameÚpathlibÚPathÚ	read_textÚOSErrorÚCONFIG_H_UNCERTAINÚstrerrorÚCONFIG_H_NOTOK)rŠ   ÚfnÚconfig_hÚexcÚ	substringÚcodeÚ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'   Ú
out_stringr   r   r   r‡   J  s   r‡   )!ry   rK   r)   r”   r¡   r‘   r9   Ú
subprocessr   Úerrorsr   r   Ú	file_utilr   rŠ   r   r’   r   r	   Ú r   r   r   r   rL   r   r„   r%   rš   r˜   r#   r‡   Úget_versionsr   r   r   r   Ú<module>   s6    ÿ K 1