o
    e                     @   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
 z
ddlmZ dZW n ey5   dZY nw dZi a		dd	d
ZedkrQed ddlmZ dS dS )zBuild a Pyrex file from .pyx source to .so loadable module using
the installed distutils infrastructure. Call:

out_fname = pyx_to_dll("foo.pyx")
    N)DistutilsArgErrorDistutilsErrorCCompilerError)	Extension)grok_environment_error)	build_extTFc           $   	   C   s  t j| sJ dt j|  t jt j| \}}	|sBt j|	\}
}|dv s.J |ts;| dt|  d } t|
| gd}|du rHi }|sQt j	|d}|}|j
dddd	 D ]}t j|\}}||krpd} nq^|d
g }ts}d|v rd}nd}|r|ddg}n|dg}|r|d |r|r|d|g |j
dks|j
drt|dsddi|_n
d|jvrd|jd< | }|d|| d ddlm} ||}|jsg |_|j| trdti|_|d}||_| }|| z| }W n	 ty    w trtd |   |sJ z|d}|!  |" d }|j#r?t j	t j$| t j%|}|r|}t j&|}t'|d\}}}||kr]|}|W S t j%|}|dk r|d7 }t j	|j(|d|  } z)ddl)}!zt j*| rt +|  W n t,y   Y W qcw |!-||  | }W n t.y   Y qcw nt/d| |||ft'|< |W S  t0y   t12d Y dS  t.t j3fy   t14 d }"t5|"}#trt1j67|#d    w )!zUCompile a PYX file to a DLL and return the name of the generated .so
       or .dll .zCould not find %s)z.pyxz.pyNz.c)namesourcesZ_pyxbld.script_argsz	--verbosez--quietr   z--cython-c-in-tempz--forcez--build-lib__init__z	.__init__cython_directivesZset_initial_pathZ
SOURCEFILE)script_namer   r   )Distributionbuildz%options (after parsing command line):)NNr   d      z	.reload%sz#reload count for %s reached maximum
)8ospathexistsabspathsplitsplitext
HAS_CYTHONlenr   joinr   getDEBUGappendextendendswithhasattrr   copyupdatedistutils.distr   Zext_modulesr   ZcmdclassZget_command_objZ
build_baseZfind_config_filesZparse_config_filesZparse_command_liner   printZdump_option_dictsZrun_commandsZget_outputsinplacedirnamebasenamegetmtime_reloadsZ	build_libshutilisfileunlinkOSErrorcopy2IOErrorImportErrorKeyboardInterruptsysexiterrorexc_infor   stderrwrite)$filenameextZforce_rebuildZbuild_in_tempZpyxbuild_dirZ
setup_argsZreload_supportr)   r   r   modname	extensionZpackage_base_dirpackage_nameZpnamer   quietargsZsargsr   distr   ZcfgfilesokZobj_build_extZso_pathZorg_path	timestampZlast_timestampZ	last_pathcountr+   Zr_pathr.   excr8    rH   BD:\Projects\ConvertPro\env\Lib\site-packages\pyximport/pyxbuild.py
pyx_to_dll   s    














rJ   __main__z	dummy.pyxr   )test)Nr   FNNFF)__doc__r   r6   Zdistutils.errorsr   r   r   Zdistutils.extensionr   Zdistutils.utilr   ZCython.Distutils.build_extr   r   r4   r    r-   rJ   __name__ rL   rH   rH   rH   rI   <module>   s,    
 