
    -Ph                        d Z dZddlZddlZej        dk     rddlmZ  G d d          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
T    N)   	   )	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    \/var/www/html/test/jupyter/venv/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-   6   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_configr5   =   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_argsrB   L   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)cmdrE   rG   
returncodes       r   runcmdrL   _   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)rL   r    r4   r0   r1   r3   ospathrF   r2   r"   splitr#   r!   basenames    r   clinkrU   m   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-crN   rO   z.cz-I)rL   r   r/   r   rR   rS   s    r   ccompilerW   s   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   r8   )CompilerrZ   r[   r\   parse_command_linelistr-   versioncompile
num_errorsr(   rI   )rA   optionsrZ   r[   r\   sourcesresults          r   	cycompilerf   w   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 )NFrD   )rL   rP   rQ   abspathr_   )program_namer,   s     r   	exec_filerj      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)rP   rQ   splitextr4   rh   r<   existsgetmtimer-   rf   rW   rU   )rA   compiler_argsforcerT   exe_files        r   buildrr      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)_buildrj   )r,   ri   s     r   build_and_runru      s*      L$lD!!!!!r   c                 P    t          |           \  }}} t          ||          }|| fS r   )rB   rr   )r,   rA   r=   ri   s       r   rt   rt      s0     +D 1 1JW--Lr   __main__r8   )r   )T)r   )r   F)'__doc__r'   r(   rP   version_info	distutilsr   r	   r   r   r/   r0   r1   r2   r3   rQ   rl   environgetr   r   r    r!   r"   r#   r4   r-   r5   rB   rL   rU   rW   rf   rj   rr   ru   rt   r   argvr   r   r   <module>r~      s    	 



 				f111111A A A A A 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   