o
    “si5;  ã                   @   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mZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZ ddlmZmZ d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)ÚUnixCCompiler)Ú
write_file)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚCCompilerErrorÚCompileErrorÚUnknownFileError)ÚLooseVersionÚsuppress_known_deprecationc                  C   s¼   t j d¡} | dkr\t j| d | d … }|dkrdgS |dkr#dgS |d	kr*d
gS |dkr1dgS |dkr8dgS |dkr?dgS |dkrFdgS dt|ƒ  krUdk rVddgS  td| ƒ‚dS )zaInclude the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    zMSC v.éÿÿÿÿé   é
   Z1300Zmsvcr70Z1310Zmsvcr71Z1400Zmsvcr80Z1500Zmsvcr90Z1600Zmsvcr100Z1700Zmsvcr110Z1800Zmsvcr120il  iÐ  ÚucrtZvcruntime140zUnknown MS Compiler version %s N)ÚsysÚversionÚfindÚintÚ
ValueError)Zmsc_posZmsc_ver© r   útC:\Users\PC\students\dividedattentionclub\venv\lib\python3.10\site-packages\setuptools/_distutils/cygwinccompiler.pyÚ	get_msvcrE   s,   þår   c                       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ddd„Z‡  ZS )ÚCygwinCCompilerz9Handles the Cygwin port of the GNU C compiler to Windows.Úcygwinz.oú.az.dll.az.dllzlib%s%szcyg%s%sz.exer   c                    s°   t ƒ  |||¡ tƒ \}}|  d||f ¡ |tur!|  d| ¡ tj dd¡| _	tj dd¡| _
| j	| _d}| jd| j	 d	| j	 d| j
 d
| j	 d| j|f d� tƒ | _d S )Nz%Python's GCC status: %s (details: %s)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%s -mcygwin %s©ÚcompilerÚcompiler_soZcompiler_cxxZ
linker_exeZ	linker_so)ÚsuperÚ__init__Úcheck_config_hZ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#   u   s*   
þÿû
zCygwinCCompiler.__init__c                 C   sB   t jdtdd� tƒ � tdƒW  d   ƒ S 1 sw   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
   )r/   r   r   r   Úgcc_version”   s   ü$ÿzCygwinCCompiler.gcc_versionc              
   C   s’   |dks|dkr&z|   dd|d|g¡ W dS  ty% } zt|ƒ‚d}~ww z|   | j| |d|g | ¡ W dS  tyH } zt|ƒ‚d}~ww )z:Compiles the source by spawning GCC and windres if needed.ú.rcú.resÚwindresz-iz-oN)Zspawnr   r   r!   )r/   ÚobjÚsrcÚextZcc_argsÚextra_postargsZpp_optsÚmsgr   r   r   Ú_compile£   s   €ÿ
ÿ€ÿzCygwinCCompiler._compileNc                 C   s6  t   |
pg ¡}
t   |pg ¡}t   |pg ¡}|r |  dt|ƒ ¡ | | j¡ |dur€|| jks4| jdkr€tj 	|d ¡}tj 
tj |¡¡\}}tj ||d ¡}tj |d| d ¡}dtj |¡ d	g}|D ]}| |¡ qh|  t||fd
| ¡ | |¡ |	s‡|
 d¡ t | |||||||d|	|
|||¡ dS )zLink the objects.z5I don't know what to do with 'runtime_library_dirs': Nr   r   z.defÚlibr   z
LIBRARY %sZEXPORTSz
writing %sz-s)Úcopyr&   ÚstrÚextendr.   Z
EXECUTABLEr,   r'   ÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendÚexecuter   r   Úlink)r/   Ztarget_descÚobjectsZoutput_filenameÚ
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsÚdebugZextra_preargsrC   Z
build_tempZtarget_langÚtemp_dirZdll_nameZdll_extensionZdef_fileZlib_fileÚcontentsÚsymr   r   r   rQ   ³   sR   ÿÿ

ÿ

òzCygwinCCompiler.linkc                 C   s   |   d¡ g S ©Nz<don't know how to set runtime library search path on Windows)r&   ©r/   Údirr   r   r   Úruntime_library_dir_option  s   
z*CygwinCCompiler.runtime_library_dir_optionÚ c                 C   sª   |du rd}g }|D ]H}t j t j |¡¡\}}|| jddg vr)td||f ƒ‚|r1t j |¡}|dv rE| t j ||| | j	 ¡¡ q
| t j ||| j	 ¡¡ q
|S )z#Adds supports for rc and res files.Nr\   r=   r>   z"unknown file type '%s' (from '%s'))r>   r=   )
r'   rJ   rL   ÚnormcaseZsrc_extensionsr	   rM   rO   rN   Úobj_extension)r/   Zsource_filenamesZ	strip_dirrS   Z	obj_namesZsrc_nameÚbaserB   r   r   r   Úobject_filenames  s"   
ÿÿz CygwinCCompiler.object_filenames©r   r   r   )
NNNNNr   NNNN)r   r\   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úcompiler_typer^   Zstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZexe_extensionr#   Úpropertyr<   rE   rQ   r[   r`   Ú__classcell__r   r   r6   r   r   h   s8    

ò`	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mingw32r   c                    sn   t ƒ  |||¡ d}t| jƒrtdƒ‚| jd| j d| j d| j d| j d| j|f d� g | _t	ƒ | _d S )Nr   z1Cygwin gcc cannot be used with --compiler=mingw32z%s -O -Wallz%s -mdll -O -Wallz%sz%s %sr   )
r"   r#   Úis_cygwinccr*   r   r-   r+   r,   r.   r   )r/   r0   r1   r2   r5   r6   r   r   r#   :  s   
ûzMingw32CCompiler.__init__c                 C   s   t dƒ‚rX   )r   rY   r   r   r   r[   V  s   ÿz+Mingw32CCompiler.runtime_library_dir_optionra   )rb   rc   rd   re   rf   r#   r[   rh   r   r   r6   r   ri   5  s
    ri   Úokznot okZ	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|ƒ}zd| ¡ v r4td| fW | ¡  W S t	d	| fW | ¡  W S | ¡  w  t
y_ } ztd
||jf fW  Y d}~S d}~w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'ZClangzsys.version mentions 'Clang'Z__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'zcouldn't read '%s': %sN)Ú	distutilsrl   r   r   r%   Úget_config_h_filenameÚopenÚreadÚcloseÚCONFIG_H_NOTOKÚOSErrorÚCONFIG_H_UNCERTAINÚstrerror)rl   ÚfnÚconfig_hÚexcr   r   r   r$   e  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*   Z
out_stringr   r   r   rj   ”  s   rj   )re   r'   r   rG   rz   r:   Ú
subprocessr   Zdistutils.unixccompilerr   Zdistutils.file_utilr   Zdistutils.errorsr   r   r   r   r	   Zdistutils.versionr
   r   r   r   ri   r%   rs   ru   r$   rj   Úget_versionsr   r   r   r   Ú<module>   s,    1# N+/