o
    LK&hD.                     @   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   [/var/www/html/venv/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  ||| 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_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!   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 )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_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   )r/   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)r/   target_descobjectsoutput_filename
output_dir	librarieslibrary_dirsruntime_library_dirsexport_symbolsdebugextra_preargsrG   
build_temptarget_langtemp_dirdll_namedll_extensiondef_filecontentsr6   r   r   rW      sD   





zCompiler.linkc                 C   s   |  t g S N)r%   rM   r/   dirr   r   r   runtime_library_dir_option   s   
z#Compiler.runtime_library_dir_optionc                    s   t j|}t |||S ri   )r(   rP   normcaser    _make_out_path)r/   r[   	strip_dirsrc_namenorm_src_namer6   r   r   rn      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).0rE   r<   r   r   
<dictcomp>   s    z+Compiler.out_extensions.<locals>.<dictcomp>)r?   r>   )r    out_extensionsr<   r6   r<   r   ru      s
   zCompiler.out_extensionsFFF)
NNNNNFNNNN)__name__
__module____qualname____doc__compiler_typerr   static_lib_extensionshared_lib_extensiondylib_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatexe_extensionr!   propertyr=   rJ   rW   rl   rn   ru   __classcell__r   r   r6   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,   )r/   r0   r1   r2   r5   r6   r   r   r!      s   





zMinGW32Compiler.__init__c                 C   s   t tri   )r   rM   rj   r   r   r   rl     s   z*MinGW32Compiler.runtime_library_dir_optionrv   )rw   rx   ry   rz   r{   r!   rl   r   r   r   r6   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   )!rz   rL   r(   r   r   r   r:   
subprocessr   errorsr   r   	file_utilr   r   r   r   r   r	    r   r   r   r   rM   r   r   r$   r   r   r"   r   get_versionsr   r   r   r   <module>   s6     K 1