o
    e%                     @   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 ddlm	Z	m
Z
 ddlmZ ddlmZ zd dlZee d	 ZW n eyI   dZd ZY nw 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r|e  dS dS )    )absolute_importprint_functionN)setup   )	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   s<   zddl m} W n ty   t}Y nw |||D ]}qd S )Nr   )imap)	itertoolsr   ImportErrormap)selffuncargsr   _ r   FD:\Projects\ConvertPro\env\Lib\site-packages\Cython/Build/Cythonize.py	map_async   s   z_FakePool.map_asyncc                 C      d S Nr   r   r   r   r   close      z_FakePool.closec                 C   r   r   r   r   r   r   r   	terminate    r   z_FakePool.terminatec                 C   r   r   r   r   r   r   r   join#   r   z_FakePool.joinN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s
    r   c                 C   sD   t j| \}}t|rt j|\}}d||f }t|s||fS )Nz%s/%s)ospathsplitr	   )r"   base_dirpackage_pathparentr   r   r   find_package_base'   s   r'   c                 C   s    t tjjt| }t|| d S r   )r   r!   r"   abspathr   _cython_compile_files)path_patternoptions	all_pathsr   r   r   cython_compile.   s   r-   c                    sd  d }z| D ]}|j r'| tj rt r&tj  tj rt snd  tj|r9tj|ddg}n|g}t|f|j|j	|j
|j|j|j|j|jd|j}|r|jrt|dkr|jdkr|d u rzt|j}W n ty~   t }Y nw |t fdd|D  qt |f qW n   |d ur|   |d ur|  |  d S d S )Nz**z
*.{py,pyx})ZnthreadsZexclude_failuresexcludeZcompiler_directivescompile_time_envforcequietdepfiler   c                    s   g | ]} |gfqS r   r   ).0extr$   r   r   
<listcomp>W   s    
z)_cython_compile_files.<locals>.<listcomp>)build_inplacer!   r"   isdirr	   dirnamer   r   parallel
keep_goingexcludes
directivesr/   r0   r1   r2   r+   buildlenmultiprocessingZPoolOSErrorr   r   run_distutilsr   r   )r,   r+   poolr"   pathsext_modulesr   r5   r   r)   2   sb   



&r)   c              	   C   s   | \}}ddg}t  }d }z8|r#t | tj|d}|d|g td||d W |rAt | |rCt j|rEt	
| d S d S d S d S |r\t | |r]t j|r^t	
| w w w w )NZ	build_ext-i)dirz--build-tempzsetup.py)script_namescript_argsrE   )r!   getcwdchdirtempfilemkdtempextendr   r"   r8   shutilrmtree)r   r$   rE   rI   cwdtemp_dirr   r   r   rB   e   s4   


rB   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& |jd'dd(d$d)d& |jd*d+d,d-d.g d/d0 |jd1d2d3d4d d5d6 |jd7d8d9d4d d:d6 |jd;d<d=d>t	t
d?t
 pd@dA |jdBdCdDd4d dEd6 |jdFdGdHd4d dId6 |jdJdKd4d dLd6 |jdMdNdOd4d dPd6 |jdQdRd4d dSd6 |jdTdUd4dVdW |jdXdYdZ |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)Zformatter_classepilogz-Xz--directivezNAME=VALUE,...r=   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)rZ   r]   constr[   r^   z-3   z#use Python 3 syntax mode by default)rZ   r]   ra   r^   z--3str3strz-az
--annotater[   annotatez/Produce a colorized HTML version of the source.)r]   ra   rZ   r^   z--annotate-fullcZfullczZProduce a colorized HTML version of the source which includes entire generated C/C++-code.z-xz	--excludeZPATTERNr<   appendz2exclude certain file patterns from the compilation)rY   rZ   r]   r[   r^   z-bz--buildr>   
store_truez'build extension modules using distutils)rZ   r]   r[   r^   rF   z	--inplacer7   z=build extension modules in place using distutils (implies -b)z-jz
--parallelr:   Nz+run builds in N parallel jobs (default: %d)r   )rZ   rY   r\   r[   r^   z-fz--forcer0   zforce recompilationz-qz--quietr1   z"be less verbose during compilationz	--lenientlenientzBincrease Python compatibility by ignoring some compile time errorsz-kz--keep-goingr;   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)argparserS   rT   ZCompiler.CmdLinerU   rV   rW   add_argumentstrintparallel_compiles)rS   rT   rU   rV   rW   parserr   r   r   create_args_parser{   s   



rs   c                 C   sN   |  |\}}|j}|D ]}|dr| d|  q|| q|`||fS )N-zunknown option )Zparse_known_argsrj   
startswitherrorre   )rr   r   r+   unknownrj   optionr   r   r   parse_args_raw   s   
ry   c                 C   s   t  }t|| \}} | s|d |jrd|_td u rd|_|jr.|jdv s(J |j|jd< |j	r7dt
_dt
_|jr>|jt
_|jrDdt
_|| fS )Nzno source files providedTr   )r   rb   rc   r_   F)rs   ry   rv   r7   r>   r@   r:   r_   r+   rh   r
   Zerror_on_unknown_namesZerror_on_uninitializedrd   ri   Z
docstrings)r   rr   r+   r   r   r   
parse_args   s&   
rz   c                 C   sv   t | \}}g }|D ])}dd t|D }|s.dd l}td|jd ||jd |d || q
t	|| d S )Nc                 S   s   g | ]}t j|qS r   )r!   r"   r(   )r3   pr   r   r   r6      s    zmain.<locals>.<listcomp>r   z#{}: No such file or directory: '{}')filer   )
rz   r   sysprintformatargvstderrexitrN   r)   )r   r+   rD   r,   r"   Zexpanded_pathr}   r   r   r   main   s   
r   __main__r   )
__future__r   r   r!   rO   rL   Zdistutils.corer   ZDependenciesr   r   ZUtilsr	   ZCompilerr
   r@   rp   	cpu_countrq   r   objectr   r'   r-   r)   rB   rs   ry   rz   r   r   r   r   r   r   <module>   s6    3A

