o
    jR                     @   sp   d dl Z d dlZd dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ dd Zdd ZdS )	    N)
MemoryViewCodeOptionsPipelineErrorsMainSymtab)EncodedString)FileSourceDescriptorc                    s   t |  fdd}dd }tj}dd }|d|| gt j| dd	d
|t | t j| ddt | t jt 	 |||S )Nc                    s    fdd}|S )Nc                    sP   | }|j tj |j t  |j t   jt	
  |S N)scopeuse_utility_coder   Zget_view_utility_codeZshared_utility_qualified_nameZ_get_memviewslice_declare_codeZ_get_typeinfo_to_format_codeZinclude_directoriesappendr   get_utility_dir)Zcompsrctree)contextoptionsparse Z/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/Cython/Build/SharedModule.pygenerate_tree   s   
zTcreate_shared_library_pipeline.<locals>.generate_tree_factory.<locals>.generate_treer   )r   r   r   r   )r   r   generate_tree_factory   s   z=create_shared_library_pipeline.<locals>.generate_tree_factoryc           	      S   s   t j}|d}tt  D ]:}|dsqt |D ],}|| }r+|d }s,q|	| }s4q|
 \}}|dkrH| j||| qq| S )N/.cnameZexport)r   UtilityCodeZget_special_comment_matcheroslistdirr   endswithZread_utilities_hookgroupZmatch_section_titlegroupsr   r   Zload_cached)	Zmodule_noder   Zmatch_specialZc_utility_filelinemr   Zsection_titleZsection_typer   r   r   generate_c_utilities   s    

z<create_shared_library_pipeline.<locals>.generate_c_utilitiesc                    s    fdd}|S )Nc                    s
    t _| S r   )r   cimport_from_pyx)noder%   r   r   inner2   s   zKcreate_shared_library_pipeline.<locals>.set_cimport_from_pyx.<locals>.innerr   )r%   r(   r   r'   r   set_cimport_from_pyx1   s   z<create_shared_library_pipeline.<locals>.set_cimport_from_pyxTpyxr   )Zexclude_classesF)Zinternalise_c_class_entries)
r   Zparse_stage_factoryr   r%   Zcreate_pipelineZinject_pxd_code_stage_factoryZ!inject_utility_code_stage_factoryZ%inject_utility_pxd_code_stage_factoryZabort_on_errorsZgenerate_pyx_code_stage_factory)r   r   r   resultr   r$   Zorig_cimport_from_pyxr)   r   r   r   create_shared_library_pipeline   s0   
	

r,   c              	   C   sF  t   t d  | j}tjtj|d }tj	
| }tjdd |dd}t l}tj|| d}tj|| d}t|d W d    n1 sPw   Y  t|}t|t|t }	t|	| }
t||| |
}t||	\}}|d u rt|| W d    ||fS W d    ||fS 1 sw   Y  ||fS )Nr   r   F)parent_moduler   
is_packagez.pyxr   w)r   Zinit_threadZopen_listing_fileZshared_c_file_pathr   pathsplitextbasenamer   ContextZfrom_optionsr   ZModuleScopetempfileTemporaryDirectoryjoinopenr
   ZCompilationSourcer	   getcwdZcreate_default_resultobjr,   r   Zrun_pipelineshutilcopy)r   Zdest_c_filemodule_namer   r   Z
tmpdirnameZpyx_fileZc_fileZsource_descZcomp_srcr+   ZpipelineerrZenddatar   r   r   generate_shared_moduleF   s4   



r=   )r   rer9   r4   ZCython.Compilerr   r   r   r   r   r   r   ZCython.Compiler.StringEncodingr	   ZCython.Compiler.Scanningr
   r,   r=   r   r   r   r   <module>   s    $9