o
    Zhs.                     @   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   \/var/www/html/lang_env/lib/python3.10/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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 )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_hZ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   s4   






zCygwinCCompiler.__init__c                 C   sB   t jdtdd t  tdW  d    S 1 sw   Y  d S )Nzgcc_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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.resZwindresz-iz-oNzc++)Zspawnr   r   Zdetect_languager   r   )r-   objsrcextZcc_argsextra_postargsZpp_optsmsgr   r   r   _compileh   s2   

zCygwinCCompiler._compileNc                 C   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 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_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsdebugZextra_preargsrA   Z
build_tempZtarget_langtemp_dirZdll_nameZdll_extensionZdef_filecontentsr   r   r   rN      sF   





zCygwinCCompiler.linkc                 C   s   |  t g S N)r#   rE   r-   dirr   r   r   runtime_library_dir_option   s   
z*CygwinCCompiler.runtime_library_dir_optionc                    s   t j|}t |||S rT   )r&   rG   normcaser   _make_out_path)r-   rP   Z	strip_dirZsrc_nameZnorm_src_namer4   r   r   rY      s   zCygwinCCompiler._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).0r@   r:   r   r   
<dictcomp>   s    z2CygwinCCompiler.out_extensions.<locals>.<dictcomp>)r=   r<   )r   out_extensionsr:   r4   r:   r   r]      s
   zCygwinCCompiler.out_extensionsFFF)
NNNNNFNNNN)__name__
__module____qualname____doc__compiler_typerZ   Zstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZexe_extensionr    propertyr;   rC   rN   rW   rY   r]   __classcell__r   r   r4   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.   r/   r0   r3   r4   r   r   r       s   





zMingw32CCompiler.__init__c                 C   s   t trT   )r   rE   rU   r   r   r   rW     s   z+Mingw32CCompiler.runtime_library_dir_optionr^   )r_   r`   ra   rb   rc   r    rW   re   r   r   r4   r   rf      s
    rf   okznot okZ	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   )	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 mentionrg   )	distutilsrj   sysversionr"   get_config_h_filenamepathlibPath	read_textOSErrorCONFIG_H_UNCERTAINstrerrorCONFIG_H_NOTOK)rj   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   rh   I  s   rh   )!rb   rD   r&   rp   r{   rm   r8   
subprocessr   errorsr   r   r   r   Z	file_utilr   rj   r	   Zunixccompilerr
   rn   r   r   r   rE   r   rf   r"   rv   rt   r!   rh   get_versionsr   r   r   r   <module>   s4     L 1