o
    Ni5                     @   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   R/home/ubuntu/.local/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
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-tempNr1   )zpyrex-gen-pxiNr2   )zpyrex-directives=Nr3   )	pyrex-gdbNr5   )
r*   r,   r.   r0   r4   r6   r7   r8   r9   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   rL      s   zold_build_ext.__getattr__c                 C   s6   |d d dkrt | d|dd   |S || j|< d S rG   )setattr__dict__)r   rM   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pathseprA   r   r   r   r   rS      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 )rD   F   )rK   )r   extr   r   r   r      s    

z%old_build_ext.run.<locals>.<listcomp>)rD   
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 rR   )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?   rE   r=   zc++rC   rD   FrF   NrA   z.cppz.crB   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>   rK   r?   rE   r=   languagelowerrC   rD   rF   listr@   appendAttributeErrorinclude_dirsdictrA   hasattrupdateinplacerB   rV   pathr    
build_temprM   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_directivesrE   rn   rC   rD   rF   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<   rL   rQ   rS   r\   r]   r^   r   r   r   r   r)   R   sJ    '	r)   )__doc____revision__r   rV   distutils.errorsr   distutils.dep_utilr   r   	distutilsr   distutils.commandr   r;   r   extension_name_reshow_compilersr   r[   r)   r   r   r   r   <module>   s    