ó
¦V]c           @   så   d  Z  d d l Z d d l Z d d l m Z m Z m Z d d l m Z d d l	 m
 Z
 y d d l m Z e Z Wn e k
 r e Z n Xd Z i  a d d e d d e e d „ Z e d	 k rá e d
 ƒ d d l m Z n  d S(   s’   Build a Pyrex file from .pyx source to .so loadable module using
the installed distutils infrastructure. Call:

out_fname = pyx_to_dll("foo.pyx")
iÿÿÿÿN(   t   DistutilsArgErrort   DistutilsErrort   CCompilerError(   t	   Extension(   t   grok_environment_error(   t   old_build_exti    c   $      C   sm  t  j j |  ƒ s. t d t  j j |  ƒ ƒ ‚ t  j j t  j j |  ƒ ƒ \ } }	 | sÁ t  j j |	 ƒ \ }
 } | d" k sˆ t | ƒ ‚ t s¦ |  t | ƒ  d }  n  t	 d |
 d |  g ƒ } n  | d
 k rÖ i  } n  | sô t  j j | d ƒ } n  | } xU | j j d ƒ d	 d
 d … D]4 } t  j j | ƒ \ } } | | k rd
 } PqqW| j d g  ƒ } t svd | k rd } n d } | d g } | r§| j d ƒ n  | r.| r.| j d | g ƒ | j d k sç| j j d ƒ r.t | d ƒ s	i d d 6| _ q+d | j k r+d | j d <q+q.n  t rJ| rJ| j d ƒ n  | j ƒ  } | j i d
 d 6| | d 6ƒ d d l m } | | ƒ } | j s¦g  | _ n  | j j | ƒ t rÏi t d 6| _ n  | j d ƒ } | | _ | j ƒ  } | j | ƒ y | j ƒ  } Wn t  k
 r&‚  n Xt r?d GH| j! ƒ  n  | sKt ‚ y¨| j d ƒ } | j" ƒ  | j# ƒ  d } | j$ r°t  j j t  j j% |  ƒ t  j j& | ƒ ƒ } n  | rî| } t  j j' | ƒ } t( j | d# ƒ \ } } } | | k rþ| } qît  j j& | ƒ } xÅ | d k  rÇ| d 7} t  j j | j) | d | ƒ }  yc d d
 l* }! y& t  j j+ |  ƒ r}t  j, |  ƒ n  Wn t- k
 r”wn X|! j. | |  ƒ |  } Wn t/ k
 rÂqn XPqWt0 d  | ƒ ‚ | | | f t( | <n  | SWns t1 k
 rt2 j3 d ƒ nV t/ t  j4 f k
 rht2 j5 ƒ  d }" t6 |" ƒ }# t rbt2 j7 j8 |# d! ƒ n  ‚  n Xd
 S($   sU   Compile a PYX file to a DLL and return the name of the generated .so
       or .dll .s   Could not find %ss   .pyxs   .pys   .ct   namet   sourcest   _pyxbldt   .iþÿÿÿNiÿÿÿÿt   script_argss	   --verboses   --quiett	   build_exts   --forces   --build-libt   __init__s	   .__init__t   cython_directivest
   SOURCEFILEt   set_initial_paths   --pyrex-c-in-tempt   script_name(   t   Distributiont   builds%   options (after parsing command line):i    id   i   s	   .reload%ss#   reload count for %s reached maximums   
(   s   .pyxs   .py(   NNi    (9   t   ost   patht   existst   AssertionErrort   abspatht   splitt   splitextt
   HAS_CYTHONt   lenR   t   Nonet   joinR   t   gett   DEBUGt   appendt   extendt   endswitht   hasattrR   t   copyt   updatet   distutils.distR   t   ext_modulesR   t   cmdclasst   get_command_objt
   build_baset   find_config_filest   parse_config_filest   parse_command_lineR    t   dump_option_dictst   run_commandst   get_outputst   inplacet   dirnamet   basenamet   getmtimet   _reloadst	   build_libt   shutilt   isfilet   unlinkt   OSErrort   copy2t   IOErrort   ImportErrort   KeyboardInterruptt   syst   exitt   errort   exc_infoR   t   stderrt   write($   t   filenamet   extt   force_rebuildt   build_in_tempt   pyxbuild_dirt
   setup_argst   reload_supportR1   R   R   t   modnamet	   extensiont   package_base_dirt   package_namet   pnameR
   t   quiett   argst   sargsR   t   distR   t   cfgfilest   okt   obj_build_extt   so_patht   org_patht	   timestampt   last_timestampt	   last_patht   countR3   t   r_pathR7   t   excRA   (    (    s1   lib/python2.7/site-packages/pyximport/pyxbuild.pyt
   pyx_to_dll   sÄ    .$	&	!			
		

t   __main__s	   dummy.pyxi   (   t   test(   t   __doc__R   R?   t   distutils.errorsR    R   R   t   distutils.extensionR   t   distutils.utilR   t   Cython.Distutils.old_build_extR   R   t   TrueR   R=   t   FalseR   R5   R   R`   t   __name__t    Rb   (    (    (    s1   lib/python2.7/site-packages/pyximport/pyxbuild.pyt   <module>   s"   

…
