a
    ñ»j².  ã                   @   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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 d
gdgdgdgdgdgdgdgejdœ	¡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é   )ÚRangeMap)ÚCCompilerErrorÚCompileErrorÚDistutilsExecErrorÚDistutilsPlatformError)Ú
write_file)ÚUnixCCompiler)ÚLooseVersionÚsuppress_known_deprecationZmsvcr70Zmsvcr71Zmsvcr80Zmsvcr90Zmsvcr100Zmsvcr110Zmsvcr120Zvcruntime140)	i  i  ix  iÜ  i@  i¤  i  il  iÐ  c                  C   sj   t  dtj¡} zt|  d¡ƒ}W n ty6   g  Y S 0 z
t| W S  tyd   t	d|› d�ƒ‚Y n0 dS )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 ú N)
ÚreÚsearchÚsysÚversionÚintÚgroupÚAttributeErrorÚ_msvcr_lookupÚKeyErrorÚ
ValueError)ÚmatchZmsc_ver© r   úKE:\soccer\ml_env\Lib\site-packages\setuptools/_distutils/cygwinccompiler.pyÚ	get_msvcr4   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rL|  d|› d�¡ tj dd¡| _	tj dd	¡| _
| j	| _d
}| j| 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Ú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__r   r   r*   V   s*    
ÿÿ



û
zCygwinCCompiler.__init__c                 C   sB   t jdtdd� tƒ � tdƒW  d   ƒ S 1 s40    Y  d S )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)Úwarningsr.   ÚDeprecationWarningr   r   ©r7   r   r   r   Úgcc_versiont   s    üzCygwinCCompiler.gcc_versionc              
   C   s¤   |dv rPz|   dd|d|g¡ W q  tyL } zt|ƒ‚W Y d}~q d}~0 0 nPz"|   | j| |d|g | ¡ W n, tyž } zt|ƒ‚W Y d}~n
d}~0 0 dS )z:Compiles the source by spawning GCC and windres if needed.)ú.rcú.resZwindresz-iz-oN)Úspawnr   r   r%   )r7   ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsÚmsgr   r   r   Ú_compileƒ   s     ÿzCygwinCCompiler._compileNc                 C   s  t   |
p
g ¡}
t   |pg ¡}t   |p&g ¡}|r8|  t¡ | | j¡ |duræ|| jks`| jdkrætj 	|d ¡}tj 
tj |¡¡\}}tj ||d ¡}dtj |¡› �dg}|D ]}| |¡ q´|  t||fd|› �¡ | |¡ |	sô|
 d¡ t | |||||||d|	|
|||¡ dS )	zLink the objects.Nr    r   z.defzLIBRARY ZEXPORTSzwriting z-s)Úcopyr.   Ú_runtime_library_dirs_msgÚextendr6   Z
EXECUTABLEr4   r/   ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendÚexecuter	   r
   Úlink)r7   Ztarget_descÚobjectsZoutput_filenameÚ
output_dirÚ	librariesÚlibrary_dirsÚruntime_library_dirsÚexport_symbolsÚdebugZextra_preargsrL   Ú
build_tempZtarget_langÚtemp_dirZdll_nameZdll_extensionZdef_fileÚcontentsÚsymr   r   r   rY   “   sN    
ÿÿ
ÿ

òzCygwinCCompiler.linkc                 C   s   |   t¡ g S ©N)r.   rP   ©r7   Údirr   r   r   Úruntime_library_dir_optioní   s    
z*CygwinCCompiler.runtime_library_dir_optionc                    s   t j |¡}tƒ  |||¡S re   )r/   rR   Únormcaser)   Ú_make_out_path)r7   r[   Z	strip_dirÚsrc_nameZnorm_src_namer>   r   r   rj   ö   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)Ú.0rK   rD   r   r   Ú
<dictcomp>  ó    z2CygwinCCompiler.out_extensions.<locals>.<dictcomp>)rG   rF   )r)   Úout_extensionsrD   r>   rD   r   rp   û   s
    ÿþzCygwinCCompiler.out_extensions)FFF)
NNNNNFNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompiler_typerl   Zstatic_lib_extensionÚshared_lib_extensionZdylib_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZexe_extensionr*   ÚpropertyrE   rN   rY   rh   rj   rp   Ú__classcell__r   r   r>   r   r   I   s:   
          ò
Z	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                    sf   t ƒ  |||¡ d}t| jƒr&tdƒ‚| j| j› d�| j› d�| j› d�| j› | j› d|› �d� d S )Nr"   z1Cygwin gcc cannot be used with --compiler=mingw32z	 -O -Wallz -shared -O -Wallr   r#   )r)   r*   Úis_cygwinccr2   r   r5   r3   r4   )r7   r8   r9   r:   r=   r>   r   r   r*     s    



ûzMingw32CCompiler.__init__c                 C   s   t tƒ‚d S re   )r   rP   rf   r   r   r   rh     s    z+Mingw32CCompiler.runtime_library_dir_option)FFF)rq   rr   rs   rt   ru   r*   rh   rx   r   r   r>   r   ry     s   ry   Úokznot okZ	uncertainc               
   C   sÂ   ddl m}  dtjv rtdfS dtjv r0tdfS |  ¡ }zJt |¡jdd�}d	}||v rbt}d
}nt	}d}||›d|› d|›�fW S  t
y¼ } z"td|› d|j› �fW  Y d}~S d}~0 0 d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__GNUC__Zmentionszdoes not mentionr   zcouldn't read 'z': N)Ú	distutilsr|   r   r   r-   Úget_config_h_filenameÚpathlibÚPathÚ	read_textÚCONFIG_H_NOTOKÚOSErrorÚCONFIG_H_UNCERTAINÚstrerror)r|   ÚfnÚconfig_hZ	substringÚcodeZmention_inflectedÚexcr   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)r2   Z
out_stringr   r   r   rz   Y  s    rz   )%rt   rO   r/   r€   r   r‹   r   rB   Ú
subprocessr   Ú_collectionsr   Úerrorsr   r   r   r   Ú	file_utilr	   Zunixccompilerr
   r   r   r   ÚleftZundefined_valuer   r   rP   r   ry   r-   rƒ   r…   r+   rz   Úget_versionsr   r   r   r   Ú<module>   sL   ïÿÿ ?0