509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \[@  ã               @   sþ   d Z ddlZddlZddlZddlmZmZmZ ddl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mZmZ ddlmZ dd	lmZ dd
l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!ej"dƒZ#dd„ Z$dd„ Z%d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)ÚPopenÚPIPEÚcheck_output)Úgen_preprocess_optionsÚgen_lib_options)ÚUnixCCompiler)Ú
write_file)ÚDistutilsExecErrorÚCCompilerErrorÚCompileErrorÚUnknownFileError)Úlog)ÚLooseVersion)Úfind_executablec              C   s€   t jjdƒ} | dkr|t j| d | d … }|dkr8dgS |dkrFdgS |d	krTd
gS |dkrbdgS |dkrpd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Unknown MS Compiler version %s Néÿÿÿÿ)ÚsysÚversionÚfindÚ
ValueError)Zmsc_posZmsc_ver© r   ú1/usr/lib64/python3.6/distutils/cygwinccompiler.pyÚ	get_msvcr?   s    r   c            
   @   sR   e Zd ZdZdZdZdZdZdZdZ	dZ
dd
d„Zdd„ Zddd„Zddd„ZdS )ÚCygwinCCompilerz? Handles the Cygwin port of the GNU C compiler to Windows.
    Úcygwinz.oz.az.dllzlib%s%sz%s%sz.exer   c             C   sè   t j| |||ƒ tƒ \}}| jd||f ƒ |tk	rB| jd| ƒ tƒ \| _| _| _	| j| j
d| j| j| j	f  ƒ | jdkr†d| _nd| _| jdkrœd}nd	}| jd
dddd| j|f d� | jdkrÜdg| _| jdƒ n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.z: gcc %s, ld %s, dllwrap %s
z2.10.90ÚgccÚdllwrapz2.13z-sharedz-mdll -staticzgcc -mcygwin -O -Wallzgcc -mcygwin -mdll -O -Wallzg++ -mcygwin -O -Wallzgcc -mcygwinz%s -mcygwin %s)ÚcompilerÚcompiler_soÚcompiler_cxxÚ
linker_exeÚ	linker_soz2.91.57Zmsvcrtz,Consider upgrading to a newer version of gcc)r   Ú__init__Úcheck_config_hZdebug_printÚCONFIG_H_OKÚwarnÚget_versionsÚgcc_versionÚ
ld_versionZdllwrap_versionÚcompiler_typeÚ
linker_dllÚset_executablesÚdll_librariesr   )ÚselfÚverboseÚdry_runÚforceZstatusZdetailsÚshared_optionr   r   r   r$   d   s<    




zCygwinCCompiler.__init__c             C   s¨   |dks|dkrVy| j dd|d|gƒ W q¤ tk
rR } zt|ƒ‚W Y dd}~X q¤X nNy"| j | j| |d|g | ƒ W n* tk
r¢ } zt|ƒ‚W Y dd}~X nX dS )z:Compiles the source by spawning GCC and windres if needed.z.rcz.resZ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   sR  t j |
p
g ƒ}
t j |pg ƒ}t j |p&g ƒ}|j| jƒ |dk	oP|| jksT| jdk�rtjj|d ƒ}tjjtjj	|ƒƒ\}}tjj
||d ƒ}tjj
|d| d ƒ}dtjj	|ƒ dg}x|D ]}|j|ƒ q¾W | jt||fd	| ƒ | jd
k�r|
jd|gƒ |
jd|gƒ n
|j|ƒ |	�s*|
jdƒ tj| |||||||d|	|
|||ƒ dS )zLink the objects.Nr   r   z.defÚlibz.az
LIBRARY %sZEXPORTSz
writing %sr   z--output-libz--defz-s)ÚcopyÚextendr.   Z
EXECUTABLEr,   ÚosÚpathÚdirnameÚsplitextÚbasenameÚjoinÚappendZexecuter   r   Úlink)r/   Ztarget_descZobjectsZoutput_filenameÚ
output_dirZ	librariesZlibrary_dirsZruntime_library_dirsZexport_symbolsÚdebugZextra_preargsr7   Z
build_tempZtarget_langZtemp_dirZdll_nameZdll_extensionZdef_fileZlib_fileÚcontentsZsymr   r   r   rD   ®   s:    	



zCygwinCCompiler.linkÚ c             C   s®   |dkrd}g }x˜|D ]�}t jjt jj|ƒƒ\}}|| jddg krTtd||f ƒ‚|rdt jj|ƒ}|dkrŒ|jt jj||| | j	 ƒƒ q|jt jj||| j	 ƒƒ qW |S )z#Adds supports for rc and res files.NrH   ú.rcú.resz"unknown file type '%s' (from '%s'))rJ   rI   )
r=   r>   r@   ÚnormcaseZsrc_extensionsr   rA   rC   rB   Úobj_extension)r/   Zsource_filenamesZ	strip_dirrE   Z	obj_namesZsrc_nameÚbaser6   r   r   r   Úobject_filenamesü   s     
z CygwinCCompiler.object_filenames)r   r   r   )
NNNNNr   NNNN)r   rH   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+   rL   Zstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZexe_extensionr$   r9   rD   rN   r   r   r   r   r   Y   s   
;   
Kr   c               @   s   e Zd ZdZdZddd„ZdS )ÚMingw32CCompilerz@ Handles the Mingw32 port of the GNU C compiler to Windows.
    Zmingw32r   c          	   C   sx   t j| |||ƒ | jdkr d}nd}| jdkr4d}nd}tƒ rFtdƒ‚| jdd	d
dd| j||f d� g | _t	ƒ | _d S )Nz2.13z-sharedz-mdll -staticz2.91.57z--entry _DllMain@12rH   z1Cygwin gcc cannot be used with --compiler=mingw32zgcc -O -Wallzgcc -mdll -O -Wallzg++ -O -Wallr   z%s %s %s)r   r    r!   r"   r#   )
r   r$   r*   r)   Úis_cygwingccr
   r-   r,   r.   r   )r/   r0   r1   r2   r3   Zentry_pointr   r   r   r$     s&    

zMingw32CCompiler.__init__N)r   r   r   )rO   rP   rQ   rR   r+   r$   r   r   r   r   rS     s   rS   Úokznot okZ	uncertainc              C   sš   ddl m}  dtjkrtdfS | jƒ }y@t|ƒ}z(d|jƒ krJtd| fS td| fS W d|j	ƒ  X W n. t
k
r” } ztd	||jf fS d}~X nX 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__GNUC__z'%s' mentions '__GNUC__'z '%s' does not mention '__GNUC__'Nzcouldn't read '%s': %s)Ú	distutilsrV   r   r   r&   Úget_config_h_filenameÚopenÚreadÚCONFIG_H_NOTOKÚcloseÚOSErrorÚCONFIG_H_UNCERTAINÚstrerror)rV   ÚfnÚconfig_hÚexcr   r   r   r%   H  s    
r%   s   (\d+\.\d+(\.\d+)*)c             C   sl   | j ƒ d }t|ƒdkrdS t| dtd�j}z|jƒ }W d|jƒ  X tj|ƒ}|dkrZdS t	|j
dƒjƒ ƒS )z¤Find the version of an executable by running `cmd` in the shell.

    If the command is not found, or the output does not match
    `RE_VERSION`, returns None.
    r   NT)ÚshellÚstdoutr   )Úsplitr   r   r   rd   rZ   r\   Ú
RE_VERSIONÚsearchr   ÚgroupÚdecode)ÚcmdÚ
executableÚoutÚ
out_stringÚresultr   r   r   Ú_find_exe_versionu  s    

ro   c              C   s   dddg} t dd„ | D ƒƒS )zg Try to find out the versions of gcc, ld and dllwrap.

    If not possible it returns None for it.
    zgcc -dumpversionzld -vzdllwrap --versionc             S   s   g | ]}t |ƒ‘qS r   )ro   )Ú.0rj   r   r   r   ú
<listcomp>�  s    z get_versions.<locals>.<listcomp>)Útuple)Zcommandsr   r   r   r(   Š  s    
r(   c              C   s   t ddgƒ} | jƒ jdƒS )z>Try to determine if the gcc that would be used is from cygwin.r   z-dumpmachines   cygwin)r   ÚstripÚendswith)rm   r   r   r   rT   ’  s    rT   )'rR   r=   r   r;   Ú
subprocessr   r   r   ÚreZdistutils.ccompilerr   r   Zdistutils.unixccompilerr   Zdistutils.file_utilr   Zdistutils.errorsr	   r
   r   r   rW   r   Zdistutils.versionr   Zdistutils.spawnr   r   r   rS   r&   r[   r^   r%   Úcompilerf   ro   r(   rT   r   r   r   r   Ú<module>   s0   ) ;1+
