o
    j5                     @   s   d Z dZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddl	mZ 	 ejZejZG d	d
 d
Ze ZG dd dejZdS )zCython.Distutils.old_build_ext

Implements a version of the Distutils 'build_ext' command, for
building Cython extension modules.

Note that this module is deprecated.  Use cythonize() instead.
z$Id:$    N)DistutilsPlatformError)newernewer_group)log)	build_ext)	sysconfigc                   @   s$   e Zd Zdd Zdd Zdd ZdS )Optimizationc                 C   s"   d| _ tj| j  | _t | _d S )N)OPTCFLAGSCPPFLAGSEXTRA_CFLAGS
BASECFLAGS	PY_CFLAGS)flagsr   get_config_varsstateconfig_varsself r   _/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py__init__2   s   zOptimization.__init__c                    sN   d t | j| jD ]\}}|dur$ fdd| D }d|| j|< q	dS )z.disable optimization for the C or C++ compiler)z-O1z-O2z-O3Nc                    s   g | ]}| vr|qS r   r   ).0optZ
badoptionsr   r   
<listcomp>E   s    z5Optimization.disable_optimization.<locals>.<listcomp> )zipr   r   splitjoinr   )r   flagoptionLr   r   r   disable_optimization?   s   z!Optimization.disable_optimizationc                 C   s.   t | j| jD ]\}}|dur|| j|< qdS )zrestore the original stateN)r   r   r   r   )r   r    r!   r   r   r   restore_stateH   s
   
zOptimization.restore_stateN)__name__
__module____qualname__r   r#   r$   r   r   r   r   r   1   s    	r   c                   @   s   e Zd ZdZejjZejjdd Zejjdd Zejj	dd Z	e
dddddde fdd	d
dddddddde fddddg e
g d dd Zdd Zdd Zdd Zdd Zd d! Zd"d# ZdS )$old_build_extzCbuild C/C++ and Cython extensions (compile/link to build directory)N)cython-cplusNgenerate C++ source files)cython-create-listingNwrite errors to a listing file)cython-line-directivesNemit source line directiveszcython-include-dirs=z path to the Cython include files)cython-c-in-tempN'put generated C files in temp directory)zcython-gen-pxiN*generate .pxi file for public declarations)zcython-directives=Ncompiler directive overrides)
cython-gdbN$generate debug information for cygdb)zcython-compile-time-envNzcython compile time environment)pyrex-cplusNr*   )pyrex-create-listingNr,   )pyrex-line-directivesNr.   zpyrex-include-dirs=)pyrex-c-in-tempNr0   )zpyrex-gen-pxiNr1   )zpyrex-directives=Nr2   )	pyrex-gdbNr4   )
r)   r+   r-   r/   r3   r5   r6   r7   r8   r9   c                 C   sL   t j|  d| _d| _d| _d | _d | _d| _d| _	d| _
d| _d | _d S )Nr   F)
_build_extr   initialize_optionscython_cpluscython_create_listingcython_line_directivescython_include_dirscython_directivescython_c_in_tempcython_gen_pxi
cython_gdbno_c_in_tracebackcython_compile_time_envr   r   r   r   r;      s   
z old_build_ext.initialize_optionsc                 C   s4   |d d dkrt | d|dd   S tj| |S N   Zpyrex_Zcython_)getattrr:   r   __getattr__)r   namer   r   r   rI      s   zold_build_ext.__getattr__c                 C   s6   |d d dkrt | d|dd   |S || j|< d S rF   )setattr__dict__)r   rJ   valuer   r   r   __setattr__   s   zold_build_ext.__setattr__c                 C   sR   t j|  | jd u rg | _nt| jtr| jtj| _| j	d u r'i | _	d S d S N)
r:   r   finalize_optionsr?   
isinstancestrr   ospathsepr@   r   r   r   r   rP      s   


zold_build_ext.finalize_optionsc                 C   s.   | j sdd | jD rt  tj|  d S )Nc                 S   s   g | ]
}t |d drdqS )rC   F   )rH   )r   extr   r   r   r      s    

z%old_build_ext.run.<locals>.<listcomp>)rC   
extensionsoptimizationr#   r:   r   runr   r   r   r   rY      s   zold_build_ext.runc                 C   s.   t j| | | jD ]
}| |j||_q
d S rO   )r:   r   check_extensions_listrW   cython_sourcessources)r   rW   rV   r   r   r   rZ      s   
z#old_build_ext.check_extensions_listc           #      C   s  g }g }i }| j pt|dd}| jpt|dd}| jp t|dd}| jp3t|ddp3|jo3|j dk}	| jp<t|dd}
| jpEt|dd	}| j	pNt|d
d}t
| j}z|jD ]}||vrc|| qXW n	 tyn   Y nw t
|j|_|jD ]}||vr|| qxt| j}t|dr||j |	rd}nd}| js| jst|ddrtj| jd}|jddd D ]	}tj||}qnd}d}|D ]V}tjtj|\}}|dkrd}|dkr|ptj|}|tj|||  || |d ||< q|dks|dkr|du st||r|}q|| q|s&|S zddlm }m!}m"} ddl#m$} W n t%yP   t&' d }t(d|  t)dw |j}|D ]}|| }|gt
|j*pdd }|dd  dkrtj+|dd d r||dd d g7 }| j,pt-||d } | s|durt||} | rt./d!|| | 0tj| | jrtj1}n| j2}|||||||	|| |
|||d"}!|||!|d#}"qVt./d$| qV|S )%a  
        Walk the list of source files in 'sources', looking for Cython
        source files (.pyx and .py).  Run Cython on all that are
        found, and return a modified 'sources' list with Cython source
        files replaced by the generated C (or C++) files.
        r=   r   r>   rD   r<   zc++rB   rC   FrE   Nr@   z.cppz.crA   pyrex.z.pyz.pyxz.pxiz.pxd)CompilationOptionsdefault_optionscompile)
PyrexErrorrU   zfailed to import Cython: %sz&Cython does not appear to be installedr   Zpxdr   zcythoning %s to %s)Zuse_listing_fileZinclude_pathZcompiler_directivesoutput_filecplusZemit_linenumsZc_line_in_tracebackZgenerate_pxi
output_dirZ	gdb_debugZcompile_time_env)optionsZfull_module_namez+skipping '%s' Cython extension (up-to-date))3r=   rH   r>   rD   r<   languagelowerrB   rC   rE   listr?   appendAttributeErrorZinclude_dirsdictr@   hasattrupdateZinplacerA   rS   pathr   Z
build_temprJ   r   splitextbasenamedirnamer   ZCython.Compiler.Mainr`   ra   rb   ZCython.Compiler.Errorsrc   ImportErrorsysexc_infoprintr   dependsisfileforcer   r   infoZmkpathcurdirZ	build_lib)#r   r\   	extensionZnew_sourcesr[   Zcython_targetsZcreate_listingZline_directivesrD   rg   rB   rC   rE   ZincludesiZ
directivesZ
target_ext
target_dirpackage_nameZnewest_dependencysourcebaserV   rh   r`   Zcython_default_optionsZcython_compilerc   emodule_nametargetrz   Zrebuildri   resultr   r   r   r[      s   














0

zold_build_ext.cython_sources)r%   r&   r'   descriptionr:   r   Zsep_byZuser_optionsZboolean_optionsZhelp_optionsextendr;   rI   rN   rP   rY   rZ   r[   r   r   r   r   r(   R   sJ    '	r(   )__doc__Z__revision__rw   rS   Zdistutils.errorsr   Zdistutils.dep_utilr   r   	distutilsr   Zdistutils.commandr   r:   r   Zextension_name_reZshow_compilersr   rX   r(   r   r   r   r   <module>   s    