
    \jb.                       d Z ddlm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 ZdZ G d dej6                        Z G d de      ZdZdZdZd Z ddZ!dZ"y)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).
    )annotationsN)check_output   )DistutilsExecErrorDistutilsPlatformError)
write_file)get_config_vars)LooseVersionsuppress_known_deprecation   )unix)CompileErrorErrorc                     g S )z6No longer needed, but kept for backward compatibility. r       [/root/.hermes/venv/lib/python3.12/site-packages/setuptools/_distutils/compilers/C/cygwin.py	get_msvcrr   !   s    Ir   zxUnable to set runtime library search path on Windows, usually indicated by `runtime_library_dirs` parameter to Extensionc                       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
	Zed        Zd Z	 	 	 	 	 	 	 	 	 	 d fd	Zd Z fdZe fd       Z x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.exec                   t         |   ||       t               \  }}| j                  d| d| d       |t        ur| j                  d| d       t        dd      \  | _        | _        t        j                  j                  d| j                  xs d	      | _        t        j                  j                  d| j                  xs d
      | _        | j                  | _        | j                  | _        d}| j                  | j                   d| j                   d| j                   d| j                   d| j                   d| j                   d| | j                   d| j                   d|        t               | _        y )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__s         r   r(   zCompiler.__init__9   s{   .(*0G9ANO$II") $OO ,D%8 **..tww'7%8::>>%):U;''"hh!y 2377)#;< HH:%78#xxj(@A''),)M?C"hhZy1!001M?K 	 		
 '[r   c                    t        j                  dt        d       t               5  t	        d      cd d d        S # 1 sw Y   y xY w)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
   )r6   s    r   gcc_versionzCompiler.gcc_version]   sA     	X		
 () 	*)	* 	* 	*s	   <Ac                t   |dv r	 | j                  dd|d|g       y	 | j                  |      dk(  r(| j                  | j                  |z   |d|gz   |z          y| j                  | j
                  |z   |d|gz   |z          y# t        $ r}t        |      d}~ww xY w# t        $ r}t        |      d}~ww xY w)z:Compiles the source by spawning GCC and windres if needed.).rc.reswindresz-iz-oNzc++)spawnr   r   detect_languager"   r    )r6   objsrcextcc_argsextra_postargspp_optsmsgs           r   _compilezCompiler._compilel   s    /!(

ItS$<=('',5JJ,,!"c*+ )) JJ((72c45EEV & ("3''( & ("3''(s4   B ;B 'B 	BBB	B7'B22B7c                j   t        j                   |
xs g       }
t        j                   |xs g       }t        j                   |xs g       }|r| j                  t               |j                  | j                         ||| j
                  k7  s| j                  dk(  rt        j                  j                  |d         }t        j                  j                  t        j                  j                  |            \  }}t        j                  j                  ||dz         }dt        j                  j                  |       dg}|j                  |       | j                  t        ||fd|        |j                  |       |	s|
j                  d       t         | E  |||||||d|	|
|||       y)	zLink the objects.Nr   r   z.defzLIBRARY EXPORTSzwriting z-s)copyr,   _runtime_library_dirs_msgextendr5   
EXECUTABLEr2   r/   pathdirnamesplitextbasenamejoinexecuter   appendr'   link)r6   target_descobjectsoutput_filename
output_dir	librarieslibrary_dirsruntime_library_dirsexport_symbolsdebugextra_preargsrL   
build_temptarget_langtemp_dirdll_namedll_extensiondef_filecontentsr;   s                      r   r]   zCompiler.link   s~   $ 		-"526IIio2.	))GMr*II/0 	++, &4??*doo.F wwwqz2H(*(8(8  1)%X}
 ww||Hh.?@H #277#3#3O#D"EF	RHOON+LLh%9XhZ;PQ
 NN8$   & 	
r   c                0    | j                  t               g S N)r,   rS   r6   dirs     r   runtime_library_dir_optionz#Compiler.runtime_library_dir_option   s     			+,	r   c                d    t         j                  j                  |      }t        |   |||      S rp   )r/   rV   normcaser'   _make_out_path)r6   ra   	strip_dirsrc_namenorm_src_namer;   s        r   rv   zCompiler._make_out_path   s+    ((2w%j)]KKr   c                b    i t         |   dD ci c]  }||| j                  z    c}S c c}w )z3
        Add support for rc and res files.
        )rD   rC   )r'   out_extensionsobj_extension)r6   rJ   r;   s     r   r{   zCompiler.out_extensions   s@    

g$
8GHsC$,,,,H
 	
Hs   ,FF)
NNNNNFNNNN)__name__
__module____qualname____doc__compiler_typer|   static_lib_extensionshared_lib_extensiondylib_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatexe_extensionr(   propertyrA   rO   r]   rs   rv   r{   __classcell__r;   s   @r   r   r   ,   s    CMM# !! M")H * *(: !V
pL
 
 
r   r   c                  .     e Zd ZdZdZd fd	Zd Z xZS )MinGW32Compilerz:Handles the Mingw32 port of the GNU C compiler to Windows.mingw32c                l   t         |   ||       d}t        | j                        rt	        d      | j                  | j                   d| j                   d| j                   d| j                   d| j                   | j                   d| | j                   | j                   d|        y )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   r4   r.   r2   r3   )r6   r7   r   r:   r;   s       r   r(   zMinGW32Compiler.__init__   s    %(!twwKLLy	*77)#45#xxj(9: HH:Y/'')=/:"hhZ!001=/B 	 		
r   c                     t        t              rp   )r   rS   rq   s     r   rs   z*MinGW32Compiler.runtime_library_dir_option  s    $%>??r   r}   )r~   r   r   r   r   r(   rs   r   r   s   @r   r   r      s    DM
&@r   r   okznot ok	uncertainc                    ddl m}  dt        j                  v rt        dfS dt        j                  v rt        dfS | j                         }	 t        j                  |      j                  d      }d	}||v r	t        }d
}nt        }d}||d| d|fS # t        $ r"}t        d| d|j                   fcY d}~S d}~ww xY w)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)encoding__GNUC__mentionszdoes not mentionr   zcouldn't read 'z': N)	distutilsr   sysversionr+   get_config_h_filenamepathlibPath	read_textCONFIG_H_NOTOKOSErrorCONFIG_H_UNCERTAINstrerror)r   fnconfig_h	substringcodemention_inflectedexcs          r   r)   r)     s    * $ 888 #++::: 
	(	(	*BA<<#--w-? 	 D *!D 2vQ019-@@@  M"obTS\\N$KLLMs   %B 	B?B:4B?:B?c                    t        t        j                  |       dgz         }|j                         j	                  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_strings     r   r   r   L  s6    ekk"o0@@AJ&&y11r   )r-   zstr | shlex._ShlexInstreamreturnbool)#r   
__future__r   rR   r/   r   r   r   r?   
subprocessr   errorsr   r   	file_utilr   r   r	   r   r
   r    r   r   r   r   rS   r   r   r+   r   r   r)   r   get_versionsr   r   r   <module>r      s    #  	   
  # $ ( ? I F
t}} F
T@h @@   .Ab2 r   