Ë
    
_ßd”.  ã                   ó>  — 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
 ddlmZ ddlmZmZmZmZ ddlmZmZ dd	lmZ  ej.                  d
gdgdgdgdgdgdgdgej0                  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é   )ÚUnixCCompiler)Ú
write_file)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚCCompilerErrorÚCompileError)ÚLooseVersionÚsuppress_known_deprecation)ÚRangeMapÚ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 Y yw xY w# t        $ r t        d|z  «      ‚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   NzUnknown MS Compiler version %s )
ÚreÚsearchÚsysÚversionÚintÚgroupÚAttributeErrorÚ_msvcr_lookupÚKeyErrorÚ
ValueError)ÚmatchÚmsc_vers     úG/usr/lib/python3/dist-packages/setuptools/_distutils/cygwinccompiler.pyÚ	get_msvcrr$   4   sx   € ô �I‰IÐ'¬¯©Ó5€EðÜ�e—k‘k !“nÓ%ˆðFÜ˜WÑ%Ð%øô ò Ùðûô ò FÜÐ:¸WÑDÓEÐEðFús   ¦A
 ÁA Á
	AÁAÁA1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           
      ó\  •— t         ‰| �  |||«       t        «       \  }}| j                  dj	                  ||«      «       |t
        ur| j                  d|z  «       t        j                  j                  dd«      | _
        t        j                  j                  dd«      | _        | j                  | _        d}| j                  d| j                  z  d	| j                  z  d| j                  z  d
| j                  z  dj	                  | j                  |«      ¬«       t        «       | _        y )Nz%Python's GCC status: {} (details: {})zƒPython's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.ÚCCÚgccÚCXXzg++ú-sharedz%s -mcygwin -O -Wallz%s -mcygwin -mdll -O -Wallz%s -mcygwinz{} -mcygwin {}©ÚcompilerÚcompiler_soÚcompiler_cxxÚ
linker_exeÚ	linker_so)ÚsuperÚ__init__Úcheck_config_hÚdebug_printÚformatÚ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#   r4   zCygwinCCompiler.__init__V   s  ø€ Ü‰Ñ˜ '¨5Ô1ä(Ó*‰ˆ�Ø×ÑØ3×:Ñ:¸6À7ÓKô	
ð œÑ$Ø�I‰IðOàQXñYôô —*‘*—.‘.  uÓ-ˆŒÜ—:‘:—>‘> %¨Ó/ˆŒàŸ'™'ˆŒØ!ˆà×ÑØ+¨d¯g©gÑ5Ø4°t·w±wÑ>Ø/°$·(±(Ñ:Ø$ t§w¡wÑ.Ø'×.Ñ.¨t¯©ÀÓNð 	ô 	
ô '›[ˆÕó    c                 ó�   — t        j                  dt        d¬«       t        «       5  t	        d«      cd d d «       S # 1 sw Y   y xY w)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)Úwarningsr9   ÚDeprecationWarningr   r   )rB   s    r#   Úgcc_versionzCygwinCCompiler.gcc_versionv   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
   r/   )rB   ÚobjÚsrcÚextÚcc_argsÚextra_postargsÚpp_optsÚmsgs           r#   Ú_compilezCygwinCCompiler._compile…   s�   € à�/Ñ!ð(Ø—
‘
˜I t¨S°$¸Ð<Õ=ð(Ø—
‘
Ø×$Ñ$ wÑ.°#°t¸SÐ1AÑAÀNÑ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(  rít        j                  j                  |d   «      }t        j                  j                  t        j                  j                  |«      «      \  }}t        j                  j                  ||dz   «      }dt        j                  j                  |«      z  dg}|D ]  }|j                  |«       Œ | j                  t        ||fd|z  «       |j                  |«       |	s|
j                  d«       t!        j"                  | |||||||d|	|
|||«       y)	zLink the objects.Nr*   r   z.defz
LIBRARY %sÚEXPORTSz
writing %sz-s)Úcopyr9   Ú_runtime_library_dirs_msgÚextendrA   Ú
EXECUTABLEr?   r:   ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendÚexecuter   r   Úlink)rB   Útarget_descÚobjectsÚoutput_filenameÚ
output_dirÚ	librariesÚlibrary_dirsÚruntime_library_dirsÚexport_symbolsÚdebugÚextra_preargsrZ   Ú
build_tempÚtarget_langÚtemp_dirÚdll_nameÚdll_extensionÚdef_fileÚcontentsÚsyms                       r#   rk   zCygwinCCompiler.link•   sŒ  € ô$ Ÿ	™	 -Ò"5°2Ó6ˆÜ—I‘I˜išo¨2Ó.ˆ	Ü—)‘)˜GšM rÓ*ˆáØ�I‰IÔ/Ô0ð 	×Ñ˜×+Ñ+Ô,ð Ñ&Ø˜4Ÿ?™?Ò*¨d¯o©oÀÒ.Fô —w‘w—‘ w¨q¡zÓ2ˆHä(*¯©×(8Ñ(8Ü—‘× Ñ  Ó1ó)Ñ%ˆX�}ô
 —w‘w—|‘| H¨h¸Ñ.?Ó@ˆHð %¤r§w¡w×'7Ñ'7¸Ó'HÑHÈ)ÐTˆHØ%ò %�Ø—‘ Õ$ð%à�L‰Lœ h°Ð%9¸<È(Ñ;RÔSð
 �N‰N˜8Ô$ñ Ø× Ñ  Ô&ä×ÑØØØØØØØØ ØØØØØØõ	
rJ   c                 ó0   — | j                  t        «       g S ©N)r9   ra   ©rB   Údirs     r#   Úruntime_library_dir_optionz*CygwinCCompiler.runtime_library_dir_optionï   s   € ð 	�	‰	Ô+Ô,Øˆ	rJ   c                 ód   •— t         j                  j                  |«      }t        ‰| �  |||«      S r   )r:   rd   Únormcaser3   Ú_make_out_path)rB   ro   Ú	strip_dirÚsrc_nameÚnorm_src_namerI   s        €r#   r…   zCygwinCCompiler._make_out_pathø   s+   ø€ äŸ™×(Ñ(¨Ó2ˆÜ‰wÑ% j°)¸]ÓKÐKrJ   c                 ób   •— i t         ‰| �  ¥dD �ci c]  }||| j                  z   “Œ c}¥S c c}w )z3
        Add support for rc and res files.
        )rS   rR   )r3   Úout_extensionsÚobj_extension)rB   rX   rI   s     €r#   rŠ   zCygwinCCompiler.out_extensionsý   s@   ø€ ð

Ü‰gÑ$ð
à8GÖH°ˆs�C˜$×,Ñ,Ñ,Ñ,ÒHð
ð 	
ùâHs   ‘,©r   r   r   )
NNNNNr   NNNN)Ú__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_extensionr4   ÚpropertyrP   r]   rk   r‚   r…   rŠ   Ú__classcell__©rI   s   @r#   r&   r&   I   sž   ø„ ÙCà€MØ€MØÐØ#ÐØ ÐØ!ÐØ!ÐØ ÐØ€Mõ)ð@ ñ*ó ð*ò(ð* ØØØ!ØØØØØØóX
òtôLð
 ó
ó ô
rJ   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           
      ó4  •— t         ‰| �  |||«       d}t        | j                  «      rt	        d«      ‚| j                  d| j                  z  d| j                  z  d| j                  z  d| j                  z  dj                  | j                  |«      ¬«       y )Nr,   z1Cygwin gcc cannot be used with --compiler=mingw32z%s -O -Wallz%s -mdll -O -Wallz%sz{} {}r-   )	r3   r4   Úis_cygwinccr=   r	   r@   r>   r7   r?   )rB   rC   rD   rE   rH   rI   s        €r#   r4   zMingw32CCompiler.__init__  s…   ø€ Ü‰Ñ˜ '¨5Ô1à!ˆä�t—w‘wÔÜ Ð!TÓUÐUà×ÑØ" T§W¡WÑ,Ø+¨d¯g©gÑ5Ø&¨¯©Ñ1Ø˜dŸg™g‘~Ø—n‘n T§_¡_°mÓDð 	õ 	
rJ   c                 ó    — t        t        «      ‚r   )r   ra   r€   s     r#   r‚   z+Mingw32CCompiler.runtime_library_dir_option  s   € Ü$Ô%>Ó?Ð?rJ   rŒ   )r�   rŽ   r�   r�   r‘   r4   r‚   rš   r›   s   @r#   r�   r�   	  s   ø„ ÙDà€Mõ
ö @rJ   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        |«      }	 d|j                  «       v rt        d|z  f|j                  «        S t        d	|z  f|j                  «        S # |j                  «        w xY w# t        $ r,}t        d
j                  ||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'Ú__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '{}': {}N)Ú	distutilsr¥   r   r   r8   Úget_config_h_filenameÚopenÚreadÚcloseÚCONFIG_H_NOTOKÚOSErrorÚCONFIG_H_UNCERTAINr7   Ústrerror)r¥   ÚfnÚconfig_hÚexcs       r#   r5   r5   +  sÚ   € õ* $ð ”—‘ÑÜÐ8Ð8Ð8ð ”#—+‘+ÑÜÐ:Ð:Ð:ð 
×	(Ñ	(Ó	*€Bð
WÜ˜“8ˆð	Ø˜XŸ]™]›_Ñ,Ü"Ð$>ÀÑ$CÐCð �N‰NÕô &Ð'IÈBÑ'NÐNà�N‰NÕøˆH�N‰NÕûÜò WÜ"Ð$<×$CÑ$CÀBÈÏÉÓ$UÐVÕVûðWúsB   ÁB5 ÁB  Á4B5 Â
B  ÂB5 Â B2Â2B5 Â5	C*Â>!C%ÃC*Ã%C*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    Z  s6   € äœeŸk™k¨"›o°Ð0@Ñ@ÓA€JØ×ÑÓ×&Ñ& yÓ1Ð1rJ   )$r�   r:   r   r   r`   r¶   rN   Ú
subprocessr   Úunixccompilerr   Ú	file_utilr   Úerrorsr   r   r	   r
   r   r   r   Ú_collectionsr   ÚleftÚundefined_valuer   r$   ra   r&   r�   r8   r®   r°   r5   r    Úget_versions© rJ   r#   ú<module>rÄ      sÜ   ðñó 
Û 	Û 
Û Û Û Ý #å (Ý !÷ó ÷ >Ý "ð �—‘ð ˆkàˆkàˆkàˆkàˆlàˆlàˆlàÐØ×&Ñ&ñ#ó€ò.Fð Ið ô|
�mô |
ô@@�ô @ð: €Ø€Ø Ð ò,Wò^2ð €ðrJ   