o
    ff&                     @   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 zd dlZee d ZW n eyC   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rve  dS 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   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   R/var/www/html/mig_web/myenv/lib/python3.10/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                    sh  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|jd	|j}|r|jrt|dkr|jdkr|d u rz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})	nthreadsexclude_failuresexcludecompiler_directivescompile_time_envforcequietdepfilelanguager   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
directivesr1   r2   r3   r4   r5   r*   buildlenmultiprocessingPoolOSErrorr
   r   run_distutilsr   r   )r+   r*   poolr!   pathsext_modulesr   r8   r   r(   1   sd   


'r(   c                 C   s
  zddl m} W n ty%   zddlm} W n ty"   tdw Y nw | \}}ddg}t }d }z8|rIt| tj|d}|	d|g |d||d	 W |rgt| |ritj
|rkt| d S d S d S d S |rt| |rtj
|rt| w w w w )
Nr   )setupzL'distutils' is not available. Please install 'setuptools' for binary builds.	build_ext-i)dirz--build-tempzsetup.py)script_namescript_argsrI   )distutils.corerJ   r   
setuptoolsr    getcwdchdirtempfilemkdtempextendr!   r;   shutilrmtree)r   rJ   r#   rI   rO   cwdtemp_dirr   r   r   rF   e   sH   


rF   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
 pdEdF |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,...r@   zset a compiler directive)metavardestdefaulttypeactionhelpz-Ez--compile-time-envr1   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)rc   rf   constrd   rg   z-3   z#use Python 3 syntax mode by default)rc   rf   rj   rg   z--3str3strz-+z--cplusr5   zc++zCompile as C++ rather than Cz-az
--annotaterd   annotatez/Produce a colorized HTML version of the source.)rf   rj   rc   rg   z--annotate-fullcfullczZProduce a colorized HTML version of the source which includes entire generated C/C++-code.z-xz	--excludePATTERNr?   appendz2exclude certain file patterns from the compilation)rb   rc   rf   rd   rg   z-bz--buildrA   
store_truez2build extension modules using distutils/setuptools)rc   rf   rd   rg   rL   z	--inplacer:   zHbuild extension modules in place using distutils/setuptools (implies -b)z-jz
--parallelr=   Nz+run builds in N parallel jobs (default: %d)r   )rc   rb   re   rd   rg   z-fz--forcer2   zforce recompilationz-qz--quietr3   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)rf   rg   sources*)nargs)argparser[   r\   Compiler.CmdLiner]   r^   r_   add_argumentstrintparallel_compiles)r[   r\   r]   r^   r_   parserr   r   r   create_args_parser   s   



r   c                 C   sN   |  |\}}|j}|D ]}|dr| d|  q|| q|`||fS )N-zunknown option )parse_known_argsru   
startswitherrorrp   )r~   r   r*   unknownru   optionr   r   r   parse_args_raw   s   
r   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   rk   rl   rh   F)r   r   r   r:   rA   rC   r=   rh   r*   rs   r	   error_on_unknown_nameserror_on_uninitializedrm   rt   
docstrings)r   r~   r*   r   r   r   
parse_args   s&   
r   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'   )r6   pr   r   r   r9      s    zmain.<locals>.<listcomp>r   z#{}: No such file or directory: '{}')filer   )
r   r   sysprintformatargvstderrexitrV   r(   )r   r*   rH   r+   r!   expanded_pathr   r   r   r   main   s   
r   __main__r   )
__future__r   r   r    rW   rT   Dependenciesr   r   Utilsr   Compilerr	   rC   r|   	cpu_countr}   r   objectr
   r&   r,   r(   rF   r   r   r   r   r   r   r   r   r   <module>   s4    4C

