o
    j                     @   s  d Z dZddlZddlZejdk rddlmZ G dd dZnddlZd3d	d
Ze	dZ
edZedZedZedZeekrDdZnejedd d ZedejddZedd ejdd ZedejdeZedZedZedZedZdd Zdd Zdd Zd4dd Zd!d" Zd#d$ Zd5d&d'Z d5d(d)Z!d6d+d,Z"d-d. Z#d/d0 Z$e%d1kre$ej&d2d  dS dS )7z
Compile a Python script into an executable that embeds CPython.
Requires CPython to be built as a shared library ('libpythonX.Y').

Basic usage:

    python -m Cython.Build.BuildExecutable [ARGS] somefile.py
T    N)   	   )	sysconfigc                   @   s"   e Zd Zedd ZeejZdS )r   c                 C   s   | dksJ t  S )Ninclude)
_sysconfigZget_python_inc)name r   ]/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/Cython/Build/BuildExecutable.pyget_path   s   zsysconfig.get_pathN)__name__
__module____qualname__staticmethodr
   r   get_config_varr   r   r   r	   r      s    
r    c                 C   s   t | p|S N)r   r   )r   defaultr   r   r	   r      s   r   r   LIBDIRLIBPLLIBRARY	LDLIBRARYr   CCCFLAGS LINKCCLINKFORSHAREDLIBSSYSLIBSEXEc                 G   s(   t r|r| | } tj| d  d S d S )N
)DEBUGsysstderrwrite)msgargsr   r   r	   _debug6   s
   r&   c                   C   s|   t dt t dt t dt t dt t dt t dt t dt t dt t d	t	 t d
t
 t dt t dt d S )Nz
INCDIR: %szLIBDIR1: %szLIBDIR2: %sz	PYLIB: %szPYLIB_DYN: %szCC: %sz
CFLAGS: %sz
LINKCC: %szLINKFORSHARED: %szLIBS: %szSYSLIBS: %szEXE_EXT: %s)r&   INCDIRLIBDIR1LIBDIR2PYLIB	PYLIB_DYNr   r   r   r   r   r   EXE_EXTr   r   r   r	   dump_config=   s   










r-   c                 C   sr   g }d }t | D ]'\}}|dr|| n|dv r!|| n|}| |d d  }  n|}qtd||| fS )N-)z-Xz--directive   zno input file provided)	enumerate
startswithappend
ValueError)r%   cy_argsZlast_argiarg
input_filer   r   r	   _parse_argsL   s   

r8   c                 C   sR   |rd | } t|  ntd |  dd l}|j| |d}|r't| d S d S )Nr   r   shell)joinr&   
subprocesscallr!   exit)cmdr:   r<   
returncoder   r   r	   runcmd_   s   

rA   c                 C   s\   t td| t | d dt dt gtrdt ptjtt	g t
  t  t   d S )N-o.oz-Lz-l)rA   r   r,   r(   r)   r+   ospathr;   r*   r   splitr   r   basenamer   r   r	   clinkm   s    
rI   c                 C   s,   t tdd| d | d dt gt   d S )Nz-crB   rC   z.cz-I)rA   r   r'   r   rF   rG   r   r   r	   ccompiles   s   ,rJ   r   c                 C   sh   ddl m}m}m} |t|pdd| g \}}td|j|  |||}|j	dkr2t
d d S d S )N   )VersionCmdLineMainr   z--embedzUsing Cython %s to compile %sr   r/   )ZCompilerrL   rM   rN   Zparse_command_linelistr&   versioncompileZ
num_errorsr!   r>   )r7   optionsrL   rM   rN   sourcesresultr   r   r	   	cycompilew   s   
rU   c                 C   s"   t tj| gt| dd d S )NFr9   )rA   rD   rE   abspathrO   )program_namer%   r   r   r	   	exec_file   s   "rX   Fc                 C   s   t j| d }|t }|st j|t j| krtd|s?t j|r?t j| r?t j| t j|kr?td| |S t	| | t
| t| |S )zi
    Build an executable program from a Cython module.

    Returns the name of the executable file.
    r   z?Input and output file names are the same, refusing to overwritez'File is up to date, not regenerating %s)rD   rE   splitextr,   rV   r3   existsgetmtimer&   rU   rJ   rI   )r7   Zcompiler_argsforcerH   Zexe_filer   r   r	   build   s   

r]   c                 C   s   t | \}} t||  dS )z
    Build an executable program from a Cython module and run it.

    Arguments after the module name will be passed verbatimly to the program.
    N)_buildrX   )r%   rW   r   r   r	   build_and_run   s   r_   c                 C   s    t | \}}} t||}|| fS r   )r8   r]   )r%   r7   r4   rW   r   r   r	   r^      s   
r^   __main__r/   )r   )T)r   )r   F)'__doc__r    r!   rD   version_info	distutilsr   r   r   r
   r'   r(   r)   r*   r+   rE   rY   environgetr   r   r   r   r   r   r,   r&   r-   r8   rA   rI   rJ   rU   rX   r]   r_   r^   r   argvr   r   r   r	   <module>   sL    








	

