σ
ΤΌYc           @@  sΡ  d  Z  d d l m Z e Z d d l Z d d l Z d d l m Z d d  Z	 e j
   Z e	 d  Z e	 d  Z e	 d	  Z e	 d
  Z e e k r‘ d Z n e j j e d  d Z e	 d e j j d d   Z e	 d  d e j j d d  Z e	 d e j j d e   Z e	 d  Z e	 d  Z e	 d  Z e j	 d  Z d   Z d   Z e d  Z d   Z d   Z d d  Z  d  d  Z! d! e" d  Z# d   Z$ e% d k rΝe$ e j& d  n  d S("   sΖ   
Compile a Python script into an executable that embeds CPython and run it.
Requires CPython to be built as a shared library ('libpythonX.Y').

Basic usage:

    python cythonrun somefile.py [ARGS]
i    (   t   absolute_importN(   t	   sysconfigt    c         C@  s   t  j |   p | S(   N(   R   t   get_config_var(   t   namet   default(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyR      s    t   LIBDIRt   LIBPLt   LIBRARYt	   LDLIBRARYi   t   CCt   CFLAGSt    t   LINKCCt   LINKFORSHAREDt   LIBSt   SYSLIBSt   EXEc         G@  s4   t  r0 | r |  | }  n  t j j |  d  n  d  S(   Ns   
(   t   DEBUGt   syst   stderrt   write(   t   msgt   args(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   _debug)   s    c           C@  s    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(   Ns
   INCDIR: %ss   LIBDIR1: %ss   LIBDIR2: %ss	   PYLIB: %ss   PYLIB_DYN: %ss   CC: %ss
   CFLAGS: %ss
   LINKCC: %ss   LINKFORSHARED: %ss   LIBS: %ss   SYSLIBS: %ss   EXE_EXT: %s(   R   t   INCDIRt   LIBDIR1t   LIBDIR2t   PYLIBt	   PYLIB_DYNR
   R   R   R   R   R   t   EXE_EXT(    (    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   dump_config/   s    c         C@  s   | r" d j  |   }  t |   n t d j  |    y d d  l } Wn  t k
 rg t j |   } n X| j |  d | } | r t j |  n  d  S(   NR   i    t   shell(	   t   joinR   t
   subprocesst   ImportErrort   ost   systemt   callR   t   exit(   t   cmdR    R"   t
   returncode(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   runcmd=   s    c         C@  st   t  t d |  t |  d d t d t g t r8 d t pJ t j j t t	  g t
 j   t j   t j    d  S(   Ns   -os   .os   -Ls   -l(   R*   R   R   R   R   R   R$   t   pathR!   R   R   t   splitR   R   (   t   basename(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   clinkN   s    c         C@  s6   t  t d d |  d |  d d t g t j    d  S(   Ns   -cs   -os   .os   .cs   -I(   R*   R
   R   R   R,   (   R-   (    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   ccompileS   s    c         C@  s   d d l  m } m } m } | j t | p. d  d |  g  \ } } t d | j |   | j | |  } | j	 d k r t
 j d  n  d  S(   Ni   (   t   Versiont   CmdLinet   Mains   --embeds   Using Cython %s to compile %si    i   (    (   t   CompilerR0   R1   R2   t   parse_command_linet   listR   t   versiont   compilet
   num_errorsR   R'   (   t
   input_filet   optionsR0   R1   R2   t   sourcest   result(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt	   cycompileV   s    +c         C@  s-   t  t j j |   g t |  d t d  S(   NR    (   R*   R$   R+   t   abspathR5   t   False(   t   program_nameR   (    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt	   exec_file^   s    c         C@  sί   t  j j |   d } | t } | rZ t  j j |  t  j j |   k rZ t d   n  | rΊ t  j j |  rΊ t  j j |   rΊ t  j j |   t  j j |  k rΊ t d |  | St	 |  |  t
 |  t |  | S(   si   
    Build an executable program from a Cython module.

    Returns the name of the executable file.
    i    s?   Input and output file names are the same, refusing to overwrites'   File is up to date, not regenerating %s(   R$   R+   t   splitextR   R>   t
   ValueErrort   existst   getmtimeR   R=   R/   R.   (   R9   t   compiler_argst   forceR-   t   exe_file(    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   builda   s    
++$

c         C@  s«   g  } d } x| t |   D]b \ } } | j d  rD | j |  n1 | d k r` | j |  n | } |  | d }  P| } q Wt d   t | |  } t | |   d S(   s   
    Build an executable program from a Cython module and runs it.

    Arguments after the module name will be passed verbatimely to the
    program.
    t   -s   -Xs   --directivei   s   no input file providedN(   s   -Xs   --directive(   t   Nonet	   enumeratet
   startswitht   appendRC   RI   RA   (   R   t   cy_argst   last_argt   it   argR9   R@   (    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   build_and_runt   s    
t   __main__i   (    (    (    ('   t   __doc__t
   __future__R    t   TrueR   R   R$   t	   distutilsR   R   t   get_python_incR   R   R   R   R   R+   RB   t   environt   getR
   R   R   R   R   R   R   R   R   R*   R.   R/   R=   RA   R?   RI   RS   t   __name__t   argv(    (    (    sl   /home/psgendb/BIRCHDEV/lib-linux-x86_64/python/lib64/python2.7/site-packages/Cython/Build/BuildExecutable.pyt   <module>   s@   	#					