o
    f6                     @   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 zdd	lmZ W n ey?   eZY nw 	 ejZejZG d
d de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)	sysconfig)
basestringc                   @   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   Z/var/www/html/mig_web/myenv/lib/python3.10/site-packages/Cython/Distutils/old_build_ext.py__init__8   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
badoptionsr   r   
<listcomp>K   s    z5Optimization.disable_optimization.<locals>.<listcomp> )zipr   r   splitjoinr   )r   flagoptionLr   r   r   disable_optimizationE   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_stateN   s
   
zOptimization.restore_stateN)__name__
__module____qualname__r   r%   r&   r   r   r   r   r	   7   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-directivesNr0   zpyrex-include-dirs=)pyrex-c-in-tempNr2   )zpyrex-gen-pxiNr3   )zpyrex-directives=Nr4   )	pyrex-gdbNr6   )
r+   r-   r/   r1   r5   r7   r8   r9   r:   r;   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   pyrex_cython_)getattrr<   r   __getattr__)r   namer   r   r   rM      s   zold_build_ext.__getattr__c                 C   s6   |d d dkrt | d|dd   |S || j|< d S rH   )setattr__dict__)r   rN   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_optionsrA   
isinstancer   r    ospathseprB   r   r   r   r   rT      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 )rE   F   )rL   )r   extr   r   r   r      s    

z%old_build_ext.run.<locals>.<listcomp>)rE   
extensionsoptimizationr%   r<   r   runr   r   r   r   r\      s   zold_build_ext.runc                 C   s.   t j| | | jD ]
}| |j||_q
d S rS   )r<   r   check_extensions_listrZ   cython_sourcessources)r   rZ   rY   r   r   r   r]      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@   rF   r>   zc++rD   rE   FrG   NrB   z.cppz.crC   pyrex.z.pyz.pyxz.pxiz.pxd)CompilationOptionsdefault_optionscompile)
PyrexErrorrX   zfailed to import Cython: %sz&Cython does not appear to be installedr   pxdr   zcythoning %s to %s)use_listing_fileinclude_pathcompiler_directivesoutput_filecplusemit_linenumsc_line_in_tracebackgenerate_pxi
output_dir	gdb_debugcompile_time_env)optionsfull_module_namez+skipping '%s' Cython extension (up-to-date))3r?   rL   r@   rF   r>   languagelowerrD   rE   rG   listrA   appendAttributeErrorinclude_dirsdictrB   hasattrupdateinplacerC   rV   pathr!   
build_temprN   r    splitextbasenamedirnamer   Cython.Compiler.Mainrc   rd   re   Cython.Compiler.Errorsrf   ImportErrorsysexc_infoprintr   dependsisfileforcer   r   infomkpathcurdir	build_lib)#r   r_   	extensionnew_sourcesr^   cython_targetscreate_listingline_directivesrF   rn   rD   rE   rG   includesi
directives
target_ext
target_dirpackage_namenewest_dependencysourcebaserY   rr   rc   cython_default_optionscython_compilerf   emodule_nametargetr   rebuildru   resultr   r   r   r^      s   














0

zold_build_ext.cython_sources)r'   r(   r)   descriptionr<   r   sep_byuser_optionsboolean_optionshelp_optionsextendr=   rM   rR   rT   r\   r]   r^   r   r   r   r   r*   X   sJ    '	r*   )__doc____revision__r   rV   distutils.errorsr   distutils.dep_utilr   r   	distutilsr   distutils.commandr   r<   r   __builtin__r   r   strextension_name_reshow_compilersobjectr	   r[   r*   r   r   r   r   <module>   s(    