
    f.                     F   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Zddlm	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mZ  ej0                  d
gdgdgdgdgdgdgdgej2                  d	      Zd ZdZ G d de      Z G d de      ZdZdZ dZ!d Z"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).
    N)check_output   )RangeMap)CCompilerErrorCompileErrorDistutilsExecErrorDistutilsPlatformError)
write_file)UnixCCompiler)LooseVersionsuppress_known_deprecationmsvcr70msvcr71msvcr80msvcr90msvcr100msvcr110msvcr120vcruntime140)	i  i  ix  i  i@  i  i  il  i  c                      t        j                  dt        j                        } 	 t	        | j                  d            }	 t        |   S # t        $ r g cY S w xY w# t        $ r t        d| d      w xY w)zaInclude the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    zMSC v\.(\d{4})r   zUnknown MS Compiler version  )
researchsysversionintgroupAttributeError_msvcr_lookupKeyError
ValueError)matchmsc_vers     Y/app/.heroku/python/lib/python3.12/site-packages/setuptools/_distutils/cygwinccompiler.py	get_msvcrr%   4   s~     II'5Eekk!n%DW%%  	  D7yBCCDs   A
 A 
AAA4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dZd Z fdZe fd       Z x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.exec           	      6   t         |   |||       t               \  }}| j                  d| d| d       |t        ur| j                  d| d       t        j                  j                  dd      | _	        t        j                  j                  dd	      | _
        | j                  | _        d
}| j                  | j                   d| j                   d| j                   d| j                   d| j                   d|        t               | _        y )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gccCXXzg++-sharedz -mcygwin -O -Wallz -mcygwin -mdll -O -Wallz	 -mcygwinz
 -mcygwin compilercompiler_socompiler_cxx
linker_exe	linker_so)super__init__check_config_hdebug_printCONFIG_H_OKwarnosenvirongetcccxx
linker_dllset_executablesr%   dll_libraries)selfverbosedry_runforcestatusdetailsshared_option	__class__s          r$   r6   zCygwinCCompiler.__init__V   s   '51(*0G9ANO$II") $OO **..u-::>>%/''!y 2377)#;< HH:%78''),//**]OD 	 	
 '[    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   )rC   s    r$   gcc_versionzCygwinCCompiler.gcc_versiont   sA     	X		
 () 	*)	* 	* 	*s	   <Ac                     |dv r	 | j                  dd|d|g       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-oN)spawnr   r   r1   )rC   objsrcextcc_argsextra_postargspp_optsmsgs           r$   _compilezCygwinCCompiler._compile   s    /!(

ItS$<=(

$$w.#tS1AANR	 & ("3''( & ("3''(s.   A 'A" 	AAA"	A;+A66A;c                    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}|D ]  }|j                  |        | j                  t        ||fd|        |j                  |       |	s|
j                  d       t!        j"                  | |||||||d|	|
|||       y)	zLink the objects.Nr,   r   z.defzLIBRARY EXPORTSzwriting z-s)copyr:   _runtime_library_dirs_msgextendrB   
EXECUTABLEr@   r;   pathdirnamesplitextbasenamejoinappendexecuter
   r   link)rC   target_descobjectsoutput_filename
output_dir	librarieslibrary_dirsruntime_library_dirsexport_symbolsdebugextra_preargsr[   
build_temptarget_langtemp_dirdll_namedll_extensiondef_filecontentssyms                       r$   rl   zCygwinCCompiler.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%$ &LLh%9XhZ;PQ
 NN8$   & 	
rK   c                 0    | j                  t               g S N)r:   rb   rC   dirs     r$   runtime_library_dir_optionz*CygwinCCompiler.runtime_library_dir_option   s     			+,	rK   c                 d    t         j                  j                  |      }t        |   |||      S r   )r;   re   normcaser5   _make_out_path)rC   rp   	strip_dirsrc_namenorm_src_namerJ   s        r$   r   zCygwinCCompiler._make_out_path   s+    ((2w%j)]KKrK   c                 b    i t         |   dD ci c]  }||| j                  z    c}S c c}w )z3
        Add support for rc and res files.
        )rT   rS   )r5   out_extensionsobj_extension)rC   rY   rJ   s     r$   r   zCygwinCCompiler.out_extensions   s@    

g$
8GHsC$,,,,H
 	
Hs   ,FFF)
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_extensionr6   propertyrQ   r^   rl   r   r   r   __classcell__rJ   s   @r$   r'   r'   I   s    CMM# !! M)< * *(* !X
tL
 
 
rK   r'   c                   .     e Zd ZdZdZd fd	Zd Z xZS )Mingw32CCompilerz:Handles the Mingw32 port of the GNU C compiler to Windows.mingw32c           	         t         |   |||       d}t        | j                        rt	        d      | j                  | j                   d| j                   d| j                   d| j                   | j                   d|        y )Nr.   z1Cygwin gcc cannot be used with --compiler=mingw32z	 -O -Wallz -shared -O -Wallr   r/   )r5   r6   is_cygwinccr>   r   rA   r?   r@   )rC   rD   rE   rF   rI   rJ   s        r$   r6   zMingw32CCompiler.__init__  s    '51!tww !TUUy	*77)#45 HH:Y/'')=/: 	 	
rK   c                      t        t              r   )r	   rb   r   s     r$   r   z+Mingw32CCompiler.runtime_library_dir_option  s    $%>??rK   r   )r   r   r   r   r   r6   r   r   r   s   @r$   r   r     s    DM
 @rK   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   r   r   r9   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$   r7   r7   )  s    * $ 888 #++::: 
	(	(	*BM<<#--w-?	 D *!D 2vQ019-@@@ M"obTS\\N$KLLMs   A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   Y  s6    ekk"o0@@AJ&&y11rK   )%r   ra   r;   r   r   r   r   rO   
subprocessr   _collectionsr   errorsr   r   r   r	   	file_utilr
   unixccompilerr   r   r   r   leftundefined_valuer   r%   rb   r'   r   r9   r   r   r7   r   get_versions rK   r$   <module>r      s     	  	  
  # "  " ( = kkkklll&&#.D I z
m z
|@ @:   -M`2 rK   