
    -Ph/                     <   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Z e ej                    dz            Zn# e$ r dZd ZY nw xY w G d	 d
          Zd ZdefdZdefdZd Zd ZddZd Zd Zd ZddZedk    r e             dS dS )    N)defaultdict   )	cythonizeextended_iglob   )is_package_dir)Optionsg      ?c                   &    e Zd Zd Zd Zd Zd ZdS )	_FakePoolc                 ,    t          ||          D ]}d S N)map)selffuncargs_s       V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Build/Cythonize.py	map_asyncz_FakePool.map_async   s&    T4 	 	A	 	    c                     d S r    r   s    r   closez_FakePool.close       r   c                     d S r   r   r   s    r   	terminatez_FakePool.terminate   r   r   c                     d S r   r   r   s    r   joinz_FakePool.join   r   r   N)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      sP                  r   r   c                     t           j                            |           \  }}t          |          r8t           j                            |          \  }}|d|}t          |          8||fS )N/)ospathsplitr   )r%   base_dirpackage_pathparents       r   find_package_baser*   !   sq    W]]400Hl

"
" 87==22&"(&&,,7 
"
" 8 \!!r   returnc                     t          t          j        j        t	          |                     }t          ||          }t          t          |                                          |j	                   d S r   )
r   r$   r%   abspathr   _cython_compile_files_buildlistitemsparallel)path_patternoptions	all_pathsext_modules_by_basedirs       r   cython_compiler7   )   s[    BGO^L%A%ABBI29gFF
4&,,..//1ABBBBBr   c                    t          t                    }| D ]<}|j        r~|}t          j                            |          rt          |          rMt          j                            |          }t          j                            |          >t          |          Mnd }t          j                            |          r#t          j                            |dd          g}n|g}t          |f|j
        |j        |j        |j        |j        |j        |j        |j        |j        d	|j        }|r"|j        r||                             |           >t-          |          S )Nz**z
*.{py,pyx})	nthreadsexclude_failuresexcludecompiler_directivescompile_time_envforcequietdepfilelanguage)r   r0   build_inplacer$   r%   isdirr   dirnamer   r   r2   
keep_goingexcludes
directivesr=   r>   r?   r@   rA   r4   buildextenddict)r5   r4   ext_modules_to_buildr%   r'   pathsext_moduless          r   r.   r.   /   sh   &t,, ? ?  	HgmmH-- 51I1I 57??844 gmmH-- 51I1I 5 H7== 	W\\$l;;<EE FE%$/$ ' 2$5--O%  o   	?7= 	? *11+>>>$%%%r   c                    t          d | D                       }|sd S |dk    s|dk     rt          | d                    d S 	 t          j        |          }n# t          $ r t                      }Y nw xY w	 |                    t          d | D                        |                                 |                                 d S #  |	                                  xY w)Nc              3   :   K   | ]\  }}t          |          V  d S r   )len).0r   moduless      r   	<genexpr>z_build.<locals>.<genexpr>U   s,      >>JAw3w<<>>>>>>r   r   r   r   c                 (    g | ]\  }}|D ]}||gfS r   r   )rQ   r'   rR   exts       r   
<listcomp>z_build.<locals>.<listcomp>a   sM     'W 'W 'W"3(Gg'W 'WGJXu'W 'W 'W 'Wr   )
sumrun_distutilsmultiprocessingPoolOSErrorr   r   r   r   r   )rM   r2   modcountpools       r   r/   r/   T   s   >>+>>>>>H 1}}1k!n%%%#H--   {{} 'W 'W7B'W 'W 'W 	X 	X 	X 	

		s   A A21A26%C Cc                    	 ddl m} n5# t          $ r( 	 ddlm} n# t          $ r t          d          w xY wY nw xY w| \  }}ddg}t	          j                    }d }	 |r@t	          j        |           t          j        |          }|	                    d|g            |d||	           |rKt	          j        |           |r7t          j
                            |          rt          j        |           d S d S d S d S # |rJt	          j        |           |r5t          j
                            |          rt          j        |           w w w w xY w)
Nr   )setupzL'distutils' is not available. Please install 'setuptools' for binary builds.	build_ext-i)dirz--build-tempzsetup.py)script_namescript_argsrM   )distutils.corer_   ImportError
setuptoolsr$   getcwdchdirtempfilemkdtemprI   r%   rC   shutilrmtree)r   r_   r'   rM   rd   cwdtemp_dirs          r   rX   rX   k   s   n((((((( n n n	n((((((( 	n 	n 	nlmmm	n )(n !Hk%K
)++CH( 	;HX'H555H9:::"##	
 	
 	
 	
  	(HSMMM (BGMM(33 (h'''''	( 	(( ( ( (  	(HSMMM (BGMM(33 (h''''	(( (s*   	 
;;5;;AD   AEc                 *   ddl m}  || |||d          \  }}ddddd	}d
 t          |                                          D             fd}|                                 t          |          dz  dk    sJ |d         |t          |          dz           |d         }}
}	t          | dt          |           d ||	           d ||
           d           ||	dz  k    r*t          d ||           d ||	           d           d S d S )Nr   )cymeit	   )repeatg&.>gư>gMbP?g      ?)nsecusecmsecsecc                     g | ]	\  }}||f
S r   r   )rQ   unitscales      r   rV   zbenchmark.<locals>.<listcomp>   s     GGGeudmGGGr   c                 X    D ]\  }}| |k    r nt          d          | |z  dd| S )Nz"Timing is below nanoseconds: {t:f}z.3f )RuntimeError)trz   ry   scaless      r   format_timezbenchmark.<locals>.format_time   sW    ! 	E 	EKE4Ezz  CDDDe))))4)))r   r   r   z loops, best of z: z per loop (median: )   z3The timings are likely unreliable. The worst time (z6) was more than four times slower than the best time (z).)Cython.Build.Inlinerq   reversedr1   sortrP   print)code
setup_codeimport_modulerG   rq   timingsnumberunitsr   fastestmedianslowestr   s               @r   	benchmarkr      s   ******fT:}jQRSSSOGV 4cBBEGGx/F/FGGGF* * * * * LLNNNw<<!q    &qz73w<<13D+Ewr{WVG	V
t
tS\\
t
t[[5I5I
t
t^i^ijp^q^q
t
t
tuuu1C*{733C C*5+g*>*>C C C	D 	D 	D 	D 	D r   c                  @   ddl m} m} ddlm}m}m}  | |d          }|                    ddd	d
i t          |d           |                    ddd	di t          |d           |                    ddddi t          |d           |                    ddddd d           |                    ddddd           |                    ddddd            |                    d!d"d#dd$d d%           |                    d&d'dd(d)d*+           |                    d,dd-d)d.+           |                    d/d0d1d2d3g d45           |                    d6d7d8d9d d:;           |                    d<d=d>d9d d?;           |                    d@dAdBt          d dCD           |                    dEdFdBt          d dGD           |                    dHdIdJdKt          t          dLt          pdM dND           |                    dOdPdQd9d dR;           |                    dSdTdUd9d dV;           |                    dWdXd9d dY;           |                    dZd[d\d9d d];           |                    d^d_d9d d`;           |                    dadbd9dcd           |                    dedfg           |S )hNr   )ArgumentParserRawDescriptionHelpFormatterr   )ParseDirectivesActionParseOptionsActionParseCompileTimeEnvActiona  Environment variables:
  CYTHON_FORCE_REGEN: if set to 1, forces cythonize to regenerate the output files regardless
        of modification times and changes.
  CYTHON_CACHE_DIR: the base directory containing Cython's caches.
  Environment variables accepted by setuptools are supported to configure the C compiler and build:
  https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#compiler-and-linker-options)formatter_classepilogz-Xz--directivezNAME=VALUE,...rG   zset a compiler directive)metavardestdefaulttypeactionhelpz-Ez--compile-time-envr=   z'set a compile time environment variablez-sz--optionz
NAME=VALUEr4   zset a cythonize optionz-2language_levelstore_constz#use Python 2 syntax mode by default)r   r   constr   r   z-3   z#use Python 3 syntax mode by default)r   r   r   r   z--3strz=use Python 3 syntax mode by default (deprecated alias for -3)z-+z--cplusrA   zc++zCompile as C++ rather than Cz-az
--annotater   annotatez/Produce a colorized HTML version of the source.)r   r   r   r   z--annotate-fullcfullczZProduce a colorized HTML version of the source which includes entire generated C/C++-code.z-xz	--excludePATTERNrF   appendz2exclude certain file patterns from the compilation)r   r   r   r   r   z-bz--buildrH   
store_truez2build extension modules using distutils/setuptools)r   r   r   r   ra   z	--inplacerB   zHbuild extension modules in place using distutils/setuptools (implies -b)z--timeitr   
CODESTRINGzabuild in place, then compile+run CODESTRING as benchmark in first module's namespace (implies -i))r   r   r   r   r   z--setupbenchmark_setupz6use CODESTRING as pre-benchmark setup code for --benchz-jz
--parallelr2   Nz(run builds in N parallel jobs (default: r   r   z-fz--forcer>   zforce recompilationz-qz--quietr?   z"be less verbose during compilationz	--lenientlenientzBincrease Python compatibility by ignoring some compile time errorsz-kz--keep-goingrE   z8compile as much as possible, ignore compilation failuresz--no-docstringsno_docstringszstrip docstringsz-Mz	--depfilez produce depfiles for the sources)r   r   sources*)nargs)argparser   r   Compiler.CmdLiner   r   r   add_argumentstrintparallel_compiles)r   r   r   r   r   parsers         r   create_args_parserr      s^   DDDDDDDDgggggggggg^3a	 	 	F m5E'#25  7 7 7 2<L-r6D  F F F j,$bs/3  5 5 5 #3MQR\`@  B B B
#3MQR@  B B B
'7UVZ  \ \ \
ijV[ei;  = = =
l=	XbL  N N N
*=V`I  J J J k9:%rO  Q Q Q iglTXO  Q Q Q
k^be  g g g 
lQT^b~  @ @ @
	(9<VYcgS  U U U lS(9_FWF\[\___  a a a iglTX0  2 2 2
iglTX?  A A A )LRV_  a a a
n<^bU  W W W
)^b-  / / /
k,Eghhh
	---Mr   c                     |                      |          \  }}|j        }|D ]E}|                    d          r|                     d|z              0|                    |           F|`||fS )N-zunknown option )parse_known_argsr   
startswitherrorr   )r   r   r4   unknownr   options         r   parse_args_rawr      s    ..t44GWoG  # #S!! 	#LL*612222NN6""""Wr   c                    t                      }t          ||           \  }} |j        d|_        n| s|                    d           |j        rd|_        t          d|_        |j        r|j        dv sJ |j        |j	        d<   |j
        rdt          _        dt          _        |j        r|j        t          _        |j        rdt          _        || fS )NTzno source files providedr   )r   r   3strr   F)r   r   r   rB   r   rH   rY   r2   r   r4   r   r	   error_on_unknown_nameserror_on_uninitializedr   r   
docstrings)r   r   r4   s      r   
parse_argsr      s    !!F"6400MGT$ $ 1/000  C%7777,3,B() /).&).& ,"+ #"D=r   c                    t          |           \  }}g }|D ]}d t          |          D             }|sNdd l}t          d                    |j        d         |          |j                   |                    d           |                    |           t          ||          }|r;|j
        r4t          t          |                                          |j                   |j        d x}}	|r&|                                \  }}
|
r|
d         j        }	dd l}||j                            d|           t          |j        |j        |	           ||j                            |           d S d S d S )Nc                 L    g | ]!}t           j                            |          "S r   )r$   r%   r-   )rQ   ps     r   rV   zmain.<locals>.<listcomp>"  s&    JJJ++JJJr   r   z#{}: No such file or directory: '{}')filer   )r   )r   r   sysr   formatargvstderrexitrI   r.   rH   r/   r0   r1   r2   r   popitemnamer%   insertr   remove)r   r4   rL   r5   r%   expanded_pathr   r6   r'   r   first_extensionss              r   mainr     s   %%NGUI ( (JJ^D5I5IJJJ 	JJJ7>>sx{DQQX[XbccccHHQKKK''''29gFF G'- Gt*002233W5EFFF$#''=! 	9)?)G)G)I)I&H& 9 0 3 8


HOOAx(((w6'	
 	
 	
 	

 HOOH%%%%%# %$   r   __main__)NNNr   )r$   rl   rj   collectionsr   Dependenciesr   r   Utilsr   Compilerr	   rY   r   	cpu_countr   rf   r   r*   rJ   r7   r.   r/   rX   r   r   r   r   r   r   r   r   r   <module>r      s   				   # # # # # # 3 3 3 3 3 3 3 3 " " " " " "      5O577#=>>   O
       " " "CT C C C C"& "& "& "& "&J  .( ( (<D D D D<F F FR    >"& "& "& "&J zDFFFFF s   A 	AA