
    J/Ph)                         d dl m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mZmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ ej        Zej        Z ej                    Z G d
 de          Z G d de          ZdS )    )	distutils)	build_ext)	ExtensionN)typingsigutils)global_compiler_lock)ModuleCompilerExportEntry)	Toolchain)cextc                      e Zd ZdZdgez   Zi Zi ZddZe	d             Z
e	d             Zej        d             Ze	d             Zej        d	             Ze	d
             Zej        d             Ze	d             Zej        d             Ze	d             Zej        d             Zd Ze	d             Zd Zd Zd Zd Zd Zed             Zed             Zd ZdS )CCz_
    An ahead-of-time compiler to create extension modules that don't
    depend on Numba.
    zmodulemixin.cNc                 8   d|v rt          d          || _        d|z   | _        i | _        t	          j        d          }||j        }|d         }n6t          |d          r|j        }|j	        }nt          j
        |         j        }|                    dd          | _        || _        t                      | _        d| _        t"          j                            | j                  | _        | j                            |          | _        d	| _        d| _        d S )
N.z;basename should be a simple module name, not qualified name
pycc_init_   __name____file__ FT)
ValueError	_basename_init_function_exported_functionssys	_getframe	f_globalshasattr__dict__r   modulesget_source_path_source_moduler   
_toolchain_verboseospathdirname_output_dirget_ext_filename_output_file_use_nrt_target_cpu)selfextension_namesource_modulefdcts        M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/pycc/cc.py__init__zCC.__init__/   s   .   . / / / (*^;#% M! +C
OMM]J// 	6(C)2MM+m,5CGGJ33+#++7??4+<== O<<^LL    c                     | j         S )z=
        The name of the extension module to create.
        )r   r-   s    r2   namezCC.nameL   s    
 ~r4   c                     | j         S )zJ
        The specific output file (a DLL) that will be generated.
        r*   r6   s    r2   output_filezCC.output_fileS   s    
   r4   c                     || _         d S Nr9   r-   values     r2   r:   zCC.output_fileZ   s    !r4   c                     | j         S )z?
        The directory the output file will be put in.
        r(   r6   s    r2   
output_dirzCC.output_dir^       
 r4   c                     || _         d S r<   r@   r=   s     r2   rA   zCC.output_dire        r4   c                     | j         S r<   r+   r6   s    r2   use_nrtz
CC.use_nrti   s
    }r4   c                     || _         d S r<   rF   r=   s     r2   rG   z
CC.use_nrtm       r4   c                     | j         S )z;
        The target CPU model for code generation.
        r,   r6   s    r2   
target_cpuzCC.target_cpuq   rB   r4   c                     || _         d S r<   rK   r=   s     r2   rL   zCC.target_cpux   rD   r4   c                     | j         S )zI
        Whether to display detailed information when compiling.
        r$   r6   s    r2   verbosez
CC.verbose|   s    
 }r4   c                     || _         d S r<   rO   r=   s     r2   rP   z
CC.verbose   rI   r4   c                      t          j                  \  }}t          j        |g|R   j        v rt          dz             fd}|S )zH
        Mark a function for exporting in the extension module.
        zduplicated export symbol %sc                 >    t          |           }|j        <   | S r<   )r
   r   )funcentryexported_namer-   sigs     r2   	decoratorzCC.export.<locals>.decorator   s&    sD99E6;D$]3Kr4   )r   normalize_signaturer   	signaturer   KeyError)r-   rV   rW   fn_argsfn_rettyrX   s   ```   r2   exportz	CC.export   s     %8==x2'222D4448MJKKK	 	 	 	 	 	 	
 r4   c                 T    t          | j                                        d           S )Nc                     | j         S r<   )symbol)rU   s    r2   <lambda>z$CC._export_entries.<locals>.<lambda>   s     r4   )key)sortedr   valuesr6   s    r2   _export_entrieszCC._export_entries   s0    d.5577446 6 6 	6r4   c                     t           j                            t                    | j        d d          }| j        r|                    d           fd|D             S )Nz../core/runtime/nrt.cppc                 P    g | ]"}t           j                            |          #S  )r%   r&   join).0r0   heres     r2   
<listcomp>z)CC._get_mixin_sources.<locals>.<listcomp>   s)    ===!T1%%===r4   )r%   r&   r'   r   _mixin_sourcesr+   append)r-   mixin_sourcesrl   s     @r2   _get_mixin_sourceszCC._get_mixin_sources   s`    wx((+AAA.= 	<  !:;;;====}====r4   c                 @    d| j         fdt          | j                  fgS )NPYCC_MODULE_NAMEPYCC_USE_NRT)r   intr+   r6   s    r2   _get_mixin_defineszCC._get_mixin_defines   s*      0S//0 	r4   c                     | j                             t          j        g           }|s%| j                             t          j        g           }|S r<   )_extra_cflagsr    r   platformr%   r7   )r-   extra_cflagss     r2   _get_extra_cflagszCC._get_extra_cflags   sD    )--clB?? 	?-11"'2>>Lr4   c                    | j                             t          j        g           }|s%| j                             t          j        g           }t          j                            d          rd|vr|                    d           |S )Nlinuxz-pthread)_extra_ldflagsr    r   ry   r%   r7   
startswithro   )r-   extra_ldflagss     r2   _get_extra_ldflagszCC._get_extra_ldflags   s|    +//bAA 	A /33BGR@@M<""7++ 	1..$$Z000r4   c                     |                                  }|                                 }| j                                        }|                                 }| j                            |||||          }|S )N)include_dirsmacrosrz   )rq   rv   r#   get_python_include_dirsr{   compile_objects)r-   	build_dirsourcesr   r   rz   objectss          r2   _compile_mixinszCC._compile_mixins   s|    ))++((**>>@@--// /11'9?K9??K 2 M M r4   c                    t          | j        | j        | j        | j                  }| j        |_        t          j        	                    |t          j        
                    | j                  d         dz             }t                              d| j        |           |                    |d           |g|j        fS )N)cpu_namer   z.oz%generating LLVM code for '%s' into %sT)wrap)r	   rf   r   r+   r,   r   external_init_functionr%   r&   rj   splitextr*   loginfowrite_native_objectdll_exports)r-   r   compilertemp_objs       r2   _compile_object_fileszCC._compile_object_files   s    !$"6 $8HJ J J*.*='7<<	 " 0 01B C CA F MO O8	* 	* 	*$$XD$999z8///r4   c                 
   | j         | j        _         t          j        d| j        z            }|                     |          \  }}||                     |          z  }|                                 }t          j	        
                    | j        | j                  }| j                                        }| j                                        }| j                            ||||||           t!          j        |           dS )z/
        Compile the extension module.
        zpycc-build-%s-)prefix)export_symbolsr   N)rP   r#   tempfilemkdtempr   r   r   r   r%   r&   rj   r(   r*   get_python_librariesget_python_library_dirslink_sharedshutilrmtree)r-   r   r   r   r   
output_dll	librarieslibrary_dirss           r2   compilez
CC.compile   s    
 #',$,<t~,MNNN	  $99)DD 	4''	222 //11W\\$"2D4EFF
O88::	>>@@##J$-|3>2? 	$ 	A 	A 	A
 	i     r4   c                 P   |                     dg           |                                 z   }|                     dg           | j        gz   }|                     dg           |                                 z   }|                     dg           |                                 z   }|                     dg           | j                                        z   }|                     dg           | j                                        z   }|                     dg           | j                                        z   }| j	        d| j	        
                    d	          d
z            }	t          d|	| j        z   |                                 |||||||d	|}
|
                                 | |
_        |
S )z`
        Create a distutils extension object that can be used in your
        setup.py.
        r   dependsextra_compile_argsextra_link_argsr   r   r   Nr   r   )	r7   r   r   define_macrosr   r   r   r   r   ri   )poprv   r!   r{   r   r#   r   r   r   r"   rfind_CCExtensionr   rq   monkey_patch_distutils_cc)r-   kwargsr   r   r   r   r   r   r   python_package_pathexts              r2   distutils_extensionzCC.distutils_extension   s   
 Hb))D,C,C,E,EE**Y++t/@.AA$jj)=rBB $ 6 6 8 89!::&7<<!44667

>266/AACCDZZR00;;==>	

>266/AACCD"12S43F3L3LS3Q3QRS3S2ST 	% 3dn D#'#:#:#<#<#*)/(4%.(4.@+:	% 	% $	% 	% 	""$$$
r4   r<   )r   
__module____qualname____doc__extension_libsrn   rx   r~   r3   propertyr7   r:   setterrA   rG   rL   rP   r^   rf   rq   rv   r{   r   r   r   r   r   r   ri   r4   r2   r   r      sD         &'>9N
M

N
   :   X ! ! X! " " "     X  ! ! !   X ^  ^     X  ! ! !   X ^  ^    6 6 X6> > >         	0 	0 	0 ! ! !2    r4   r   c                   6    e Zd ZdZdZdZd Zed             ZdS )r   zj
    A Numba-specific Extension subclass to LLVM-compile pure Python code
    to an extension module.
    NFc                    | j         }t                              t          j        j        |j        g| j                            d          d d         R             |	                    |j                  \  }}|| _
        d S )Nr   )r   dir_utilmkpathr%   r&   rj   
build_tempr7   splitr   extra_objects)r-   r   ccr   _s        r2   _prepare_object_filesz"_CCExtension._prepare_object_files  st    XY%9VDIOOC<P<PQTRTQT<UVVVWWW--i.BCC
$r4   c                 x    | j         rdS t          j         G fdd          }|t          _        d| _         dS )z}
        Monkey-patch distutils with our own build_ext class knowing
        about pycc-compiled extensions modules.
        Nc                       e Zd Z fdZdS ):_CCExtension.monkey_patch_distutils.<locals>._CC_build_extc                     t          |t                    r|                    |                                | |           d S r<   )
isinstancer   r   build_extension)r-   r   _orig_build_exts     r2   r   zJ_CCExtension.monkey_patch_distutils.<locals>._CC_build_ext.build_extension-  sE    c<00 4--d333//c:::::r4   N)r   r   r   r   )r   s   r2   _CC_build_extr   +  s.        ; ; ; ; ; ; ;r4   r   T)_distutils_monkey_patchedr   )clsr   r   s     @r2   r   z#_CCExtension.monkey_patch_distutils   si     ( 	F#-	; 	; 	; 	; 	; 	; 	;O 	; 	; 	; ,	(,%%%r4   )	r   r   r   r   r   r   r   classmethodr   ri   r4   r2   r   r     sU         
 C %% % % - - [- - -r4   r   )
setuptoolsr   dutilssetuptools.commandr   setuptools.extensionr   r%   r   r   r   
numba.corer   r   numba.core.compiler_lockr   numba.pycc.compilerr	   r
   numba.pycc.platformr   numbar   r   r   get_extension_libsr   objectr   r   ri   r4   r2   <module>r      sL   * * * * * * ( ( ( ( ( ( * * * * * * 				  



  ' ' ' ' ' ' ' ' 9 9 9 9 9 9 ; ; ; ; ; ; ; ; ) ) ) ) ) )       ?j((**w w w w w w w wt%- %- %- %- %-9 %- %- %- %- %-r4   