σ
¦V]c           @@  s;  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l m Z d d l m Z m	 Z	 d d l
 m Z d d l m Z y& d  d l Z e e j   d	  Z Wn e k
 rΏ d Z d  Z n Xd
 e f d     YZ d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z e d k r7e   n  d S(   i    (   t   absolute_importN(   t   setupi   (   t	   cythonizet   extended_iglobi   (   t   is_package_dir(   t   Optionsg      ψ?t	   _FakePoolc           B@  s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C@  sL   y d d l  m } Wn t k
 r- t } n Xx | | |  D] } q> Wd  S(   Ni    (   t   imap(   t	   itertoolsR   t   ImportErrort   map(   t   selft   funct   argsR   t   _(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt	   map_async   s    
c         C@  s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   close   s    c         C@  s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt	   terminate"   s    c         C@  s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   join%   s    (   t   __name__t
   __module__R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyR      s   			c         C@  s\   |  j  } t t | j | t j     } t j | d t d | } t | j | |  d  S(   Nt   relaxed_boolt   current_settings(	   t   destt   dictt   getattrt   valuesR   t   get_directive_defaultst   parse_directive_listt   Truet   setattr(   t   optiont   namet   valuet   parserR   t   old_directivest
   directives(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   parse_directives)   s    	c   	      C@  s₯   |  j  } t t | j | i    } xg | j d  D]V } d | k rs | j d d  \ } } | j   d k } n | t } } | | | <q4 Wt | j | |  d  S(	   Nt   ,t   =i   t   falset   ft   0t   no(   R(   R)   R*   R+   (   R   R   R   R   t   splitt   lowerR   R   (	   R   R    R!   R"   R   t   optionst   optt   nt   v(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   parse_options2   s    	c         C@  sP   |  j  } t t | j | i    } t j | d | } t | j | |  d  S(   NR   (   R   R   R   R   R   t   parse_compile_time_envR   (   R   R    R!   R"   R   t   old_envt   new_env(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyR3   ?   s    	c         C@  sr   t  j j |   \ } } xM t  j j t  j j | d   rg t  j j |  \ } } d | | f } q W| | f S(   Ns   __init__.pys   %s/%s(   t   ost   pathR,   t   isfileR   (   R7   t   base_dirt   package_patht   parent(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   find_package_baseF   s
    $c   	      C@  s  d  } t t j j t |    } y£x| D]} | j r{ | } x> t j j |  sb t |  rw t j j	 |  } qC Wn d  } t j j |  r± t j j
 | d d  g } n	 | g } t | d | j d | j d | j d | j d | j d | j d	 | j | j } | r+ | j r+ t |  d
 k r¬| j d
 k r¬| d  k r}y t j | j  } Wq}t k
 ryt   } q}Xn  | j t g  | D] } | | g f ^ q qΏt | | f  q+ q+ WWn# | d  k	 rγ| j   n    n$ X| d  k	 r| j   | j
   n  d  S(   Ns   **s
   *.{py,pyx}t   nthreadst   exclude_failurest   excludet   compiler_directivest   compile_time_envt   forcet   quieti   (   t   NoneR
   R6   R7   t   abspathR   t   build_inplacet   isdirR   t   dirnameR   R   t   parallelt
   keep_goingt   excludesR$   RA   RB   RC   R.   t   buildt   lent   multiprocessingt   Poolt   OSErrorR   R   t   run_distutilsR   R   (	   t   path_patternR.   t   poolt	   all_pathsR7   R9   t   pathst   ext_modulest   ext(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   cython_compileN   sN    	"							!	&
c         C@  sΘ   |  \ } } d d g } t  j   } d  } zX | rh t  j |  t j d |  } | j d | g  n  t d d d | d |  Wd  | rΓ t  j |  | rΓ t  j j	 |  rΓ t
 j |  qΓ n  Xd  S(	   Nt	   build_exts   -it   dirs   --build-tempt   script_names   setup.pyt   script_argsRV   (   R6   t   getcwdRD   t   chdirt   tempfilet   mkdtempt   extendR   R7   RG   t   shutilt   rmtree(   R   R9   RV   R\   t   cwdt   temp_dir(    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyRQ      s"    c         C@  s&  d d l  m } | d d  } | j d d d d d	 d
 d i  d d d d d t d d | j d d d d d	 d d i  d d d d d t d d | j d d d d d	 d d i  d d d d d t d d | j d d	 d d d d d d d  d d  | j d! d	 d d d d d" d d# | j d$ d	 d d d d d% d d# | j d& d' d	 d( d d) d d* | j d+ d, d d- d	 d. d d/ d g  d d0 | j d1 d2 d	 d3 d d) d d4 | j d5 d6 d	 d7 d d) d d8 | j d9 d: d	 d; d d< d t d t d d= t p
d> | j d? d@ d	 dA d d) d dB | j dC dD d	 dE d d) d dF | j dG d	 dH d d) d dI | j dJ dK d	 dL d d) d dM | j	 |   \ } }  |  sΎ| j
 dN  n  | j rΣt | _ n  t d  k rλd | _ n  | j r| j dO k s	t  | j | j d <n  | |  f S(P   Ni    (   t   OptionParsert   usages'   %prog [options] [sources and packages]+s   -Xs   --directivet   metavars   NAME=VALUE,...R   R$   t   defaultt   typet   strt   actiont   callbackt   helps   set a compiler directives   -Es   --compile-time-envRA   s'   set a compile time environment variables   -ss   --options
   NAME=VALUER.   s   set a cythonize options   -2t   language_levelt   store_constt   consti   s#   use Python 2 syntax mode by defaults   -3i   s#   use Python 3 syntax mode by defaults   --3strt   3strs   -as
   --annotatet   annotatet
   store_trues-   generate annotated HTML page for source filess   -xs	   --excludet   PATTERNRK   t   appends2   exclude certain file patterns from the compilations   -bs   --buildRL   s'   build extension modules using distutilss   -is	   --inplaceRF   s=   build extension modules in place using distutils (implies -b)s   -js
   --parallelRI   t   Ns+   run builds in N parallel jobs (default: %d)i   s   -fs   --forceRB   s   force recompilations   -qs   --quietRC   s"   be less verbose during compilations	   --lenientt   lenientsB   increase Python compatibility by ignoring some compile time errorss   -ks   --keep-goingRJ   s8   compile as much as possible, ignore compilation failuress   no source files provided(   i   i   Rr   (   t   optparseRf   t
   add_optionR%   R3   R2   RD   t   intt   parallel_compilest
   parse_argst   errorRF   R   RL   RN   RI   Ro   t   AssertionErrorR.   (   R   Rf   R"   R.   (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyR}      sh    $		c         C@  sg   t  |   \ } } | j r0 t t _ t t _ n  | j rE t t _ n  x | D] } t | |  qL Wd  S(   N(	   R}   Rx   t   FalseR   t   error_on_unknown_namest   error_on_uninitializedRs   R   RX   (   R   R.   RU   R7   (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   mainΣ   s    			t   __main__(   t
   __future__R    R6   Rb   R_   t   distutils.coreR   t   DependenciesR   R   t   UtilsR   t   CompilerR   RN   R{   t	   cpu_countR|   R	   RD   t   objectR   R%   R2   R3   R<   RX   RQ   R}   R   R   (    (    (    s5   lib/python2.7/site-packages/Cython/Build/Cythonize.pyt   <module>   s0   
						3		<