
    AeC5                     l   d Z dZddl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 ddlZ	 dd	lmZ d
 Z ed      s" ed      s ed      s ej,                  d       ej.                  Zej0                  Z G d de      Z e       Z G d dej                        Zy# e$ r eZY vw xY w)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                     	 t        j                  t        j                         d      D ])  }| |d   j                  t        j
                  d      v s) y 	 y# t        $ r Y yw xY w)Nr      /TF)inspectgetouterframescurrentframereplaceossep	Exception)pathframes     >lib/python3.12/site-packages/Cython/Distutils/old_build_ext.py_check_stackr      sh    	''(<(<(>B 	q!!"&&#.	.
 
 
 			s   AA A A 	A$#A$zsetuptools/extensions.pyzpyximport/pyxbuild.pyzCython/Distutils/build_ext.pyzWCython.Distutils.old_build_ext does not properly handle dependencies and is deprecated.c                       e Zd Zd Zd Zd Zy)Optimizationc                     d| _         t        j                  | j                    | _        t        j                         | _        y )N)OPTCFLAGSCPPFLAGSEXTRA_CFLAGS
BASECFLAGS	PY_CFLAGS)flagsr   get_config_varsstateconfig_varsselfs    r   __init__zOptimization.__init__2   s4    

 ..

;
$446    c                     d}t        | j                  | j                        D ]H  \  }}|	|j                         D cg c]	  }||vs| }}dj	                  |      | j
                  |<   J yc c}w )z.disable optimization for the C or C++ compiler)z-O1z-O2z-O3N )zipr!   r#   splitjoinr$   )r&   
badoptionsflagoptionoptLs         r   disable_optimizationz!Optimization.disable_optimization?   sj    *


DJJ7 	5LD&!$*LLNLSc6KSLL),!  &	5Ls   	A/A/c                 x    t        | j                  | j                        D ]  \  }}|	|| j                  |<    y)zrestore the original stateN)r+   r!   r#   r$   )r&   r/   r0   s      r   restore_statezOptimization.restore_stateH   s:    

DJJ7 	0LD&!)/  &	0r(   N)__name__
__module____qualname__r'   r3   r5    r(   r   r   r   1   s    
750r(   r   c                   ~   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j                  ddddddez   fdd	d
ddddddddez   fddddg       ej                  g d       d Zd Zd Zd Zd Zd Zd Zy)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-directivesNrA   zpyrex-include-dirs=)pyrex-c-in-tempNrC   )zpyrex-gen-pxiNrD   )zpyrex-directives=NrE   )	pyrex-gdbNrG   )
r<   r>   r@   rB   rF   rH   rI   rJ   rK   rL   c                     t         j                  j                  |        d| _        d| _        d| _        d | _        d | _        d| _        d| _	        d| _
        d| _        d | _        y )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%   s    r   rO   z old_build_ext.initialize_options   se    //5%&"&'##' !% !!"'+$r(   c                 v    |d d dk(  rt        | d|dd  z         S t        j                  j                  | |      S N   pyrex_cython_)getattrrN   r   __getattr__)r&   names     r   r`   zold_build_ext.__getattr__   sA    8x4T!"X!566''33D$??r(   c                 X    |d d dk(  rt        | d|dd  z   |      S || j                  |<   y r[   )setattr__dict__)r&   ra   values      r   __setattr__zold_build_ext.__setattr__   s:    8x4T!"X!5u== #(DMM$r(   c                 "   t         j                  j                  |        | j                  g | _        nHt	        | j                  t
              r.| j                  j                  t        j                        | _        | j                  i | _	        y y N)
rN   r   finalize_optionsrS   
isinstancer	   r,   r   pathseprT   r%   s    r   ri   zold_build_ext.finalize_options   ss    --d3##+')D$00*=((..rzz: $!!)%'D" *r(   c                     | j                   s'| j                  D cg c]  }t        |dd      rd c}rt        j	                          t
        j                  j                  |        y c c}w )NrW   Fr   )rW   
extensionsr_   optimizationr3   rN   r   runr&   exts     r   ro   zold_build_ext.run   sW    
 ??DOO KS(/\5(I  ! K--/  &	Ks   A(c                     | j                  | j                         | j                  D ]#  }| j                  |j                  |      |_        % t        j
                  j                  |        y rh   )check_extensions_listrm   cython_sourcessourcesrN   r   build_extensionsrp   s     r   rv   zold_build_ext.build_extensions   sW    ""4??3?? 	@C--ckk3?CK	@ 	--d3r(   c                 	   	 ddl m}m}m} ddlm} g }g }	i }
| j                  xs t        |dd      }| j                  xs t        |dd      }| j                  xs t        |d	d      }| j                  xs: t        |d
d      xs+ |j                   xr |j                   j#                         dk(  }| j$                  xs t        |dd      }| j&                  xs t        |dd      }| j(                  xs t        |dd      }| j*                  }	 |j*                  D ]  }||vs|j-                  |        	 t1        |j2                        |_        |j2                  D ]  }||vs|j-                  |        | j4                  }t7        |d      r|j9                  |j4                         |rd}nd}| j:                  s| j<                  st        |dd      rnt>        j@                  jC                  | jD                  d      }|jF                  jI                  d      dd D ]"  }t>        j@                  jC                  ||      }$ nd}d}|D ]  }t>        j@                  jK                  t>        j@                  jM                  |            \  }}|dk(  rd}|dk(  ro|xs t>        j@                  jO                  |      }|j-                  t>        j@                  jC                  |||z                |	j-                  |       |d   |
|<   |dk(  s|dk(  r|tQ        ||      s|}|j-                  |        |	s|S |jF                  }|	D ]?  }|
|   }|gt1        |jR                  xs d      z   }|dd j#                         dk(  r1t>        j@                  jU                  |dd dz         r||dd dz   gz  }| jV                  xs tY        ||d       } | s|tQ        ||      } | rt[        j\                  d!||       | j_                  t>        j@                  jO                  |             | j:                  rt>        j`                  }n| jb                  } ||||||||| ||||"      }! |||!|#      }"*t[        j\                  d$|       B |S # t        $ r1 t        j                         d   }t        d|z         t        d      w xY w# t.        $ r Y w xY w)%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   )CompilationOptionsdefault_optionscompile)
PyrexErrorr   zfailed to import Cython: %sz&Cython does not appear to be installedrQ   rR   rX   rP   zc++rV   rW   FrY   NrT   z.cppz.crU   pyrex.z.pyz.pyxz.pxiz.pxdr9   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))2Cython.Compiler.Mainrx   ry   rz   Cython.Compiler.Errorsr{   ImportErrorsysexc_infoprintr   rQ   r_   rR   rX   rP   languagelowerrV   rW   rY   rS   appendAttributeErrorlistinclude_dirsrT   hasattrupdateinplacerU   r   r   r-   
build_tempra   r,   splitextbasenamedirnamer   dependsisfileforcer   r   infomkpathcurdir	build_lib)#r&   ru   	extensionrx   cython_default_optionscython_compiler{   enew_sourcesrt   cython_targetscreate_listingline_directivesrX   r   rV   rW   rY   includesi
directives
target_ext
target_dirpackage_namenewest_dependencysourcebaserq   r   module_nametargetr   rebuildr   results#                                      r   rt   zold_build_ext.cython_sources   s   		S1 1 : ( 33 ;I6: 	55 <I7; 	 22 7I2A6 	!! MWY%J M##K	(:(:(@(@(Be(K 	,,W	CSUV0W__O	<(O
"&">"> #@I8$? 	  ++	22 'H}OOA&' "&i&<&<!=	'' 	#A="	# ++
912i99: JJ
 ||!6!69&8!<doow?J ) 4 4S 9#2 > DWW\\*lC
D J  	+F''**277+;+;F+CDKT3e|f}'B277??6+B
""277<<
D:<M#NO%%f-)4Rv&#-$, ):;(.%""6*	+" nn$ 	PF#F+Fhi&7&7&=2!>>Gbc{  "F*rww~~fSbk%>O/PF3BK-..jjIK$IG0< 16:-vv>BGGOOF34<<!#J!%J,-C'5#+*4"(!$3.?*?#1!+ *'>@ (9DF FO=	P@ [  	Sq!A/!34()QRR	Sd  		s#   R S #S :S	SS)r6   r7   r8   descriptionrN   r   sep_byuser_optionsboolean_optionshelp_optionsextendrO   r`   rf   ri   ro   rv   rt   r9   r(   r   r;   r;   R   s   WK!!((F''44Q7L **::1=O''44Q7L 	&	+	(		+f	4	6	4	:	,	1	/	&	+	(		+f	4	6	4	:	,	1G%
 %N   ,@((	'4Zr(   r;   )__doc____revision__r   r   r   distutils.errorsr   distutils.dep_utilr   r   	distutilsr   distutils.commandr   rN   r   warnings__builtin__r	   r   strr   warnextension_name_reshow_compilersobjectr   rn   r;   r9   r(   r   <module>r      s      
 	 3 1  5  &
 	/00189HMM	
 00 **06 0< ~MJ(( Mu  Js   B) )B32B3