3
hf&                 @   s   d dl mZmZ d dlZd dlZd dl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W n ek
r   dZd ZY nX G d	d
 d
eZdd Zdd Zdd Zdd Zdd Zdd Zdd ZdddZedkre  dS )    )absolute_importprint_functionN   )	cythonizeextended_iglob   )is_package_dir)Optionsg      ?c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
	_FakePoolc             C   sB   yddl m} W n tk
r(   t}Y nX x|||D ]}q6W d S )Nr   )imap)	itertoolsr   ImportErrormap)selffuncargsr   _ r   h/var/www/html/CrowdFlow/Picklecon/ble_analysis_env/lib/python3.6/site-packages/Cython/Build/Cythonize.py	map_async   s    
z_FakePool.map_asyncc             C   s   d S )Nr   )r   r   r   r   close   s    z_FakePool.closec             C   s   d S )Nr   )r   r   r   r   	terminate   s    z_FakePool.terminatec             C   s   d S )Nr   )r   r   r   r   join"   s    z_FakePool.joinN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r
      s   r
   c             C   sB   t jj| \}}x(t|r8t jj|\}}d||f }qW ||fS )Nz%s/%s)ospathsplitr   )r   base_dirZpackage_pathparentr   r   r   find_package_base&   s
    
r!   c             C   s    t tjjt| }t|| d S )N)r   r   r   abspathr   _cython_compile_files)path_patternoptions	all_pathsr   r   r   cython_compile-   s    r'   c                st  d }y.x&| D ]}|j rJ| x,tjj  s8t rFtjj  q"W nd  tjj|rntjj|ddg}n|g}t|f|j|j	|j
|j|j|j|j|j|jd	|j}|o|jrt|dko|jdkr"|d krytj|j}W n tk
r   t }Y nX |jt fdd|D  qt |f qW W n    |d k	rN|j   Y nX |d k	rp|j  |j  d S )Nz**z
*.{py,pyx})	ZnthreadsZexclude_failuresexcludeZcompiler_directivescompile_time_envforcequietdepfilelanguager   c                s   g | ]} |gfqS r   r   ).0ext)r   r   r   
<listcomp>X   s    z)_cython_compile_files.<locals>.<listcomp>)build_inplacer   r   isdirr   dirnamer   r   parallel
keep_goingexcludes
directivesr)   r*   r+   r,   r-   r%   buildlenmultiprocessingPoolOSErrorr
   r   run_distutilsr   r   )r&   r%   poolr   pathsext_modulesr   )r   r   r#   1   sP    




r#   c             C   s   yddl m} W nB tk
rR   yddlm} W n tk
rL   tdY nX Y nX | \}}ddg}tj }d }z:|rtj| tj|d}|j	d|g |d||d	 W d |rtj| |rtj
j|rtj| X d S )
Nr   )setupzL'distutils' is not available. Please install 'setuptools' for binary builds.	build_extz-i)dirz--build-tempzsetup.py)script_namescript_argsr@   )distutils.corerA   r   
setuptoolsr   getcwdchdirtempfilemkdtempextendr   r2   shutilrmtree)r   rA   r   r@   rE   cwdtemp_dirr   r   r   r=   e   s0    

r=   c           
   C   s  ddl m} m} ddlm}m}m} | |dd}|jddd	d
i t|dd |jddd	di t|dd |jddddi t|dd |jddddd dd |jdddddd |jdddd dd |jd!d"d#dd$d d%d |jd&d'dd(d)d*d+ |jd,dd-d)d.d+ |jd/d0d1d2d3g d4d5 |jd6d7d8d9d d:d; |jd<d=d>d9d d?d; |jd@dAdBdCt	t
dDt
 p^dEdF |jdGdHdId9d dJd; |jdKdLdMd9d dNd; |jdOdPd9d dQd; |jdRdSdTd9d dUd; |jdVdWd9d dXd; |jdYdZd9d[d\ |jd]d^d_ |S )`Nr   )ArgumentParserRawDescriptionHelpFormatterr   )ParseDirectivesActionParseOptionsActionParseCompileTimeEnvActionaa  Environment variables:
  CYTHON_FORCE_REGEN: if set to 1, forces cythonize to regenerate the output files regardless
        of modification times and changes.
  Environment variables accepted by setuptools are supported to configure the C compiler and build:
  https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#compiler-and-linker-options)formatter_classepilogz-Xz--directivezNAME=VALUE,...r7   zset a compiler directive)metavardestdefaulttypeactionhelpz-Ez--compile-time-envr)   z'set a compile time environment variablez-sz--optionz
NAME=VALUEr%   zset a cythonize optionz-2language_levelstore_constz#use Python 2 syntax mode by default)rY   r\   constrZ   r]   z-3   z#use Python 3 syntax mode by default)rY   r\   r`   r]   z--3str3strz-+z--cplusr-   zc++zCompile as C++ rather than Cz-az
--annotaterZ   annotatez/Produce a colorized HTML version of the source.)r\   r`   rY   r]   z--annotate-fullcZfullczZProduce a colorized HTML version of the source which includes entire generated C/C++-code.z-xz	--excludeZPATTERNr6   appendz2exclude certain file patterns from the compilation)rX   rY   r\   rZ   r]   z-bz--buildr8   
store_truez2build extension modules using distutils/setuptools)rY   r\   rZ   r]   z-iz	--inplacer1   zHbuild extension modules in place using distutils/setuptools (implies -b)z-jz
--parallelr4   Nz+run builds in N parallel jobs (default: %d)r   )rY   rX   r[   rZ   r]   z-fz--forcer*   zforce recompilationz-qz--quietr+   z"be less verbose during compilationz	--lenientlenientzBincrease Python compatibility by ignoring some compile time errorsz-kz--keep-goingr5   z8compile as much as possible, ignore compilation failuresz--no-docstringsno_docstringszstrip docstringsz-Mz	--depfilez produce depfiles for the sources)r\   r]   sources*)nargs)argparserQ   rR   ZCompiler.CmdLinerS   rT   rU   add_argumentstrintparallel_compiles)rQ   rR   rS   rT   rU   parserr   r   r   create_args_parser   sj    


rr   c             C   sR   | j |\}}|j}x0|D ](}|jdr8| jd|  q|j| qW |`||fS )N-zunknown option )parse_known_argsri   
startswitherrorrd   )rq   r   r%   unknownri   optionr   r   r   parse_args_raw   s    

ry   c             C   s   t  }t|| \}} | s"|jd |jr.d|_td kr<d|_|jr\|jd	ksPt|j|j	d< |j
rndt_dt_|jr||jt_|jrdt_|| fS )
Nzno source files providedTr   r   ra   rb   r^   F)r   ra   rb   )rr   ry   rv   r1   r8   r:   r4   r^   AssertionErrorr%   rg   r	   Zerror_on_unknown_namesZerror_on_uninitializedrc   rh   Z
docstrings)r   rq   r%   r   r   r   
parse_args   s&    
r{   c             C   sz   t | \}}g }xZ|D ]R}dd t|D }|s^dd l}tdj|jd ||jd |jd |j| qW t	|| d S )Nc             S   s   g | ]}t jj|qS r   )r   r   r"   )r.   pr   r   r   r0      s    zmain.<locals>.<listcomp>r   z#{}: No such file or directory: '{}')filer   )
r{   r   sysprintformatargvstderrexitrL   r#   )r   r%   r?   r&   r   Zexpanded_pathr~   r   r   r   main   s    

r   __main__)N)
__future__r   r   r   rM   rJ   ZDependenciesr   r   ZUtilsr   ZCompilerr	   r:   ro   	cpu_countrp   r   objectr
   r!   r'   r#   r=   rr   ry   r{   r   r   r   r   r   r   <module>   s.   
4C
