
    J/Ph                        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j        ed           Z ej        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$dS )    N)	build_ext)Distribution)mkdtemp)contextmanager)Path)z.dllz.pyd).sor   )windefaultc                 ~    t                               t          j        d d         t           d                   |          S )N   r
   )_configsgetsysplatformargs    S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/pycc/platform.pyget_configsr      s+    <<RaR((9*=>>sCC       c              #     K   	 t                      }t          t          j                            |d| z            d          }|V  	 |                                 t          j        |           t          j        |           d S #  Y d S xY w# 	 |                                 t          j        |           t          j        |           w #  Y w xY wxY w)Nztemp%swt)r   openospathjoincloseremovermdir)suffixtmpdirntfs      r   _gentmpfiler#   #   s      27<<6(9::DAA				IIKKKIcNNN HV	DD		IIKKKIcNNN HV	Ds0   AB (B BC(C8CCC)maxsizec                     t                      } t          |            dD ]}	 t          |          5 }d}|                    |           |                                 |                                 |                     |j        gt          |j                  j	                   ddd           n# 1 swxY w Y   # t          $ r Y  dS w xY wdS )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		(###				   #(SX8M NNNO O O O O O O O O O O O O O O  	 	 	555	4s5   B>A4B2&B>2B6	6B>9B6	:B>>
CCc                       e Zd Zg ZdS )_DummyExtensionN)__name__
__module____qualname__	libraries r   r   r3   r3   L   s        IIIr   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dS )	Toolchainc                    t                      s|                                  d| _        t                      | _        t          | j                   t          t                                | _        | j        	                                 | j        j
        | _        | j        j        | _        dt          j                    gi}t           j        dk    rg |d<   ndg|d<   || _        d S )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    &(( 	2//111%4>***#LNN33((*** O8 $ <)BN,<,<+>@<7""+-OK((,/6OK()r   c                     | j         S N)r@   rJ   s    r   verbosezToolchain.verbosed   s
    }r   c                 x    || _         t                              |rt          j        nt          j                   d S rN   )r@   logset_thresholdINFOWARN)rJ   values     r   rP   zToolchain.verboseh   s2     	e9#((:::::r   c                    d}d}t           j        }|                    d          r7t           j        dk    rddg}nddg}|d	|d	                    |          z  }n[|                    d
          r"ddg}|d	|d	                    |          z  }n$|                    d          r
d}|d	|}n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@	l>>'"" 	.{g%%+^<		+^<	$WWi#((92E2E&E&EFCC^^H%% 	.')9:I$WWi#((92E2E&E&EFCC^^G$$ 	.1F$WWff-CC'#-C3r   r8   Nc                 J    | j                             |||||p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 E r   c           
          t           j                            |          \  }}| j                            t
          j        |||||||           dS )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   s\     ')gmmF&;&;#
OI3W+Z%|+9*7	 	 	9 	9 	9 	9 	9r   c                     | 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   sL     ,,_->->??<7"" 8*$Ddok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                 F    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                 6    | 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99r   )r8   r8   r8   N)r4   r5   r6   rL   propertyrP   setterr?   rj   rt   ry   r|   r~   r   r8   r   r   r:   r:   P   s        * * *$   X ^; ; ^;     , =?%)   , 6846"&9 9 9 9
3 
3 
3' ' 'M M 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                     t          | t          t          f          rdS 	 t          |            dS # t          $ r Y dS w xY w)NFT)
isinstancestrbyteslenr.   r   s    r   _is_sequencer      sT    #U|$$ uCt   uus   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 2 2 2 2 2 ( ( ( ( ( (         				     



       % % % % % %       !+5	$.;)3F 
  D D D 'Y&{A66 %I%k155   " Q   ,    f   u: u: u: u: u: u: u: u:p      r   