
    Ng                     (   d Z ddlmZ dZddlZddlZej        dk     rddlmZ	  G d de
          ZnddlZd(d
Z ej        d          Z ed          Z ed          Z ed          Z ed          Zeek    rd	Zn(ej                            edd                   d         Z edej                            dd	                    Z ed          dz   ej                            dd	          z   Z edej                            de                    Z ed          Z ed          Z ed          Z ej        d          Zd Zd Zd Zd)dZ d Z!d Z"d*d Z#d*d!Z$d+d#Z%d$ Z&d% Z'e(d&k    r e'ej)        d'd                    dS dS ),z
Compile a Python script into an executable that embeds CPython.
Requires CPython to be built as a shared library ('libpythonX.Y').

Basic usage:

    python -m Cython.Build.BuildExecutable [ARGS] somefile.py
    )absolute_importTN)   	   )	sysconfigc                   D    e Zd Zed             Z eej                  ZdS )r   c                 8    | dk    sJ t          j                    S )Ninclude)
_sysconfigget_python_inc)names    X/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Build/BuildExecutable.pyget_pathzsysconfig.get_path   s"    9$$$$,...    N)__name__
__module____qualname__staticmethodr   r
   get_config_var r   r   r   r      s;        		/ 	/ 
	/ &j&?@@r   r    c                 .    t          j        |           p|S N)r   r   )r   defaults     r   r   r       s    #D))4W4r   r	   LIBDIRLIBPLLIBRARY	LDLIBRARYr   CCCFLAGS LINKCCLINKFORSHAREDLIBSSYSLIBSEXEc                 j    t           r+|r| |z  } t          j                            | dz              d S d S )N
)DEBUGsysstderrwrite)msgargss     r   _debugr.   7   sE     % 	*C
t$$$$$% %r   c                     t          dt                     t          dt                     t          dt                     t          dt                     t          dt
                     t          dt                     t          dt                     t          dt                     t          d	t                     t          d
t                     t          dt                     t          dt                     d S )Nz
INCDIR: %szLIBDIR1: %szLIBDIR2: %sz	PYLIB: %szPYLIB_DYN: %szCC: %sz
CFLAGS: %sz
LINKCC: %szLINKFORSHARED: %szLIBS: %szSYSLIBS: %szEXE_EXT: %s)r.   INCDIRLIBDIR1LIBDIR2PYLIB	PYLIB_DYNr   r   r!   r"   r#   r$   EXE_EXTr   r   r   dump_configr6   >   s    
<   
='"""
='"""
;
?I&&&
8R
<   
<   
...
:t
='"""
='"""""r   c                    g }d }t          |           D ]]\  }}|                    d          r|                    |           n+|dv r|                    |           n|}| |dz   d          }  n|}^t          d          ||| fS )N-)z-Xz--directive   zno input file provided)	enumerate
startswithappend
ValueError)r-   cy_argslast_argiarg
input_files         r   _parse_argsrC   M   s    GHD// 3 33>># 	NN3...NN3J!:DE1222w$$r   c                     |r%d                     |           } t          |            n"t          d                     |                      dd l}|                    | |          }|rt	          j        |           d S d S )Nr    r   shell)joinr.   
subprocesscallr)   exit)cmdrF   rH   
returncodes       r   runcmdrM   `   s     hhsmmssxx}}E22J  r   c           	         t          t          d| t          z   | dz   dt          z   dt          z   gt
          r
dt
          z   p)t          j                            t          t                    gz   t                                          z   t                                          z   t                                          z              d S )N-o.oz-Lz-l)rM   r!   r5   r1   r2   r4   ospathrG   r3   r#   splitr$   r"   basenames    r   clinkrV   n   s    
FD(W,htmT'\4PW<X,T)^LWe0L0LMNZZ\\#MMOO,.;.A.A.C.CD E E E E Er   c           	          t          t          dd| dz   | dz   dt          z   gt                                          z              d S )Nz-crO   rP   z.cz-I)rM   r   r0   r   rS   rT   s    r   ccompilerX   t   s<    
BdHTM8D=$-H6<<>>YZZZZZr   r   c                    ddl m}m}m} |                    t          |pd          d| gz             \  }}t          d|j        |            |                    ||          }|j	        dk    rt          j        d           d S d S )N   )VersionCmdLineMainr   z--embedzUsing Cython %s to compile %sr   r9   )Compilerr[   r\   r]   parse_command_linelistr.   versioncompile
num_errorsr)   rJ   )rB   optionsr[   r\   r]   sourcesresults          r   	cycompilerg   x   s    111111111111$w}"2E2ET^H_2_``GW
*GOZHHH\\'7++F1 r   c                     t          t          j                            |           gt	          |          z   d           d S )NFrE   )rM   rQ   rR   abspathr`   )program_namer-   s     r   	exec_filerk      s7    
BGOOL))*T$ZZ7uEEEEEEr   Fc                    t           j                            |           d         }|t          z   }|sOt           j                            |          t           j                            |           k    rt          d          |st           j                            |          rqt           j                            |           rRt           j                            |           t           j                            |          k    rt          d|           |S t          | |           t          |           t          |           |S )zi
    Build an executable program from a Cython module.

    Returns the name of the executable file.
    r   z?Input and output file names are the same, refusing to overwritez'File is up to date, not regenerating %s)rQ   rR   splitextr5   ri   r=   existsgetmtimer.   rg   rX   rV   )rB   compiler_argsforcerU   exe_files        r   buildrs      s    w
++A.H'!H \RW__X.."'//*2M2MMMZ[[[ bgnnX.. 27>>*3M3M   ,,0@0@0J0JJJ8(CCCj-(((X	(OOOOr   c                 J    t          |           \  }} t          ||            dS )z
    Build an executable program from a Cython module and run it.

    Arguments after the module name will be passed verbatimly to the program.
    N)_buildrk   )r-   rj   s     r   build_and_runrv      s*      L$lD!!!!!r   c                 P    t          |           \  }}} t          ||          }|| fS r   )rC   rs   )r-   rB   r>   rj   s       r   ru   ru      s0     +D 1 1JW--Lr   __main__r9   )r   )T)r   )r   F)*__doc__
__future__r   r(   r)   rQ   version_info	distutilsr   r
   objectr   r   r0   r1   r2   r3   r4   rR   rm   environgetr   r   r!   r"   r#   r$   r5   r.   r6   rC   rM   rV   rX   rg   rk   rs   rv   ru   r   argvr   r   r   <module>r      s    ' & & & & & 



 				f111111A A A A AF A A A A 5 5 5 5 
	I	&	&
.
"
"
.
!
!y!!N;''	II  122//2I^D"*..r2233		!	!C	'"*..2*F*F	F	"*..2">">	?	?//~f
.
#
#
")
"5
)
)% % %# # #% % %&   E E E[ [ [   F F F F   (" " "   z
F38ABB< r   