
    wg                     2   d dl Z d dlmZ d dlm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 e j"                  j$                  j&                  Ze j"                  j$                  j(                  Ze j"                  j*                  j,                  Ze j"                  j.                  Zddd	Zd
 Z ej4                  ed       Z ej4                  ed      Zed        Z ej<                  d      d        Z G d de       Z! G d de       Z"d Z#d Z$y)    N)	build_ext)Distribution)mkdtemp)contextmanager)Path)z.dllz.pyd).sor   )windefaultc                 d    t         j                  t        j                  d d t         d         |    S )N   r
   )_configsgetsysplatformargs    X/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/numba/pycc/platform.pyget_configsr      s(    <<Ra((9*=>sCC       c              #     K   	 t               }t        t        j                  j	                  |d| z        d      }| 	 |j                          t        j                  |       t        j                  |       y #  Y y xY w# 	 j                          t        j                  |       t        j                         w #  Y w xY wxY ww)Nztemp%swt)r   openospathjoincloseremovermdir)suffixtmpdirntfs      r   _gentmpfiler#   #   s     277<<6(9:DA		IIKIIcN HHV			IIKIIcN HHV	sF   C	;B  %A; %C	;A?=C	C%B?)C?CCC	)maxsizec                  z   t               } t        |        dD ]  }	 t        |      5 }d}|j                  |       |j	                          |j                          | j                  |j                  gt        |j                        j                         ddd        y# 1 sw Y   xY w# t        $ r Y  yw xY w)zv
    Returns True if the "external compiler" bound in numpy.distutil is present
    and working, False otherwise.
    )z.cz.cxxzint main(void) { return 0; })
output_dirNFT)new_compilercustomize_compilerr#   writeflushr   compilenamer   anchor	Exception)compilerr    r"   simple_cs       r   external_compiler_worksr1   5   s     ~Hx   
	V$ O9		(#				   #((SXX8M8M NO O O  		s)   B-A/B!B-!B*	&B--	B:9B:c                       e Zd Zg Zy)_DummyExtensionN)__name__
__module____qualname__	libraries r   r   r3   r3   L   s    Ir   r3   c                   ~    e Zd Zd Zed        Zej                  d        Zd Z	 	 ddZ	 	 	 ddZ	d Z
d	 Zd
 Zd Zy)	Toolchainc                    t               s| j                          d| _        t               | _        t        | j                         t        t                     | _        | j                  j                          | j                  j                  | _        | j                  j                  | _        dt        j                         gi}t         j"                  dk(  rg |d<   || _        y dg|d<   || _        y )NFinclude_dirswin32r7   m)r1   _raise_external_compiler_error_verboser'   	_compilerr(   r   r   
_build_extfinalize_optionslibrary_dirs_py_lib_dirsr<   _py_include_dirsnpget_includer   r   
_math_info)selfnp_compile_argss     r   __init__zToolchain.__init__R   s    &(//1%4>>*#LN3((* OO88 $ < <)BNN,<+>@<<7"+-OK( * -06OK()r   c                     | j                   S N)r@   rJ   s    r   verbosezToolchain.verbosed   s    }}r   c                     || _         t        j                  |rt        j                         y t        j                         y rN   )r@   logset_thresholdINFOWARN)rJ   values     r   rP   zToolchain.verboseh   s(     	e#((::r   c                    d}d}t         j                  }|j                  d      r@t         j                  dk  rddg}nddg}|d	|d	j	                  |      z  }t        |      |j                  d
      r(ddg}|d	|d	j	                  |      z  }t        |      |j                  d      rd}|d	|}t        |      d|z  }t        |      )NzYAttempted to compile AOT function without the compiler used by `numpy.distutils` present.z(If using conda try:

#> conda install %slinuxl        zgcc_linux-32zgxx_linux-32zgcc_linux-64zgxx_linux-64 darwinzclang_osx-64zclangxx_osx-64r=   zCannot find suitable msvc.zUnknown platform %s)r   r   
startswithr$   r   RuntimeError)rJ   basemsg	conda_msgplt	compilersmsgwinmsgs          r   r?   z(Toolchain._raise_external_compiler_erroro   s    A@	ll>>'"{{g%+^<	+^<	$i#((92E&EFC 3 ^^H%')9:I$i#((92E&EFC 3 ^^G$1F$f-C 3 (#-C3r   Nc                 P    | j                   j                  |||||xs g |      }|S )a  
        Compile the given source files into a separate object file each,
        all beneath the *output_dir*.  A list of paths to object files
        is returned.

        *macros* has the same format as in distutils: a list of 1- or 2-tuples.
        If a 1-tuple (name,), the given name is considered undefined by
        the C preprocessor.
        If a 2-tuple (name, value), the given name is expanded into the
        given value by the C preprocessor.
        )r&   r<   dependsmacrosextra_preargs)rA   r+   )rJ   sourcesr&   r<   rd   re   extra_cflagsobjectss           r   compile_objectszToolchain.compile_objects   s:     ..((4>6B1806"7C ) E r   c           
          t         j                  j                  |      \  }}| j                  j	                  t
        j                  |||||||       y)zu
        Create a shared library *output* linking the given *objects*
        and *libraries* (all strings).
        )export_symbolsrf   N)r   r   splitrA   link	CCompilerSHARED_OBJECT)	rJ   outputri   r7   rD   rl   extra_ldflagsr&   output_filenames	            r   link_sharedzToolchain.link_shared   sL     ')ggmmF&;#
OI33W+Z%|+9*7	 	 	9r   c                     | j                   j                  t                     }t        j                  dk(  r|dgz   }|| j
                  d   z   S )zJ
        Get the library arguments necessary to link with Python.
        r=   msvcrtr7   )rB   get_librariesr3   r   r   rI   )rJ   libss     r   get_python_librarieszToolchain.get_python_libraries   sI     ,,_->?<<7" 8*$Ddook222r   c                 ,    t        | j                        S )zL
        Get the library directories necessary to link with Python.
        )listrE   rO   s    r   get_python_library_dirsz!Toolchain.get_python_library_dirs   s     D%%&&r   c                 L    t        | j                        | j                  d   z   S )zo
        Get the include directories necessary to compile against the Python
        and Numpy C APIs.
        r<   )r{   rF   rI   rO   s    r   get_python_include_dirsz!Toolchain.get_python_include_dirs   s#    
 D))*T__^-LLLr   c                 8    | j                   j                  |      S )zR
        Given a C extension's module name, return its intended filename.
        )rB   get_ext_filename)rJ   ext_names     r   r   zToolchain.get_ext_filename   s     //99r   )r8   r8   r8   N)r4   r5   r6   rL   propertyrP   setterr?   rj   rt   ry   r|   r~   r   r8   r   r   r:   r:   P   sj    *$   ^^; ; , =?%), 6846"&9
3'M:r   r:   c                      d| vr	d| v rd| z  S | S )zB
    Quote the argument for safe use in a shell command line.
    "rY   z"%s"r8   r   s    r   
_quote_argr      s      #~#*|Jr   c                 h    t        | t        t        f      ry	 t        |        y# t        $ r Y yw xY w)NFT)
isinstancestrbyteslenr.   r   s    r   _is_sequencer      s4    #U|$C s   % 	11)%
setuptoolssetuptools.command.build_extr   setuptools.distr   numpyrG   	functoolsr   
subprocessr   tempfiler   
contextlibr   pathlibr   	distutils	ccompilerro   r'   	sysconfigr(   rR   r   r   partialfind_shared_endingfind_pyext_endingr#   	lru_cacher1   objectr3   r:   r   r   r8   r   r   <module>r      s    2 (   	  
  %  !!++55	$$..;;))33FF 
 D 'Y&&{A6 %I%%k15  " Q  ,f u: u:pr   