
    -Phi                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ ddlmZmZ d dlmZ 	 d dlZn	#  dZY nxY wdd	lm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lmZ ddl m!Z!m"Z"m#Z#  eej$        j%                  Z& ee          Z' ee          Z(d9dZ)d Z*d:dZ+d Z,d Z- e.            Z/ e.            Z0 e.            Z1e2e3e3e3e0e0e0e0e3e0e0e3e0e/e1dZ4d Z5 G d d          Z6 e j7        e. ej8        dej9                  j:                  Z; e j7        e. ej8        dej9                  j:                  Z< e j7        e. ej8        dej9                  j:                  Z=d;de2de2fdZ> ej8        d ej?        ej9        z            Z@ ej8        d!ej?        ej9        z            ZAd" ZBed#             ZCd$ ZDed%             ZEed&             ZFed'             ZGed(             ZH G d) d*          ZIdaJd<d,ZKd- ZL	 	 d=d.ZM	 	 d>d/ZNd0 ZOejP        Q                    d1          rejP        d1         ZRd2 ZSnd3 ZSeS	 	 	 	 d?d6            ZTd7 ZUd8 ZVdS )@    N)iglob)StringIO)relpath   )CacheFingerprintFlags)Iterable   )Utils)cached_functioncached_methodpath_existssafe_makedirscopy_file_to_dir_if_neweris_package_dirwrite_depfile)Errors)Context)Options)CompilationOptionsdefault_optionsget_directive_defaultsc                     st          j                    d         t           j        j        k    rt           j        j        z  fd| D             S )Nc                 ^    g | ])}|                               rt          |          n|*S  )
startswith_relpath).0pathbases     Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Build/Dependencies.py
<listcomp>z"_make_relative.<locals>.<listcomp>%   sI     $ $ $ %)OOD$9$9CHT4   t $ $ $    )osgetcwdr    sep)
file_pathsr!   s    `r"   _make_relativer)       sb     y{{Bx27;$ $ $ $"$ $ $ $r$   c           	   #     K   d| v ret          j        d|           }|rN|                                \  }}}|                    d          D ]}t	          ||z   |z             D ]}|V  d S d| v st
          j        dk    rd| v rt                      }t          j        dt
          j        dk    rdnd	z  | d
          \  }}	|rt          |t
          j        z             }ndg}|D ]~}
t	          t          |
|	                    D ]}||vr|
                    |           |V   t	          t          |
dd|	                    D ]}||vr|
                    |           |V   d S t          |           D ]}|V  d S )N{z(.*){([^}]+)}(.*),z**/\z**\z\*\*[%s]z/\\/r    *z**)rematchgroupssplitextended_iglobr%   r'   setr   	join_pathadd)patternmbeforeswitchaftercaser    seenfirstrestroots              r"   r5   r5   )   s     
g~~H('22 	$%HHJJ!FFES))  *6D=5+@AA  DJJJJF 26T>>f.?.?uuh{4ggSQSZ\]^^t 	%"&.))EEDE 	 	D&yt'<'<==  t##HHTNNNJJJ&ysD$'G'GHH  t##HHTNNNJJJ	 	 'NN 	 	DJJJJ	 	r$   expected non-empty iteratorc              #   F   K   d}| D ]}d}|V  	|rt          |          d S )NTF)
ValueError)it	error_msgemptyvalues       r"   nonemptyrJ   J   sJ      E   $###$ $r$   c                     t           t          d          	 t           j                            d          }n.# t          $ r! t           j                                        }Y nw xY w| j                            |d                    | j                            |d                    | j                            |d                    | j	                            |d                    | j
                            |d                    | j                            |d	                    | j                            |d
                    d| _        dD ]-}	 | j                            |           # t          $ r Y *w xY wd S )NzBYou first need to install Pythran to use the np_pythran directive.T)pythoninclude_dirsextra_compile_argsextra_link_argsdefine_macrosundef_macroslibrary_dirs	librariesc++)z-fwhole-programz-fvisibility=hidden)pythranRuntimeErrorconfigmake_extension	TypeErrorrM   extendrN   rO   rP   rQ   rR   rS   languageremoverE   )extpythran_ext
bad_options      r"   update_pythran_extensionr`   S   s   _```6n3343@@ 6 6 6n33556 K7888!!+.B"CDDD{+<=>>>[9:::K7888K7888M[1222CL A  
	"))*5555 	 	 	D	 s!    9 (A$#A$E..
E;:E;c                     t          |           dk    r%| d         dk    r| d         dk    r| dd         } d}nd}t          |           \  } fd	fd
|                     |          D             S )a#  
    >>> parse_list("")
    []
    >>> parse_list("a")
    ['a']
    >>> parse_list("a b c")
    ['a', 'b', 'c']
    >>> parse_list("[a, b, c]")
    ['a', 'b', 'c']
    >>> parse_list('a " " b')
    ['a', ' ', 'b']
    >>> parse_list('[a, ",a", "a,", ",", ]')
    ['a', ',a', 'a,', ',']
    r
   r   [r   ]r   r,    c                 d    |                                  } | d         dv r| dd                  S | S )Nr   z'"r   r   strip)literalliteralss    r"   unquotezparse_list.<locals>.unquote   s7    --//1:GAbDM**Nr$   c                 N    g | ]!}|                                  |          "S r   rf   )r   itemrj   s     r"   r#   zparse_list.<locals>.<listcomp>   s.    IIIdDJJLLIGGDMMIIIr$   )lenstrip_string_literalsr4   )s	delimiterri   rj   s     @@r"   
parse_listrq   l   s     1vv{{qts{{qu||adG			'**KAx     JIIIaggi&8&8IIIIr$   )namesourcesrP   rQ   rS   rR   runtime_library_dirsrM   extra_objectsrN   rO   export_symbolsdependsr[   
np_pythranc                     | dk    rdS | dk    rdS dd l }|                    dt                     |                                 } | dv rdS | d	v rdS t	          d
|           )NTrueTFalseFr   z1The 'np_python' option requires 'True' or 'False')category)yyesttrueon1)nnoffalseoff0zinvalid truth value )warningswarnDeprecationWarninglowerrE   )valr   s     r"   _legacy_strtoboolr      s    
f}}t	uOOOMMEPbMccc
))++C
222t	5	5	5ujSS:;;;r$   c                   (    e Zd ZddZd Zd Zd ZdS )DistutilsInfoNc                   	 i | _         |Mt          |t                    rt          |          n|}|D ]!		                                		s	d         dk    r d S 	dd                                          	t          	fddD             d           }|d 	t          |          d                              d          D             \  }}}t          	                    |d           }	
                    d          r||t          t          fv r!t          |          }|d	k    rd
 |D             }|t          u rt          |          }|| j         |<   #d S |,t          D ]&}|dv rt!          ||d           }|r
|| j         |<   %d S d S )Nr   #r   c              3   F   K   | ]}                     |          |V  d S N)r   )r   klines     r"   	<genexpr>z)DistutilsInfo.__init__.<locals>.<genexpr>   s5      WW1DOOTUDVDVWQWWWWWWr$   )z
distutils:cython:c                 6    g | ]}|                                 S r   rf   r   ro   s     r"   r#   z*DistutilsInfo.__init__.<locals>.<listcomp>   s     $X$X$X1QWWYY$X$X$Xr$   =r   rP   c                 d    g | ]-}d |v r#t          |                    d d                    n|df.S )r   r   N)tupler4   )r   macros     r"   r#   z*DistutilsInfo.__init__.<locals>.<listcomp>   sS     %9 %9 %9). ),u &+5;;sA+>+>%?%?%?;@$-%9 %9 %9r$   )rr   rs   rx   )values
isinstancestrr   lstripnextrm   	partitiondistutils_settingsgetr   listtransitive_listrq   bool_orr   getattr)
selfsourceexnsource_lineskindkey_rI   typer   s
            @r"   __init__zDistutilsInfo.__init__   s   /9&#/F/FR8F+++FL$ - -{{}} 7c>>EEABBx((WWWW(@WWWY]^^#$X$XSYYZZ8H8R8RSV8W8W$X$X$XMCE-11#t<<Dy11LdlHo666 *5 1 1/11%9 %927%9 %9 %9E w 1% 8 8',DK$)- -* _) - -:::S$// -',DK$ _- -r$   c                    || S |j                                         D ]\  }}t          |         }|t          u r|| j         vr|| j         |<   /|t          u rI|| j         v r5| j         |         d d          }|D ]}||vr|                    |           |}|| j         |<   |t          u r&| j                             |d          |z  | j         |<   | S NF)r   itemsr   transitive_strr   appendr   r   )r   otherr   rI   r   allvs          r"   mergezDistutilsInfo.merge   s    =K,,,.. 	G 	GJC%c*D~%%#T[*@*@#(C  (($+%%+c*111-C" * *C<<JJqMMME#(C  #';??3#>#>#FC r$   c                 Z   || S t                      }| j                                        D ]~\  }}t          |         }|t          t
          fv rFg }|D ]>}||v r||         }t          |t                    r||z  })|                    |           ?|}n||v r||         }||j        |<   |S r   )r   r   r   r   r   r   r   r   )r   aliasesresolvedr   rI   r   new_value_listr   s           r"   subszDistutilsInfo.subs   s    ?K ??+++-- 	) 	)JC%c*Do...!# 1 1AG||#AJ!!T** 1&!+&--a0000&G###ENE#(HOC  r$   c                     | j                                         D ]S\  }}t          |         }|t          t          fv r t          ||          t          |          z   }t          |||           Td S r   )r   r   r   r   r   r   setattr)r   	extensionr   rI   r   s        r"   applyzDistutilsInfo.apply   sv    +++-- 	+ 	+JC%c*Do...	3//$u++=IsE****		+ 	+r$   NN)__name__
__module____qualname__r   r   r   r   r   r$   r"   r   r      sV        - - - -B  (  ,+ + + + +r$   r   z]
    (?P<comment> [#] ) |
    (?P<brace> [{}] ) |
    (?P<fstring> f )? (?P<quote> '+ | "+ )
z`
    (?P<escape> [\\]+ ) (?P<escaped_quote> ['"] ) |
    (?P<fstring> f )? (?P<quote> '+ | "+ )
z
    (?P<braces> [{]+ | [}]+ ) |
    (?P<escape> [\\]+ ) (?P<escaped_quote> ['"] ) |
    (?P<fstring> f )? (?P<quote> '+ | "+ )
__Pyx_Lcodeprefixc                 J    g i dt           fddt          dt          j        dt          j        dt          j        f fdddt          j        d	t          j        dt          j        f fd
 d           d                              fS )z
    Normalizes every string literal to be of the form '__Pyx_Lxxx',
    returning the normalized code and a mapping of labels to
    string literals.
    r   c                 T    dz    d}| |<                        |           d S )Nr   r   )r   )rh   labelcounterri   new_coder   s     r"   append_new_labelz/strip_string_literals.<locals>.append_new_label%  s@    1%7%%%!r$   
quote_typestart
is_fstringreturnc                    |}|rt           nt          }|dk    rj ||          }| |d                     d}nE|                                }|d         r4t          |d                   dz  dk    r|d         | d         k    r|dz  }n|r{|d         rst          |d                   dz  dk    r|d         d         dk    rC||dz
  k     r ||dz
                                          d            	|d	
          x}}nq|d                             |           rV|                    d          }||k    r ||                                        |            |t          |           z  }n|dk    j|S )Nr   escaper
   r   escaped_quoter   bracesr+   T
in_fstringquote)_FIND_FSTRING_TOKEN_FIND_STRING_TOKENendrm   r   r   r   )
r   r   r   charpos
find_tokentokenr   r   r   
parse_codes
         r"   parse_stringz+strip_string_literals.<locals>.parse_string,  s   %*,6N((<N
mmJtW--E}  eff...iikkGX uX''!+q00U?5KzZ[}5\5\qLG h uX''!+q00?2&#--wqy((((egai.?)@AAAOOC(((&0jT&J&J&JJEGw**:66 ++g..U??$$T%'/%:;;;
+++3z??*A mmD r$   Fr   c                    | }|dk    r |          }|!	                     | d                     d}n|                                x}}|d         r|d         }t          |          dk    r|d t          |          dz           }|rxt          |          dk    ret          |          dk    r|t          |          dz
  z  }|d d         }	                     | |                     |||d                   x} }n|d         rX	                     | |                                        d	|          } ||dk    r|nd                     |dk    rn|} n|r|d
         r|d
         dk    r7|                                dz   x}}	                     | |                    nJ|                                dz   }	                     | |                     
|d          x} }|dk    |S )Nr   r      r
      fstring)r   comment
brace}r   Tr   )r   r   rm   findr   )r   r   r   r   r   r   r   r   r   r   r   r   s         r"   r   z)strip_string_literals.<locals>.parse_codeU  sE   %* mmJtW--E}UVV---!IIKK'GcW~ Ggu::??!/3u::>/2E \SZZ1__5zzA~~s5zzA~- %bqb	OODsO444&2l5#%PYJZ&[&[&[[EGy! GU3Y000))D#..  cw"}}GG$&N!OPPPb== 
Gg 
G>S(($)KKMMA$55GcOODsO444  ++--!+COODsO444&0j&F&F&FFEGM mmP r$   r/   F)_FIND_TOKENr   cython
Py_ssize_tbintjoin)	r   r   r   r   r   ri   r   r   r   s	   ``@@@@@@@r"   rn   rn     s    HH!"GJ       ' 'V-> 'FK '\b\m ' ' ' ' ' ' ' ' 'R- -&+ - -QWQb - - - - - - - - - - -^ JqMMM778h&&r$   a  (?:^ [ \t\f]* from     [ \t\f]+ cython\.cimports\.([\w.]+) [ \t\f]+ c?import ) |(?:^ [ \t\f]* from     [ \t\f]+ ([\w.]+) [ \t\f]+ cimport ) |(?:^ [ \t\f]* c?import [ \t\f]+ cython\.cimports\.([\w.]+) ) |(?:^ [ \t\f]* cimport  [ \t\f]+ ([\w.]+ (?:[ \t\f]* , [ \t\f]* [\w.]+)*) ) |(?:^ [ \t\f]* cdef     [ \t\f]+ extern [ \t\f]+ from [ \t\f]+ ['\"] ([^'\"]+) ['\"] ) |(?:^ [ \t\f]* include  [ \t\f]+ ['\"] ([^'\"]+) ['\"] )zf(?:^ [ \t\f]+ \( ([\w., \t\f]*) \) [ \t\f]* [#\n]) |(?:^ [ \t\f]+    ([\w., \t\f]*)    [ \t\f]* [#\n])c                     t          t          j                            |           t	          t          |                              S r   )normalize_existing0r%   r    dirnamer   r6   )	base_path	rel_pathss     r"   normalize_existingr     s.    rwy995Y;P;PQQQr$   c                 X   g }d}|D ]}t           j                            |          r|                    |           7t	          | |          }t          |          r5|                    t           j                            |                     | }|                    |           ||fS )a  
    Given some base directory ``base_dir`` and a list of path names
    ``rel_paths``, normalize each relative path name ``rel`` by
    replacing it by ``os.path.join(base, rel)`` if that file exists.

    Return a couple ``(normalized, needed_base)`` where ``normalized``
    if the list of normalized file names and ``needed_base`` is
    ``base_dir`` if we actually needed ``base_dir``. If no paths were
    changed (for example, if all paths were already absolute), then
    ``needed_base`` is ``None``.
    N)r%   r    isabsr   r7   r   normpath)base_dirr   
normalizedneeded_baserelr    s         r"   r   r     s     JK 	# 	#7== 	c"""3''t 	#bg..t44555"KKc""""$$r$   c                     t          |          }g }| D ])}t          ||          }||                    |           *|S r   )r   resolve_dependr   )rw   rM   r   dependr    s        r"   resolve_dependsr    sP    &&LH " "fl33OOD!!!Or$   c                     | d         dk    r| d         dk    rd S |D ]B}t          ||           }t          |          r!t          j                            |          c S Cd S )Nr   <r   >)r7   r   r%   r    r   )r  rM   dirr    s       r"   r  r    sx    ayCF2J#--t * *f%%t 	*7##D)))))	*4r$   c                 "   t           j                            t           j                            t	          |                               }|| k    r?t          |          r0t          |          t           j                            |          fz   S dS )Nr   )r%   r    r   abspathr   r   packagebasename)filenamer	  s     r"   r  r    sg    
'//"'//#h--88
9
9C
h>#..s||rw//44666rr$   c                     t           j                            t           j                            |                     d         }d                    t          |           |fz             S )Nr   .)r%   r    splitextr  r   r  )r  modules     r"   fully_qualified_namer    sM    Wbg..x8899!<F88GH%%	1222r$   c                    t          j        | d          5 }|                                }d d d            n# 1 swxY w Y   t          |          }t	          |          \  }}|                    dd                              dd          }g }g }g }t                              |          D ],}|                                \  }	}
}}}|	r|	|
r|
}r|	                               t                              ||                                          }|rO|                                \  }}|p|}|                    fd|                    d          D                        |r3|                    d	 |                    d          D                        |r|	                    ||                    |	                    ||                    .||||fS )
Nignore)error_handlingz\
rd   	)posc              3   h   K   | ],}d                      |                                          V  -dS )z{}.{}N)formatrg   )r   ro   cimport_froms     r"   r   z%parse_dependencies.<locals>.<genexpr>  sU        @  @$% !(|QWWYY G G  @  @  @  @  @  @r$   r,   c              3   >   K   | ]}|                                 V  d S r   rf   )r   xs     r"   r   z%parse_dependencies.<locals>.<genexpr>  s*      GG!AGGIIGGGGGGr$   )r   open_source_filereadr   rn   replacedependency_regexfinditerr3   r   dependency_after_from_regexsearchr   rZ   r4   )source_filenamefhr   distutils_infori   cimportsincludesexternsr:   pycimports_frompycimports_listcimport_listexternincludem_after_from	multilineone_line
subimportsr  s                     @r"   parse_dependenciesr4    sa   
 
		I	I	I R              "6**N,V44FH^^FC((00s;;F HHG&&v.. / /XYX`X`XbXbUfg 	+*L 	+*L 	/OOL)))6==f!%%''=RRL @&2&9&9&;&;#	8&2(
  @  @  @  @)3)9)9#)>)> @  @  @ @ @ @  	/OOGG|/A/A#/F/FGGGGGGG 	/NN8F+,,,,OOHW-....Xw66s   9= =c                       e Zd ZddZd Zed             Zed             Zd Zd Z	d Z
edd
            Zed             Zed             Zd Zed             Zd Zd Zd ZddZd Zd Zd	S )DependencyTreeFc                 0    || _         || _        i | _        d S r   )contextquiet_transitive_cache)r   r8  r9  s      r"   r   zDependencyTree.__init__  s    
!#r$   c                 |    t          |          rt          j                            |          }t	          |          S r   )r   r%   r    r   r4  )r   r%  s     r"   r4  z!DependencyTree.parse_dependencies  s6    '' 	@ g..??O!/222r$   c                 2   t                      }|                     |          d         D ]}t          t          j                            |          |          }t          |          s| j                            ||          }|rsdt          j        j	        z   |v rt          j        
                    |          }|                    |           |                    |                     |                     | j        st          d|d|d           |S )Nr   source_file_pathr  zUnable to locate 'z' referenced from '')r6   r4  r7   r%   r    r   r   r8  find_include_filer'   r   r8   updateincluded_filesr9  print)r   r  r   r/  include_paths        r"   rB  zDependencyTree.included_files  s    ee..x88; 
	Z 
	ZG$RW__X%>%>HHL|,, b#|==gX`=aa Z$44#%7#3#3L#A#AL%%%

4..|<<====Z ZhhhPWPWPWXYYY
r$   c                    |                      |          d d         \  }}}t          |          }t          |          }t                      }|                     |          D ]Z}|                     |          \  }}}	|                    |           |                    |           |                    |	           [t          ||          \  }}
|
r|                    |
           t          |          ||fS )Nr   )r4  r6   rB  cimports_externs_incdirsrA  r   r8   r   )r   r  r(  r)  r*  incdirsr/  included_cimportsincluded_externsincluded_incdirsincdirs              r"   rF  z'DependencyTree.cimports_externs_incdirs#  s     '+&=&=h&G&G&K#(Gx==g,,%%**844 	- 	-GDHDaDabiDjDjA/1AOO-...NN+,,,NN+,,,,,Xw?? 	 KKX00r$   c                 8    |                      |          d         S Nr   )rF  r   r  s     r"   r(  zDependencyTree.cimports5  s    ,,X66q99r$   c                      t          |          S r   )r  rN  s     r"   r  zDependencyTree.package8  s    x   r$   c                      t          |          S r   )r  rN  s     r"   r  z#DependencyTree.fully_qualified_name;  s    #H---r$   Nc                 0   |d         dk    }|r|st          d          ||                    d          }|r|                    d           t          |                     |                    }|rN|d         sF	 |                                 n# t
          $ r Y d S w xY w|                    d           |r|d         Fd                    ||z             }| j                            ||          }|r|S |rd S | j                            ||          S )Nr   r  zNew relative imports.r=  )	NotImplementedErrorr4   popr   r  
IndexErrorr   r8  find_pxd_file)r   r  r  is_relativemodule_pathpackage_pathrelativepxds           r"   find_pxdzDependencyTree.find_pxd>  sU   Qi3& 	?x 	?%&=>>> ,,s++K #"""X 6 677L #k!n #  $$&&&&!      44 """  #k!n # xx{ :;;H,,,X,QQC 
 	4|))&8)LLLs   ;B 
BBc                 V   t           j                            |          \  }}|dv rt          |dz             r|dz   g}ng }|                     |          D ]D}|d d         dk    s|dk    r|                     ||          }||                    |           Et          |          S )N.pyx.pyz.pxd   zcython.r   )r%   r    r  r   r(  r[  r   r   )r   r  filename_rootfilename_extpxd_listr  pxd_files          r"   cimported_fileszDependencyTree.cimported_filesV  s    &(g&6&6x&@&@#|?**{=6;Q/R/R*%./HHH mmH-- 	* 	*FbqbzY&&&H*<*<}}VX66H#)))Xr$   c                     |h}|                     |                     |                     |                     |                     |                     |S r   )rA  re  rB  )r   r  all_depss      r"   immediate_dependenciesz%DependencyTree.immediate_dependenciesg  sN    :,,X66777++H55666r$   c                 N    |                      || j        t          j                  S r   )transitive_mergerh  r6   unionrN  s     r"   all_dependencieszDependencyTree.all_dependenciesn  s    $$Xt/JCIVVVr$   c                 @    t           j                            |          S r   )r%   r    getmtimerN  s     r"   	timestampzDependencyTree.timestampq  s    w)))r$   c                 0    |                      |          |fS r   )ro  rN  s     r"   extract_timestampz DependencyTree.extract_timestampu  s    ~~h''11r$   c                 `     t           fd                     |          D                       S )Nc                 :    g | ]}                     |          S r   )rq  )r   r   r   s     r"   r#   z4DependencyTree.newest_dependency.<locals>.<listcomp>y  s'    WWW!D**1--WWWr$   )maxrl  rN  s   ` r"   newest_dependencyz DependencyTree.newest_dependencyx  s4    WWWWt7L7LX7V7VWWWXXXr$   c                    |                      |          d         }|j        }|                     |          \  }}}t          j                    }|r_t          ||          }d|v r9t          t          |d                                       |                    |d<   nt          |          |d<   |rTt          |	                    dg                     }t          ||          D ]}	|	|vr|
                    |	           ||d<   |S )Nr   rw   rM   )r4  r   rF  r%   r&   r)   r   r6   rk  r   r   )
r   r  infokwdsr(  r*  rG  basedirrM   incs
             r"   distutils_info0zDependencyTree.distutils_info0{  s   &&x003{%)%B%B8%L%L"'7)++ 	0$Wg66GD  "&s4	?';';'A'A''J'J"K"KY"&w--Y  	0 < <==L%gw77 - -l** '',,,#/D r$   c                     |                      || j        t          j                                      |                              |          S r   )rj  r{  r   r   r   )r   r  r   r!   s       r"   r'  zDependencyTree.distutils_info  s8    %%h0DmFYZZT']]U4[[	r$   c                     	 | j         ||f         }n# t          $ r i x}| j         ||f<   Y nw xY w|                     ||||i | j                  d         S rM  )r:  KeyErrortransitive_merge_helperre  )r   nodeextractr   r?   s        r"   rj  zDependencyTree.transitive_merge  s    	?)'5.9DD 	? 	? 	?<>>D4)'5.999	?++'5$D,@B BBCE 	Es    --c           	      J   ||v r
||         d fS  ||          }||v r||fS 	 t          |          ||<   d } ||          D ]D}	|                     |	|||||          \  }
}||||         ||         k     rn|} |||
          }E||k    rd }||||<   ||f||= S # ||= w xY wr   )rm   r  )r   r  r  r   r?   stackoutgoingdepsloopr   sub_depssub_loops               r"   r  z&DependencyTree.transitive_merge_helper  s   4<<:t##wt}}5==:	e**E$KD  - -%)%A%A$QVX\^cem%n%n"(''E$K%/,I,I'uT8,,t|||!T
:ddOOOOs   A6B B"r   r   r   )r   r   r   r   r4  r   rB  rF  r(  r  r  r[  re  rh  rl  ro  rq  ru  r{  r'  rj  r  r   r$   r"   r6  r6    s       $ $ $ $
3 3 3
   ]" 1 1 ]1": : :! ! !. . . M M M ]M.   ]    ]W W W * * ]*2 2 2Y Y Y  ,   
E E E    r$   r6  Fc                     t           D| 1t          dgt                      t          t                              } t          | |          a t           S )Nr  )optionsr9  )	_dep_treer   r   r   r   r6  )ctxr9  s     r"   create_dependency_treer    sT    ;3%!7!9!9"4_"E"EG G GC"3e444	r$   c                 D   d|v rW|                     dg           dgz   }t          |d         |          }t          t          || j        z                       |d<   | j        } |di |}t          | d          r| j        |_        t          ||d                   }||fS )Nrw   rM   r  py_limited_apirr   )	distutilsmodule_namer   )	r   r  sortedr6   rw   	__class__hasattrr  dict)templaterx  rM   rw   r   r]   metadatas          r"   default_create_extensionr    s    Dxx33se;!$y/<@@ Wx/?%?!@!@AAYA
!))d))Cx)** 5%4dV===H?r$   c                 
  #$ |"t          d                    |                     |g }| g i fS t          | t                    st          | t                    s| g} ddlm} dt          j        v r0|t          j        d         j	        t          j        d         j        f#n|f##fd| D             }t          ||          }	|j        }
t                      }t          |t                    s|g}|D ]A}|                    t          t           j        j        t'          |                               Bg }i }|j        j        pt,          }t                      }| D ]}t          |t                    r|$ ||g           }d}d }|}n`t          |#          r	d	 |j        D             }|r7|d         $t1          |          d
k    rt          d|j        d|d           n|
r|j        |
k    r ||t5          |
|j        p0|
                    dt           j                  |j        dk    rdndz   g|j                            \  }}d|_        d |_        |                    |           |                    |           ,|}|j        }tA          |          }d }nFt          dtC          |          dtE          |          d|j#                  }tI          |          tK          tM          t'          $                    d$z            D ]0}t           j                            |          |v r%|	'                    |          }d|v r||v rCn|r|}tQ          j)        |           ||vr	 |	*                    |||          j+        }n# tX          $ r |rY  w xY w|(|j+        -                                D ]\  }}||vr|||<   ||d<   |g$fd|j        D             z   }d|v r$|d         D ]}||vr|                    |           ||d<   |r	d|vr||d<   |.                    dd          }  |||          \  }}!| pt_          |dd          |_        |
|_        |j        rta          |           |                    |           |!||<   ||j        vrt           j        1                    |          d         |j        dk    rdndz   }"	 |j        2                    |"           n"# tf          $ r t          d|z             Y nw xY w|j        4                    d|           |5                    |           2||fS )NzWarning: passing language={0!r} to cythonize() is deprecated. Instead, put "# distutils: language={0}" in your .pyx or .pxd file(s)r   )	Extension
setuptoolszsetuptools.extensionc                 >    h | ]}t          |          |j        S r   )r   rr   )r   r:   extension_classess     r"   	<setcomp>z(create_extension_list.<locals>.<setcomp>  s+    UUU1JqBS4T4TUUUUr$   r  r0   c                 `    g | ]+}t           j                            |          d          dv )|,S )r   )r_  r^  r%   r    r  r   s     r"   r#   z)create_extension_list.<locals>.<listcomp>  sD     L L LA!#!1!1!!4!4Q!7?!J!J  !J!J!Jr$   r   z6Warning: Multiple cython sources found for extension 'z': z
See https://cython.readthedocs.io/en/latest/src/userguide/sharing_declarations.html for sharing declarations among Cython files.r  rT   .cpp.c)rr   rs   r[   F)r   z6pattern is not of type str nor subclass of Extension (z) but of type z and class z'%s' doesn't match any filesrr   c                      g | ]
}|k    |S r   r   )r   r:   filepatterns     r"   r#   z)create_extension_list.<locals>.<listcomp>C  s#    #T#T#T!1CSCSACSCSCSr$   rs   r[   rx   z@Warning: Cython source file not found in sources list, adding %s)6rC  r  r   r   r	   distutils.extensionr  sysmodules
_Extensionr  shared_utility_qualified_namer6   r   rA  mapr%   r    r  r5   r  create_extensionr  rs   rm   rr   r  r   r'   r[   rx   r   r   reprr   r  rY   rJ   r  r  r   $raise_error_if_module_name_forbiddenr'  r   	Exceptionr   rS  r   r`   r  r\   rE   insertr8   )%patternsexcluder  r   r9  r[   exclude_failuresr  explicit_modulesr  r  
to_excluder9   module_listmodule_metadatar  r?   r  rr   r!   ext_languagecython_sourcesr:   r   msgfiler  rx  r   rI   rs   r   rx   r  target_filer  r  s%                                      @@r"   create_extension_listr    s    VV\V\]eVfVf	h 	h 	h2v	Hc	"	" *Xx*H*H :------s{"" K./:K%/
 'LUUUUUUU!#U333D$'$E!Jgt$$ ) I I#bgo~g/F/FGGHHHHKO {3O7O55D g ggs## (	!!K y"--HDD#LL!233 "	!L L L L LN ,Q/~&&**ELSLLLZhZhZhj k k k / 7<C`3`3`''6#O ~5==c26JJX_XhlqXqXqffw{|0~$-	2 2 2  1  %26/""1%%% ""7+++H=D X...DLL#8<Y8<W8?8I8IK L LC C.. VN;$?$?@@B`cnBnoo <	 <	Dwt$$
2233D99Kd{{"222 3 #"6{CCC$&&..tWdCCJDD    ' !  #&*k&7&7&9&9 . .
Ud??(-DI*V&#T#T#T#Tx/?#T#T#TT$$"&y/ 3 3!00#NN6222")Y 4Jd$:$:'3D$!XXlE::
 /.x>>8)LWQe-L-L2O/< 0,Q///""1%%% 08,qy(("$'"2"24"8"8";W\I\I\vvbf"gKi	((5555% i i i`cgghhhhhi I$$Q---y<	z ''s$   9NN&$N&S55TTc	                   234 |g }d|	vrdg|	d<   d|	v rt          |	d                    |	                    dd          }
t          d}nt          d2i |	}d|_        d|_        |#t          j                            d          dk    }t          d2i |	}t          d2i |	}d|_        t          j
        |          }|}	|j        }t          | ||||||	          \  } }t          |            t          ||
          }t          |	dd          2|	j        rE|	j        s>t$          j        s2|	j        du rdn|	j        }t'          |t          |	dd                    4nd4t          j                    f2fd	}2fd}t+          j        t.                    }g }| D ]j}2r|j        D ]} ||           d |j        D             }t5          |          dk    r|j        }nd}t          |dd          }t          |dd          }|r|}	n|j        dk    r|}	n|}	g }|j        D ]}t          j                            |          \  }} | dv r||j        dk    s|rdndz   }! ||!          }!|
r&|                    |          }"tA          |!||"           tC          j"        |!          r t          j        #                    |!          }#nd}#|#|$                    |          k     r|$                    |          |}}$d}%n2|%                    |          \  }$}d||&                    |          v z
  }%|s|#|$k     r|sg|se||k    r%tO          dtC          j(        |          z             n:tO          dtC          j(        |          dtC          j(        |          d           |sD4rB4)                    ||                    |          |	tU          |j        pd||                    }&nd}&|+                    |%||!|&||	| |                    |j                  ||f
           ||!         +                    |           n|r|j        |k    r ||          }!t          |	|!d          }'tC          j,        |!          stO          d |j         d!|! d"           nQ|stC          j"        |!          s+dd#l-m.}( |stO          d$|j         d"            |(|'           n|}!2r ||           |+                    |!           ||_        l|/                                 t5          |          })d%t5          ta          |)                    |)fz  j1        334fd&te          |d          D             }|)dk    rd}|rddl3}*|*4                    |tj          '          }+	 |+6                    tn          |d(          },|+8                                 |,9                                s;	 |,                    d)           n# |*j:        $ r Y nw xY w|,9                                ;n## tv          $ r |+<                                  w xY w|+=                                 n|D ]}-t}          |-  |rTt                      }.|@                                D ]\  }!}/t          j        A                    |!          s|.B                    |/           :t          j        C                    |!          d*k     r|t          |!d+d,-          }0	 |0E                    t5          d.                    d.k    r|.B                    |/           |08                                 # |08                                 w xY w|.rV|.D ]}1| F                    |1           tO          d/d0=                    t          d1 |.D                                 z             4r4H                                 t          jJ        K                                 | S )3a  
    Compile a set of source modules into C/C++ files and return a list of distutils
    Extension objects for them.

    :param module_list: As module list, pass either a glob pattern, a list of glob
                        patterns or a list of Extension objects.  The latter
                        allows you to configure the extensions separately
                        through the normal distutils options.
                        You can also pass Extension objects that have
                        glob patterns as their sources. Then, cythonize
                        will resolve the pattern and create a
                        copy of the Extension for every matching file.

    :param exclude: When passing glob patterns as ``module_list``, you can exclude certain
                    module names explicitly by passing them into the ``exclude`` option.

    :param nthreads: The number of concurrent builds for parallel compilation
                     (requires the ``multiprocessing`` module).

    :param aliases: If you want to use compiler directives like ``# distutils: ...`` but
                    can only know at compile time (when running the ``setup.py``) which values
                    to use, you can use aliases and pass a dictionary mapping those aliases
                    to Python strings when calling :func:`cythonize`. As an example, say you
                    want to use the compiler
                    directive ``# distutils: include_dirs = ../static_libs/include/``
                    but this path isn't always fixed and you want to find it when running
                    the ``setup.py``. You can then do ``# distutils: include_dirs = MY_HEADERS``,
                    find the value of ``MY_HEADERS`` in the ``setup.py``, put it in a python
                    variable called ``foo`` as a string, and then call
                    ``cythonize(..., aliases={'MY_HEADERS': foo})``.

    :param quiet: If True, Cython won't print error, warning, or status messages during the
                  compilation.

    :param force: Forces the recompilation of the Cython modules, even if the timestamps
                  don't indicate that a recompilation is necessary.

    :param language: To globally enable C++ mode, you can pass ``language='c++'``. Otherwise, this
                     will be determined at a per-file level based on compiler directives.  This
                     affects only modules found based on file names.  Extension instances passed
                     into :func:`cythonize` will not be changed. It is recommended to rather
                     use the compiler directive ``# distutils: language = c++`` than this option.

    :param exclude_failures: For a broad 'try to compile' mode that ignores compilation
                             failures and simply excludes the failed extensions,
                             pass ``exclude_failures=True``. Note that this only
                             really makes sense for compiling ``.py`` files which can also
                             be used without compilation.

    :param show_all_warnings: By default, not all Cython warnings are printed.
                              Set to true to show all warnings.

    :param annotate: If ``True``, will produce a HTML file for each of the ``.pyx`` or ``.py``
                     files compiled. The HTML file gives an indication
                     of how much Python interaction there is in
                     each of the source code lines, compared to plain C code.
                     It also allows you to see the C/C++ code
                     generated for each line of Cython code. This report is invaluable when
                     optimizing a function for speed,
                     and for determining when to :ref:`release the GIL <nogil>`:
                     in general, a ``nogil`` block may contain only "white" code.
                     See examples in :ref:`determining_where_to_add_types` or
                     :ref:`primes`.


    :param annotate-fullc: If ``True`` will produce a colorized HTML version of
                           the source which includes entire generated C/C++-code.


    :param compiler_directives: Allow to set compiler directives in the ``setup.py`` like this:
                                ``compiler_directives={'embedsignature': True}``.
                                See :ref:`compiler-directives`.

    :param depfile: produce depfiles for the sources if True.
    :param cache: If ``True`` the cache enabled with default path. If the value is a path to a directory,
                  then the directory is used to cache generated ``.c``/``.cpp`` files. By default cache is disabled.
                  See :ref:`cython-cache`.
    NrD  r  common_utility_include_dirdepfileTCYTHON_FORCE_REGENr   )r  r  r9  r  r[   r   r  	build_dir
cache_sizec           	      L   t           j                            |           }t           j                            |           r|} |                    |          rMt          t           j                            t          | |                              }t          ||           d S d S r   )	r%   r    r  r   r   r7   r   r   copy_once_if_newer)filepathrB   filepath_absmod_dirr  s       r"   copy_to_build_dirz$cythonize.<locals>.copy_to_build_dir  s    wx007=="" 	$#H""4(( 	6	 "40H0H I IK KG|W55555		6 	6r$   c                    s| S t           j                            |           rKt           j                            |           d         } |                     t           j        d          d         } t           j                            |           } t           j                            |           }t          |           | S )Nr   )	r%   r    r   
splitdriver4   r'   r   r   safe_makedirs_once)c_filer	  r  s     r"   file_in_build_dirz$cythonize.<locals>.file_in_build_dir  s     	M7==   	0W''//2F\\"&!,,Q/Fi00goof%%3r$   c                 `    g | ]+}t           j                            |          d          dv )|,S )r   r]  r  )r   r   s     r"   r#   zcythonize.<locals>.<listcomp>  sB     ? ? ?w''*o== ===r$   r   rx   Fr  rT   r]  r  r  r   r   r
   z Compiling %s because it changed.z
Compiling z because it depends on c)shared_c_file_pathr  zHWarning: Shared module source file is not a Cython file - not creating 'z' as 'r?  )generate_shared_modulezGenerating shared module 'z[{0:%d}/%d] c                 F    g | ]\  }}|d d          |          fz   S )r   Nr   )r   itaskbuild_progress_indicatorcaches      r"   r#   zcythonize.<locals>.<listcomp>e  sK       At 	QRR,,Q//77  r$   )initializer)	chunksizei    rz	iso8859-1)encodingz#error zFailed compilations: %sz, c                     g | ]	}|j         
S r   )rr   )r   r  s     r"   r#   zcythonize.<locals>.<listcomp>  s-     @: @: @: &@: @: @:r$   r   )Lr   rS  rU   r   cplusrx   r%   environr   r   from_optionsr  r  fix_windows_unicode_modulesr  r   r  annotater   r   r&   collectionsdefaultdictr   rw   rs   rm   rr   r[   r    r  rl  r   r   file_generated_by_this_cythonrn  ro  ru  rh  rC  decode_filenametransitive_fingerprintr   r   is_cython_generated_fileSharedModuler  sortr   r  	enumeratemultiprocessingPool_init_multiprocessing_helper	map_asynccythonize_one_helperclosereadyTimeoutErrorKeyboardInterrupt	terminater   cythonize_oner6   r   existsrA  getsizeopenr  r\   r  cleanup_cacher  stdoutflush)5r  r  nthreadsr   r9  forcer[   r  show_all_warningsr  r  pythran_options	c_optionscpp_optionsr  r  r  r  
cache_pathr  r  modules_by_cfile
to_compiler:   dep
cy_sourcesfull_module_namerx   r  new_sourcesr   r!   r]   r  dependenciesc_timestampdep_timestamppriorityfingerprintmodule_optionsr  Nr  poolresultargsfailed_modulesr  r   r  r  r  r  s5                                                     @@@r"   	cythonizer  j  s	   ` W$$#&%#w..g:;<<<kk)T**G,77w77 $%)"}
344;"--W--I$//w//KT1B

y
)
)CG$'$E!#8)$ $ $ K  ,,,!#U333Dd33I} g. '2B 
 %]d22TT
j''<"F"FGG)+ 6 6 6 6 6 6	 	 	 	 	 #.t44J ]  ]  	'y ' '!!#&&&&? ?!"? ? ?
 z??a v  $Qe44
 $4e<< 	 %GGZ5  !GGGi A	' A	'F((00ID#o%%1:+>+>*+>RVW +*622  @#'#8#8#@#@L!&&,??? 6v>> %"$'"2"26":":KK"$K !7!777)-)?)?3M HH)-)?)?)G)G&M3 C4+F+Fv+N+N$NOH >K-77   !S==!"DuG\]cGdGd"deeee!E % 5f = = = = % 5c : : : :#    ! +U +&+&B&B &(=(=f(E(Ew 01BsNT^ _ _' '
 '+%% &&+u%5!57J7J167R7R(*;'= > > > !(//2222. .16=Z3Z3Z**622!3VZ"\ "\ "\5f== ;|efek||sy|||}}}} ;%"Ef"M"M ;DDDDDD  FD16DDDEEE**>::: .%%f---v&&&&		OOJA !/#c!ff++q1A AI     Q//  J
 	Avv !##"> $ @ @
	^^$8*PQ^RRFJJLLLllnn JJu%%%%&3   D llnn 
 ! 	 	 	NN	 			 	! 	!D4    =/5577 
	 
	OFG7>>&)) 	%%g....((3..{;;;vvc)nn--::&--g666GGIIIIAGGIIII /  	=( + +""6****+dii @: @:*8@: @: @: 9; 9; /< /< < = = =   Js=   AX W1 0X 1
W>;X =W>>X  X61;]]c                    t           j        dk    rd S t           j        dk    rd S d }| D ]T}|j                                        r |d|j                            dd          d         z   |j                  |_        Ud S )Nwin32)r      r
   c                       G  fddt                     } ||          }|r!|                     fd|D                        |S )Nc                       e Zd Z fdZdS )Vfix_windows_unicode_modules.<locals>.make_filtered_list.<locals>.FilteredExportSymbolsc                 F    |k    pt                               | |          S r   )r   __contains__)r   r   ignored_symbols     r"   r  zcfix_windows_unicode_modules.<locals>.make_filtered_list.<locals>.FilteredExportSymbols.__contains__  s#    n,L0A0A$0L0LLr$   N)r   r   r   r  )r  s   r"   FilteredExportSymbolsr    s5        M M M M M M Mr$   r  c              3   (   K   | ]}|k    |V  d S r   r   )r   rr   r  s     r"   r   zJfix_windows_unicode_modules.<locals>.make_filtered_list.<locals>.<genexpr>  s-       X X$AWAWAWAWAWAW X Xr$   )r   rZ   )r  old_entriesr  filtered_lists   `   r"   make_filtered_listz7fix_windows_unicode_modules.<locals>.make_filtered_list  s    	M 	M 	M 	M 	M 	M 	MD 	M 	M 	M .-k:: 	Y   X X X X+ X X XXXXr$   PyInit_r  r   r   )r  platformversion_inforr   isasciirsplitrv   )r  r#  r:   s      r"   r  r    s     |w
9$$    
 
6>> 	--c1--b11
 

 
r$   XML_RESULTSc                       fd}|S )Nc            	      N   t          j                     }d}	 	  |   n	#  d}Y nxY wt          j                     |z
  }t          | d                   }d|z   }d|z
  }|rd}nd}t          t          j                            t          |dz             d	          }|                    d
                                t                      z             |
                                 d S # t          j                     |z
  }t          | d                   }d|z   }d|z
  }|rd}nd}t          t          j                            t          |dz             d	          }|                    d
                                t                      z             |
                                 w xY w)NTFr   z
cythonize.r   r/   failurez.xmlwaQ  
                    <?xml version="1.0" ?>
                    <testsuite name="%(name)s" errors="0" failures="%(failures)s" tests="1" time="%(t)s">
                    <testcase classname="%(name)s" name="cythonize">
                    %(failure_item)s
                    </testcase>
                    </testsuite>
                )timer  r  r%   r    r   compile_result_dirwriterg   localsr  )	r  r   successr  rr   failuresfailure_itemoutputfuncs	           r"   with_recordz#record_results.<locals>.with_record  s   	AG$D$KKK$#GGGIKK!O-d1g66#f,w; -#%LL#,Lbgll+=tf}MMsSS  EGGfhh' ( ( ( # IKK!O-d1g66#f,w; -#%LL#,Lbgll+=tf}MMsSS  EGGfhh' ( ( ( s    C& %C& &B>F$r   )r6  r7  s   ` r"   record_resultsr8    s$    	 	 	 	 	6 r$   c                     | S r   r   )r6  s    r"   r8  r8    s    r$   Tr/   c                 V   ddl m}m} ddlm}m} |sV|
r.|r,|
                    ||          rt          |	 d|  d           n&t          |	 dt          j	        |                       |t          |          }||_        ||_        t          j        }|rdt          _        d}	  || |||
|          }|j        dk    rd	}n}# t           |f$ rF}t"          j                            d
|z             d	}dd l}|                                 Y d }~n0d }~wt,          $ r  |r dd l}|                                 d	}Y nw xY w|r|t          _        n# |r|t          _        w xY w|rC|r |d |           t.          j                            |          rt/          j        |           d S d S d S )Nr
   )compile_singler   )CompileError
PyrexErrorzFound compiled z	 in cachezCythonizing r   )r  r  r  r   z%s
)Compiler.Mainr;  r   Compiler.Errorsr<  r=  lookup_cacherC  r   r  r   output_fileembedded_metadatar   LEVEL
num_errorsOSErrorr  stderrr0  	traceback	print_excr  r%   r    r  r\   )pyx_filer  r  r9  r  raise_on_failurerB  r  r  progressr  r;  r   r<  r=  old_warning_levelany_failuresr  erG  s                       r"   r  r    sj    @???????:::::::: N 	N[ 	NU%7%7%L%L 	NXAAhAAABBBBXLL5+@+J+JLLMMM$_55 G 1G L-'DT\aoz{{{q  LZ    
!$$$    	  	-,FL  	-,FL,,,,  	,tX...W^^F## 	If	 	 	s<   %C E D=<DE *D=:E <D==E Ec                 d    dd l }	 t          |  S # t          $ r |                                  w xY wrM  )rG  r  r  rH  )r:   rG  s     r"   r  r    sN    a     s     /c                  N    dd l } |                      | j        | j                   d S rM  )signalSIGINTSIG_IGN)rQ  s    r"   r  r     s)    MMM
MM&-00000r$   r   )rC   )r   r   )NNNFNF)Nr   NFNNFF)	NFNTNNFr/   N)Wr   r  r%   r1   r  r.  globr   ior   os.pathr   r   r   r   collections.abcr	   rU   r/   r   r   r   r   r   r   r   r   Compilerr   r>  r   r   Compiler.Optionsr   r   r   r    r   r7   r  r  r)   r5   rJ   r`   rq   objectr   r   r   r   r   r   r   r   declarecompileVERBOSEr$  r   r   r   rn   	MULTILINEr!  r#  r   r   r  r  r  r  r4  r6  r  r  r  r  r  r  r  r   r/  r8  r  r  r  r   r$   r"   <module>r_     s        				                         ' ' ' ' ' ' * * * * * * * * $ $ $ $ $ $NNNNGGG      M M M M M M M M M M M M M M M M M M       # # # # # #                OBGL))	$_%>?? $_]33 $ $ $ $  B$ $ $ $  2J J J< &((
&((     ++++ ++ +*#  &< < <$R+ R+ R+ R+ R+ R+ R+ R+j fnVZRZ 1 Z	& & 	  $V^FJBJ 8 Z- -   
 %fnVZRZ 9 Z	. . 	  k' k' k'S k' k' k' k'b 2:? L2:   )bj:L2:  R R R % % %6         3 3 3
 $7 $7 $7Np p p p p p p pf 	      ae+0Q( Q( Q( Q(j fj8=s s s sl	
 
 
> :>>-   !M2   <  
 9=;?;@%)	/ / / /d  1 1 1 1 1s	   ? A